All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler()
@ 2024-02-19 10:53 kovalev
  2024-03-01  6:42 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: kovalev @ 2024-02-19 10:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: keescook, gregkh, bryantan, vdasa, pv-drivers, arnd,
	harshit.m.mogalapalli, nickel, oficerovas, dutyrok, kovalev

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(-)

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);
-- 
2.33.8


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler()
  2024-02-19 10:53 [PATCH] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() kovalev
@ 2024-03-01  6:42 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2024-03-01  6:42 UTC (permalink / raw)
  To: linux-kernel, kovalev
  Cc: Kees Cook, gregkh, bryantan, vdasa, pv-drivers, arnd,
	harshit.m.mogalapalli, nickel, oficerovas, dutyrok

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,

-- 
Kees Cook


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-01  6:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 10:53 [PATCH] VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() kovalev
2024-03-01  6:42 ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.