In the Linux kernel, the following vulnerability has been resolved:
net/sched: taprio: Limit TCATAPRIOATTRSCHEDCYCLETIME to INTMAX.
syzkaller found zero division error [0] in divs64rem() called from getcycletimeelapsed(), where sched->cycletime is the divisor.
We have tests in parsetaprioschedule() so that cycletime will never be 0, and actually cycletime is not 0 in getcycletime_elapsed().
The problem is that the types of divisor are different; cycletime is s64, but the argument of divs64_rem() is s32.
syzkaller fed this input and 0x100000000 is cast to s32 to be 0.
@TCATAPRIOATTRSCHEDCYCLE_TIME={0xc, 0x8, 0x100000000}
We use s64 for cycletime to cast it to ktimet, so let's keep it and set max for cycle_time.
While at it, we prevent overflow in setuptxtime() and add another test in parsetaprioschedule() to check if cycletime overflows.
Also, we add a new tdc test case for this issue.
CPU: 1 PID: 103 Comm: kworker/1:3 Not tainted 6.5.0-rc1-00330-g60cc1f7d0605 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Workqueue: ipv6addrconf addrconfdadwork RIP: 0010:divs64rem include/linux/math64.h:42 [inline] RIP: 0010:getcycletimeelapsed net/sched/schtaprio.c:223 [inline] RIP: 0010:findentrytotransmit+0x252/0x7e0 net/sched/schtaprio.c:344 Code: 3c 02 00 0f 85 5e 05 00 00 48 8b 4c 24 08 4d 8b bd 40 01 00 00 48 8b 7c 24 48 48 89 c8 4c 29 f8 48 63 f7 48 99 48 89 74 24 70 <48> f7 fe 48 29 d1 48 8d 04 0f 49 89 cc 48 89 44 24 20 49 8d 85 10 RSP: 0018:ffffc90000acf260 EFLAGS: 00010206 RAX: 177450e0347560cf RBX: 0000000000000000 RCX: 177450e0347560cf RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000100000000 RBP: 0000000000000056 R08: 0000000000000000 R09: ffffed10020a0934 R10: ffff8880105049a7 R11: ffff88806cf3a520 R12: ffff888010504800 R13: ffff88800c00d800 R14: ffff8880105049a0 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88806cf00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0edf84f0e8 CR3: 000000000d73c002 CR4: 0000000000770ee0 PKRU: 55555554 Call Trace: <TASK> getpackettxtime net/sched/schtaprio.c:508 [inline] taprioenqueueone+0x900/0xff0 net/sched/schtaprio.c:577 taprioenqueue+0x378/0xae0 net/sched/schtaprio.c:658 devqdiscenqueue+0x46/0x170 net/core/dev.c:3732 _devxmitskb net/core/dev.c:3821 [inline] _devqueuexmit+0x1b2f/0x3000 net/core/dev.c:4169 devqueuexmit include/linux/netdevice.h:3088 [inline] neighresolveoutput net/core/neighbour.c:1552 [inline] neighresolveoutput+0x4a7/0x780 net/core/neighbour.c:1532 neighoutput include/net/neighbour.h:544 [inline] ip6finishoutput2+0x924/0x17d0 net/ipv6/ip6output.c:135 _ip6finishoutput+0x620/0xaa0 net/ipv6/ip6output.c:196 ip6finishoutput net/ipv6/ip6output.c:207 [inline] NFHOOKCOND include/linux/netfilter.h:292 [inline] ip6output+0x206/0x410 net/ipv6/ip6output.c:228 dstoutput include/net/dst.h:458 [inline] NFHOOK.constprop.0+0xea/0x260 include/linux/netfilter.h:303 ndiscsendskb+0x872/0xe80 net/ipv6/ndisc.c:508 ndiscsendns+0xb5/0x130 net/ipv6/ndisc.c:666 addrconfdadwork+0xc14/0x13f0 net/ipv6/addrconf.c:4175 processonework+0x92c/0x13a0 kernel/workqueue.c:2597 workerthread+0x60f/0x1240 kernel/workqueue.c:2748 kthread+0x2fe/0x3f0 kernel/kthread.c:389 retfromfork+0x2c/0x50 arch/x86/entry/entry64.S:308 </TASK> Modules linked in:
{
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/54xxx/CVE-2023-54251.json",
"cna_assigner": "Linux"
}