rtl8139: fix large_send_mss divide-by-zero
PATCH 1/1 rtl8139: fix large_send_mss divide-by-zero
If the driver sets large_send_mss to 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.
Solve these issues by skipping offloading when large_send_mss=0.
This issue was found by OSS-Fuzz as part of Alexander Bulekov's device fuzzing work. The reproducer is:
$ cat << EOF | ./qemu-system-i386 -display none -machine accel=qtest, -m \ 512M,slots=1,maxmem=0xffff000000000000 -machine q35 -nodefaults -device \ rtl8139,netdev=net0 -netdev user,id=net0 -device \ pc-dimm,id=nv1,memdev=mem1,addr=0xb800a64602800000 -object \ memory-backend-ram,id=mem1,size=2M -qtest stdio outl 0xcf8 0x80000814 outl 0xcfc 0xe0000000 outl 0xcf8 0x80000804 outw 0xcfc 0x06 write 0xe0000037 0x1 0x04 write 0xe00000e0 0x2 0x01 write 0x1 0x1 0x04 write 0x3 0x1 0x98 write 0xa 0x1 0x8c write 0xb 0x1 0x02 write 0xc 0x1 0x46 write 0xd 0x1 0xa6 write 0xf 0x1 0xb8 write 0xb800a646028c000c 0x1 0x08 write 0xb800a646028c000e 0x1 0x47 write 0xb800a646028c0010 0x1 0x02 write 0xb800a646028c0017 0x1 0x06 write 0xb800a646028c0036 0x1 0x80 write 0xe00000d9 0x1 0x40 EOF
--- hw/net/rtl8139.c | 3 +++ 1 file changed, 3 insertions(+)
hw/net/rtl8139.c +3 -0
@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)int large_send_mss = (txdw0 >>CP_TC_LGSEN_MSS_SHIFT ) &CP_TC_LGSEN_MSS_MASK ; +if (large_send_mss ==0 ) { + goto skip_offload; + } DPRINTF("+++ C+ mode offloaded task TSO IP data %d " "frame data %d specified MSS=%d\n",
Signature · 1 line
2.39.2
Quoted 12 lines · Stefan Hajnoczi
If the driver sets
large_send_mssto 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.Solve these issues by skipping offloading when large_send_mss=0.
hw/net/rtl8139.c +0
-0
hw/net/rtl8139.c static int rtl8139_cplus_transmit_one(RTL8139State *s) · line 2159
Quoted 6 lines
hw/net/rtl8139.c +3
-0@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)int large_send_mss = (txdw0 >>CP_TC_LGSEN_MSS_SHIFT ) &CP_TC_LGSEN_MSS_MASK ; +if (large_send_mss ==0 ) { + goto skip_offload; + }
Looks like 0 is the only problematic value for the code, so
thanks
-- PMM
Jason Wang
Acked-byQuoted 15 lines · Peter Maydell
Quoted 13 lines · Stefan Hajnoczi
If the driver sets
large_send_mssto 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.Solve these issues by skipping offloading when large_send_mss=0.
hw/net/rtl8139.c +0
-0@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
Quoted 8 lines
hw/net/rtl8139.c static int rtl8139_cplus_transmit_one(RTL8139State *s) · line 2159
Quoted 5 lines
hw/net/rtl8139.c +3
-0int large_send_mss = (txdw0 >>CP_TC_LGSEN_MSS_SHIFT ) &CP_TC_LGSEN_MSS_MASK ; +if (large_send_mss ==0 ) { + goto skip_offload; + }Looks like 0 is the only problematic value for the code, so
Reviewed-by Peter Maydell <[email protected]>
I think it's not worth 8.0. So I've queued this.
If anyone think it is, Peter may queue this directly with
Thanks
Quoted 4 lines
thanks
-- PMM
Quoted 5 lines · Stefan Hajnoczi
If the driver sets
large_send_mssto 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.Solve these issues by skipping offloading when large_send_mss=0.
Quoted 2 lines
Fixes 6d71357a3b65 ("rtl8139: honor large send MSS value")
/mjt
Quoted 35 lines · Stefan Hajnoczi
If the driver sets
large_send_mssto 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.Solve these issues by skipping offloading when large_send_mss=0.
This issue was found by OSS-Fuzz as part of Alexander Bulekov's device fuzzing work. The reproducer is:
$ cat << EOF | ./qemu-system-i386 -display none -machine accel=qtest, -m \ 512M,slots=1,maxmem=0xffff000000000000 -machine q35 -nodefaults -device \ rtl8139,netdev=net0 -netdev user,id=net0 -device \ pc-dimm,id=nv1,memdev=mem1,addr=0xb800a64602800000 -object \ memory-backend-ram,id=mem1,size=2M -qtest stdio outl 0xcf8 0x80000814 outl 0xcfc 0xe0000000 outl 0xcf8 0x80000804 outw 0xcfc 0x06 write 0xe0000037 0x1 0x04 write 0xe00000e0 0x2 0x01 write 0x1 0x1 0x04 write 0x3 0x1 0x98 write 0xa 0x1 0x8c write 0xb 0x1 0x02 write 0xc 0x1 0x46 write 0xd 0x1 0xa6 write 0xf 0x1 0xb8 write 0xb800a646028c000c 0x1 0x08 write 0xb800a646028c000e 0x1 0x47 write 0xb800a646028c0010 0x1 0x02 write 0xb800a646028c0017 0x1 0x06 write 0xb800a646028c0036 0x1 0x80 write 0xe00000d9 0x1 0x40 EOF
Quoted 1 line
Maybe instead:
so that gitlab will auto-close the issue.
Thank you
-Alex
Quoted 25 lines
Fixes 6d71357a3b65 ("rtl8139: honor large send MSS value")Reported-by Alexander Bulekov <[email protected]>Cc Peter Maydell <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- hw/net/rtl8139.c | 3 +++ 1 file changed, 3 insertions(+)hw/net/rtl8139.c +3
-0@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)int large_send_mss = (txdw0 >>CP_TC_LGSEN_MSS_SHIFT ) &CP_TC_LGSEN_MSS_MASK ; +if (large_send_mss ==0 ) { + goto skip_offload; + } DPRINTF("+++ C+ mode offloaded task TSO IP data %d " "frame data %d specified MSS=%d\n",Signature · 1 line
2.39.2
Quoted 35 lines · Stefan Hajnoczi
If the driver sets
large_send_mssto 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.Solve these issues by skipping offloading when large_send_mss=0.
This issue was found by OSS-Fuzz as part of Alexander Bulekov's device fuzzing work. The reproducer is:
$ cat << EOF | ./qemu-system-i386 -display none -machine accel=qtest, -m \ 512M,slots=1,maxmem=0xffff000000000000 -machine q35 -nodefaults -device \ rtl8139,netdev=net0 -netdev user,id=net0 -device \ pc-dimm,id=nv1,memdev=mem1,addr=0xb800a64602800000 -object \ memory-backend-ram,id=mem1,size=2M -qtest stdio outl 0xcf8 0x80000814 outl 0xcfc 0xe0000000 outl 0xcf8 0x80000804 outw 0xcfc 0x06 write 0xe0000037 0x1 0x04 write 0xe00000e0 0x2 0x01 write 0x1 0x1 0x04 write 0x3 0x1 0x98 write 0xa 0x1 0x8c write 0xb 0x1 0x02 write 0xc 0x1 0x46 write 0xd 0x1 0xa6 write 0xf 0x1 0xb8 write 0xb800a646028c000c 0x1 0x08 write 0xb800a646028c000e 0x1 0x47 write 0xb800a646028c0010 0x1 0x02 write 0xb800a646028c0017 0x1 0x06 write 0xb800a646028c0036 0x1 0x80 write 0xe00000d9 0x1 0x40 EOF
Quoted 8 lines
Fixes 6d71357a3b65 ("rtl8139: honor large send MSS value")Reported-by Alexander Bulekov <[email protected]>Cc Peter Maydell <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- hw/net/rtl8139.c | 3 +++ 1 file changed, 3 insertions(+)