Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1620882rdd; Thu, 11 Jan 2024 04:53:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGa+hDOVOW4H34Q2kOSJReoZwfE09v655XMRoPFlgYaj46Eg+0ewQOvssPnHsghmKhOSkK X-Received: by 2002:aa7:cfd1:0:b0:554:2905:a51d with SMTP id r17-20020aa7cfd1000000b005542905a51dmr601618edy.23.1704977636615; Thu, 11 Jan 2024 04:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704977636; cv=none; d=google.com; s=arc-20160816; b=euSqbwjJbrpS7wumMbLboLNfJFjBb3urCe9eC3iGbn80oEavtAQflb4zSU1oFSV4M/ 45yIRDz6dzGUnXSH+A3SwZ/xk6TsTNKj1gedDaF7tnFb8QwXvgVdtLVuWWq4J291Gi8Q nkh607v1zp+0tZE/o4mmdYH7znfdKO+gZclTHKqjlGkXThKmf7RloG6OCdYC2g2GHD7I hvcG8j0JXiw5tudKtYRlD8PtGFsZHBMIvx3rWQfyvHdjvIwUc+XEnOIEAyam04wsIKBP AmGMz/a3ar9Hraeb2AzTbsblq+itblBkjb+HPqYkZ6hVsMA+4biY/gnRcyj6Kv76McDY L3UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=1z6DprqHiv/MpYmAquNYV8Sg0nyoMDS8uxahPP8fCVw=; fh=4ePZEIuF4Ebos1HLPxKmmczfd6H2HLzSBAaCYign92g=; b=qnPLjXTyjcXSyo2tfnerAeN6NNYgxXOSplczyVuYI5cG8bWWT9gkrlY6QqM/E+65Sy m7+VEEfuFYDWVaTLoQu0sQdiFsEQDIplh/rcjAWv1ei0kZHF90U5lJsHYZXr41s8PcjC T3iJS1Nje6OZAyx+Z2MHoTVWKvx2HGMqMha8HGpvw2YYW42NpeWyv/3Bkj56MtrN6EVr uMZQAVnRtQXO/NwO9kbOLfHUZc+lzCId6O4fr/LXd0ifcAkrJMEb1+nB1nlhlb2mWDMk eOPRsQUR4LxggSXF6rQ7Sp15mcIu9AD4KBN/6wJ+jmWQ5+FYe4pl6gR3Ae08K+3urUGc xrcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23607-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y97-20020a50bb6a000000b005532bcb144dsi510437ede.379.2024.01.11.04.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 04:53:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23607-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5626F1F23E97 for ; Thu, 11 Jan 2024 12:53:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D376D15E8C; Thu, 11 Jan 2024 12:53:48 +0000 (UTC) Received: from air.basealt.ru (air.basealt.ru [194.107.17.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8C6715AF6; Thu, 11 Jan 2024 12:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: by air.basealt.ru (Postfix, from userid 490) id 5FEEA2F2025C; Thu, 11 Jan 2024 12:53:36 +0000 (UTC) X-Spam-Level: Received: from altlinux.malta.altlinux.ru (obninsk.basealt.ru [217.15.195.17]) by air.basealt.ru (Postfix) with ESMTPSA id 4E64C2F20251; Thu, 11 Jan 2024 12:53:34 +0000 (UTC) From: kovalev@altlinux.org To: harshit.m.mogalapalli@oracle.com Cc: arnd@arndb.de, bryantan@vmware.com, darren.kenny@oracle.com, error27@gmail.com, gregkh@linuxfoundation.org, gustavoars@kernel.org, keescook@chromium.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, pv-drivers@vmware.com, syzkaller@googlegroups.com, vdasa@vmware.com, vegard.nossum@oracle.com, kovalev@altlinux.org, nickel@altlinux.org, oficerovas@altlinux.org, dutyrok@altlinux.org Subject: Re: [PATCH v2 2/2] VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host() Date: Thu, 11 Jan 2024 15:53:30 +0300 Message-Id: <20240111125330.53853-1-kovalev@altlinux.org> X-Mailer: git-send-email 2.33.8 In-Reply-To: <20240105164001.2129796-2-harshit.m.mogalapalli@oracle.com> References: <20240105164001.2129796-2-harshit.m.mogalapalli@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hello, I was also working on solving this problem https://lore.kernel.org/lkml/20240110104042.31865-1-kovalev@altlinux.org/T/#t. Please note that there are 2 such places in the code, and by analogy with your version of the changes, including changes in the approach to calculating the size of the allocated memory, additional changes on top of your changes will be as follows: diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c index ba379cd6d054bd..1a50fcea681bf8 100644 --- a/drivers/misc/vmw_vmci/vmci_datagram.c +++ b/drivers/misc/vmw_vmci/vmci_datagram.c @@ -369,8 +369,9 @@ int vmci_datagram_invoke_guest_handler(struct vmci_datagram *dg) if (dst_entry->run_delayed) { struct delayed_datagram_info *dg_info; - dg_info = kmalloc(sizeof(*dg_info) + (size_t)dg->payload_size, + dg_info = kmalloc(struct_size(dg_info, msg_payload, dg->payload_size), GFP_ATOMIC); + if (!dg_info) { vmci_resource_put(resource); return VMCI_ERROR_NO_MEM; @@ -378,7 +379,9 @@ int vmci_datagram_invoke_guest_handler(struct vmci_datagram *dg) dg_info->in_dg_host_queue = false; dg_info->entry = dst_entry; - memcpy(&dg_info->msg, dg, VMCI_DG_SIZE(dg)); + dg_info->msg = *dg; + memcpy(&dg_info->msg_payload, dg + 1, dg->payload_size); + INIT_WORK(&dg_info->work, dg_delayed_dispatch); schedule_work(&dg_info->work);