memcpy param-overlap in Slirp ip_stripoptions through e1000e
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| QEMU |
Fix Released
|
Undecided
|
Dr. David Alan Gilbert | ||
Bug Description
Hello,
While fuzzing, I found an input that triggers an overlapping memcpy (caught by AddressSanitizer).
Overlapping memcpys are undefined behavior according to the POSIX and C standards, and can lead to bugs.
==16666==ERROR: AddressSanitizer: memcpy-
#0 0x5622d7b6a3d4 in __asan_memcpy (/home/
#1 0x5622d896a2d2 in ip_stripoptions /home/alxndr/
#2 0x5622d8963378 in udp_input /home/alxndr/
#3 0x5622d89351ea in slirp_input /home/alxndr/
#4 0x5622d852e162 in net_slirp_receive /home/alxndr/
#5 0x5622d8515851 in nc_sendv_compat /home/alxndr/
#6 0x5622d8515851 in qemu_deliver_
#7 0x5622d851786d in qemu_net_
#8 0x5622d851786d in qemu_net_
#9 0x5622d851b1c1 in net_hub_receive_iov /home/alxndr/
#10 0x5622d851b1c1 in net_hub_
#11 0x5622d851572b in qemu_deliver_
#12 0x5622d851786d in qemu_net_
#13 0x5622d851786d in qemu_net_
#14 0x5622d828bf87 in net_tx_pkt_sendv /home/alxndr/
#15 0x5622d828bf87 in net_tx_pkt_send /home/alxndr/
#16 0x5622d82b5f22 in e1000e_tx_pkt_send /home/alxndr/
#17 0x5622d82b5f22 in e1000e_
#18 0x5622d82b5f22 in e1000e_start_xmit /home/alxndr/
#19 0x5622d82b2be0 in e1000e_set_tdt /home/alxndr/
#20 0x5622d82a30fc in e1000e_core_write /home/alxndr/
#21 0x5622d7c9e336 in memory_
#22 0x5622d7c9dcdf in access_
#23 0x5622d7c9dcdf in memory_
#24 0x5622d7bb31d3 in flatview_
#25 0x5622d7babb97 in flatview_write /home/alxndr/
#26 0x5622d7babb97 in address_space_write /home/alxndr/
0x625000264940 is located 64 bytes inside of 8354-byte region [0x625000264900
allocated by thread T0 here:
#0 0x5622d7b6b06d in malloc (/home/
#1 0x7f724b932500 in g_malloc (/usr/lib/
0x625000264948 is located 72 bytes inside of 8354-byte region [0x625000264900
allocated by thread T0 here:
#0 0x5622d7b6b06d in malloc (/home/
#1 0x7f724b932500 in g_malloc (/usr/lib/
I can reproduce it in qemu 5.0 built with --enable-sanitizers using:
cat << EOF | ~/Development/
outl 0xcf8 0x80001010
outl 0xcfc 0xe1020000
outl 0xcf8 0x80001014
outl 0xcf8 0x80001004
outw 0xcfc 0x7
outl 0xcf8 0x800010a2
outl 0xcf8 0x8000fa24
outl 0xcfc 0xe1069000
outl 0xcf8 0x8000fa04
outw 0xcfc 0x7
outl 0xcf8 0x8000fb20
write 0xe1069100 0xe 0xff81000000000
write 0x820b 0xc 0x080047bb0c02e
write 0xe1020403 0x36 0xb700000000e10
EOF
I also attached the trace to this launchpad report, in case the formatting is broken:
qemu-system-i386 -M pc-q35-5.0 -accel qtest -qtest stdio -nographic -monitor none -serial none < attachment
Please let me know if I can provide any further info.
-Alex
| Changed in qemu: | |
| status: | In Progress → Fix Committed |

Created patch and merge request in upstream libslirp:
https:/ /gitlab. freedesktop. org/dgilbert/ libslirp/ -/commit/ d620bac88892352 4f8b8407dbf35f6 d2b3b7ddb2