Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler()

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>
Link: https://lore.kernel.org/r/20240219105315.76955-1-kovalev@altlinux.org
Signed-off-by: Kees Cook <keescook@chromium.org>

authored by

Vasiliy Kovalev and committed by
Kees Cook
e606e4b7 f0b7f8ad

+2 -1
+2 -1
drivers/misc/vmw_vmci/vmci_datagram.c
··· 378 378 379 379 dg_info->in_dg_host_queue = false; 380 380 dg_info->entry = dst_entry; 381 - memcpy(&dg_info->msg, dg, VMCI_DG_SIZE(dg)); 381 + dg_info->msg = *dg; 382 + memcpy(&dg_info->msg_payload, dg + 1, dg->payload_size); 382 383 383 384 INIT_WORK(&dg_info->work, dg_delayed_dispatch); 384 385 schedule_work(&dg_info->work);