VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler()
Message ID | 20240219105315.76955-1-kovalev@altlinux.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-71155-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1205010dyc; Mon, 19 Feb 2024 02:56:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqfrFiea9MHWYZXSRQokD+37Ob1mugi2zO16u3uSt7IneRKT2m8ZgczW4ei4Mnsctoj0GrtJHwIgKz2TuM/ycqG09alw== X-Google-Smtp-Source: AGHT+IEayyeCE/YtdeCyyEjOAO4I53/pOjxqqp4jH2RdsbAVeXyHaDgUSvTKPBtM82BlMXD6KRAN X-Received: by 2002:a17:90b:4c06:b0:299:75aa:8949 with SMTP id na6-20020a17090b4c0600b0029975aa8949mr2396009pjb.22.1708340191177; Mon, 19 Feb 2024 02:56:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708340191; cv=pass; d=google.com; s=arc-20160816; b=AG6U49vsa7IFbMX/I9DAMslcvRvnDmFu0fM8wRLZ/K/wtLidsiQK+GlMzhkNnjIIx1 wdyX85P2Vpeouo1iHe4a0JmLwkCt6bJUlnofjCAya+PLUFVnw97SMrMx3OSgHBud4/3K KGS40EsvPtlpdA2bTqElKBTYwbSHOPAJdTOiVmncr8oRD3Zk+9B7+oYqIBAEom67PKRe V+qVMu3qon5ougBXGF+hLAw7AykoU+7u9vhvTNSKhH/IGRaMTXHvS+95jpZmPxlSy1Am 9Dk8Ep4aS2vZ9Jg75rgP9oogE1NAQon0Wia1Tddr9IfC07uQI3wkoghzPlDQfeMF1jUb Z0fw== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from; bh=bzc2XlEh5PijMOuB9AIg6h8Qf9h3UZ1f4zcg9EYJg8A=; fh=gYfv24SMNtxQublNIrMH9u1yYx4t2lL+oM+BKSW02bQ=; b=wYkDf6RPsDUZoP0Cy929nFklK+mBGNwfdfphxeOLqoBsk5jKc2kLSNDZJ6uif7zHgV igWXGL1lxdU51FKpkwX+zWVRk/UGe76JTyJgrIngTcAtZfWAFcfsRNdFywUaPu7fC6Iz tCBPxC9mAAvlKMCel6qvbFyrTzuV6FGRBXddjH3Kg5oh10jp31bJRwHxsLhN4ExzborI oy+P9pglMGJWhLW5ObR6ft6yldXlNOr5P0rByhj87KyaNAcVaTdNrBM5yu4xtWH7ID3Z t5uMueqU67JbEo5cjVqYy1vP+J2hvn4c3oI1ekrE2Or0s2c1dusmyLWgzV8nQlU/9q7u jGaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=altlinux.org); spf=pass (google.com: domain of linux-kernel+bounces-71155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71155-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id lp15-20020a17090b4a8f00b00298b0cf9766si4341161pjb.48.2024.02.19.02.56.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 02:56:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=altlinux.org); spf=pass (google.com: domain of linux-kernel+bounces-71155-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71155-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9CF1EB2207B for <ouuuleilei@gmail.com>; Mon, 19 Feb 2024 10:54:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB3E12C1B4; Mon, 19 Feb 2024 10:54:13 +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 F304F28DDA for <linux-kernel@vger.kernel.org>; Mon, 19 Feb 2024 10:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708340052; cv=none; b=mlzuUWAnO7zPWmUrNkSeDeaygV1jvo2YvQko392sPWUlUXGAVYomNN3QGweccP5dildIknG7DmNvFwYhp2Q5+VqPMTI0Y95tLFE16AnCbqTIk6llrSypUtsnEIv67YsFMbl7btVmJ39ntnDKK83UDiffzS/+9YnWpdJO6U7+lqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708340052; c=relaxed/simple; bh=v1tv+Hn2MMckB7tibXPo04tWJVN+P3e6WQ1r4106PQ0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iHfCpFad0jPITK1jmZpCkE1/9doooXdrQhOsIGYMIFERL27q5FivuzRA46dqdJpTO0wvJfw+N192BhHI7Oc9H/SYOgUc/WTQLemHWUrIFYpbaLiew1BDEO3ak9fQJeG9g9Aw/76/qefTc9mFxZB5dHGDKeoQU7VVFy/BQPnI3tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.39 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 E59C22F20256; Mon, 19 Feb 2024 10:54:06 +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 2C3B22F20253; Mon, 19 Feb 2024 10:54:05 +0000 (UTC) From: kovalev@altlinux.org To: linux-kernel@vger.kernel.org Cc: keescook@chromium.org, gregkh@linuxfoundation.org, bryantan@vmware.com, vdasa@vmware.com, pv-drivers@vmware.com, arnd@arndb.de, harshit.m.mogalapalli@oracle.com, nickel@altlinux.org, oficerovas@altlinux.org, dutyrok@altlinux.org, kovalev@altlinux.org Subject: [PATCH] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() Date: Mon, 19 Feb 2024 13:53:15 +0300 Message-Id: <20240219105315.76955-1-kovalev@altlinux.org> X-Mailer: git-send-email 2.33.8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791324524021036667 X-GMAIL-MSGID: 1791324524021036667 |
Series |
VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler()
|
|
Commit Message
Vasiliy Kovalev
Feb. 19, 2024, 10:53 a.m. UTC
From: Vasiliy Kovalev <kovalev@altlinux.org> The changes are similar to those given in the commit 19b070fefd0d ("VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()"). Fix filling of the msg and msg_payload in dg_info struct, which prevents a possible "detected field-spanning write" of memcpy warning that is issued by the tracking mechanism __fortify_memcpy_chk. Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org> --- drivers/misc/vmw_vmci/vmci_datagram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Mon, 19 Feb 2024 13:53:15 +0300, kovalev@altlinux.org wrote: > The changes are similar to those given in the commit 19b070fefd0d > ("VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()"). > > Fix filling of the msg and msg_payload in dg_info struct, which prevents a > possible "detected field-spanning write" of memcpy warning that is issued > by the tracking mechanism __fortify_memcpy_chk. > > [...] Since I ended up carrying the other fix, I can carry this one too. :) Applied to for-next/hardening, thanks! [1/1] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() https://git.kernel.org/kees/c/1ce15647a1aa Take care,
diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c index d1d8224c8800c4..a0ad1f3a69f7e9 100644 --- a/drivers/misc/vmw_vmci/vmci_datagram.c +++ b/drivers/misc/vmw_vmci/vmci_datagram.c @@ -378,7 +378,8 @@ 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);