milos-linux/drivers
Harshit Mogalapalli 19b070fefd VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()
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>
2024-02-01 10:06:42 -08:00
..
accel accel/ivpu: Improve recovery and reset support 2024-01-25 10:17:37 +01:00
accessibility
acpi
amba
android
ata ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers 2024-01-25 16:59:09 +01:00
atm
auxdisplay
base
bcma
block block-6.8-2024-01-26 2024-01-26 15:19:43 -08:00
bluetooth
bus
cache
cdrom
cdx
char
clk clk: qcom: gcc-x1e80100: Replace of_device.h with explicit includes 2024-01-19 08:17:28 -06:00
clocksource
comedi
connector
counter
cpufreq cpufreq/amd-pstate: Fix setting scaling max/min freq values 2024-01-22 20:35:58 +01:00
cpuidle
crypto
cxl cxl/region:Fix overflow issue in alloc_hpa() 2024-01-24 21:03:03 -08:00
dax
dca
devfreq
dio
dma dmaengine fixes for v6.8-rc1 2024-01-20 15:03:25 -08:00
dma-buf
dpll dpll: fix register pin with unregistered parent pin 2024-01-22 11:01:11 +00:00
edac
eisa
extcon
firewire
firmware drm fixes for 6.8-rc2 2024-01-26 13:52:18 -08:00
fpga
fsi
gnss
gpio gpio: eic-sprd: Clear interrupt after set the interrupt type 2024-01-22 11:38:08 +01:00
gpu One regression fixup to samsung-dsim.c module 2024-01-27 04:12:21 +10:00
greybus
hid
hsi
hte
hv
hwmon
hwspinlock
hwtracing
i2c This cycle, I2C removes the currently unused CLASS_DDC support 2024-01-18 17:29:01 -08:00
i3c
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md md: fix a suspicious RCU usage warning 2024-01-24 22:58:00 -08:00
media media: vb2: refactor setting flags and caps, fix missing cap 2024-01-24 17:27:51 +01:00
memory
memstick
message
mfd
misc VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host() 2024-02-01 10:06:42 -08:00
mmc
most
mtd
mux
net Including fixes from bpf, netfilter and WiFi. 2024-01-25 10:58:35 -08:00
nfc
ntb
nubus
nvdimm
nvme for-6.8/block-2024-01-18 2024-01-18 18:22:40 -08:00
nvmem
of
opp
parisc
parport
pci
pcmcia
peci
perf
phy
pinctrl
platform platform/x86: touchscreen_dmi: Add info for the TECLAST X16 Plus tablet 2024-01-26 20:21:47 +01:00
pmdomain
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi SCSI misc on 20240120 2024-01-20 09:42:32 -08:00
sh
siox
slimbus
soc
soundwire
spi spi: fix finalize message on error return 2024-01-25 21:55:48 +00:00
spmi
ssb
staging This cycle, I2C removes the currently unused CLASS_DDC support 2024-01-18 17:29:01 -08:00
target SCSI misc on 20240120 2024-01-20 09:42:32 -08:00
tc
tee
thermal thermal: intel: powerclamp: Remove dead code for target mwait value 2024-01-22 11:59:22 +01:00
thunderbolt
tty RISC-V Patches for the 6.8 Merge Window, Part 4 2024-01-20 11:06:04 -08:00
ufs SCSI misc on 20240120 2024-01-20 09:42:32 -08:00
uio
usb
vdpa
vfio
vhost
video fbdev: stifb: Fix crash in stifb_blank() 2024-01-23 09:13:24 +01:00
virt
virtio
w1
watchdog
xen
zorro
Kconfig
Makefile