kernel_samsung_a53x/drivers/misc
Harshit Mogalapalli d0bff83a60 VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()
[ Upstream commit 19b070fefd0d024af3daa7329cbc0d00de5302ec ]

Syzkaller hit 'WARNING in dg_dispatch_as_host' bug.

memcpy: detected field-spanning write (size 56) of single field "&dg_info->msg"
at drivers/misc/vmw_vmci/vmci_datagram.c:237 (size 24)

WARNING: CPU: 0 PID: 1555 at drivers/misc/vmw_vmci/vmci_datagram.c:237
dg_dispatch_as_host+0x88e/0xa60 drivers/misc/vmw_vmci/vmci_datagram.c:237

Some code commentry, based on my understanding:

544 #define VMCI_DG_SIZE(_dg) (VMCI_DG_HEADERSIZE + (size_t)(_dg)->payload_size)
/// This is 24 + payload_size

memcpy(&dg_info->msg, dg, dg_size);
	Destination = dg_info->msg ---> this is a 24 byte
					structure(struct vmci_datagram)
	Source = dg --> this is a 24 byte structure (struct vmci_datagram)
	Size = dg_size = 24 + payload_size

{payload_size = 56-24 =32} -- Syzkaller managed to set payload_size to 32.

 35 struct delayed_datagram_info {
 36         struct datagram_entry *entry;
 37         struct work_struct work;
 38         bool in_dg_host_queue;
 39         /* msg and msg_payload must be together. */
 40         struct vmci_datagram msg;
 41         u8 msg_payload[];
 42 };

So those extra bytes of payload are copied into msg_payload[], a run time
warning is seen while fuzzing with Syzkaller.

One possible way to fix the warning is to split the memcpy() into
two parts -- one -- direct assignment of msg and second taking care of payload.

Gustavo quoted:
"Under FORTIFY_SOURCE we should not copy data across multiple members
in a structure."

Reported-by: syzkaller <syzkaller@googlegroups.com>
Suggested-by: Vegard Nossum <vegard.nossum@oracle.com>
Suggested-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240105164001.2129796-2-harshit.m.mogalapalli@oracle.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 09:23:11 +01:00
..
altera-stapl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
c2port Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cardreader Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cb710 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cxl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drb Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
echo Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
eeprom Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
genwqe Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
habanalabs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ibmasm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lis3lv02d Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lkdtm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mei mei: me: add arrow lake point H DID 2024-11-19 09:22:39 +01:00
ocxl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
samsung Fix clang 16 errors treewide 2024-06-15 16:28:48 -03:00
sgi-gru Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgi-xp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ti-st misc: st_core: Do not call kfree_skb() under spin_lock_irqsave() 2024-11-18 11:43:05 +01:00
tui drivers: tui: fix out of tree build 2024-06-15 16:21:18 -03:00
tzdev Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uacce Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmw_vmci VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host() 2024-11-19 09:23:11 +01:00
ad525x_dpot-i2c.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ad525x_dpot-spi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ad525x_dpot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ad525x_dpot.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apds990x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apds9802als.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atmel-ssc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atmel_tclib.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bh1770glc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cs5535-mfgpt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ds1682.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dummy-irq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
enclosure.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fastrpc.c misc: fastrpc: Mark all sessions as invalid in cb_remove 2024-11-18 12:13:30 +01:00
hisi_hikey_usb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hmc6352.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hpilo.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hpilo.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ibmvmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ibmvmc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ics932s401.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
isl29003.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
isl29020.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kgdbts.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lattice-ecp3-config.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pch_phub.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci_endpoint_test.c misc: pci_endpoint_test: Add deviceID for J721S2 PCIe EP device support 2024-11-18 12:11:12 +01:00
phantom.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pti.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pvpanic.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qcom-coincell.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sram-exec.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sram.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sram.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tifm_7xx1.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tifm_core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tsl2550.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uid_sys_stats.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmw_balloon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xilinx_sdfec.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00