general protection fault in ec168_streaming_ctrl
Subsystems (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 141b164bbe18 Merge tag 'char-misc-7.4-rc4' of git://git.ke.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=15d3c5be580000 kernel config: https://syzkaller.appspot.com/x/.config?x=1cf189394a856f11 dashboard link: https://syzkaller.appspot.com/bug?extid=436c71c257f18c488712 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=134f0411580000
AI-generated root cause summary:
In dvb_usb_start_feed(), the driver fails to synchronize against concurrent frontend sleep (dvb_usb_fe_sleep()) and ignores the error return value from usb_urb_submitv2(). Because dvb_usb_start_feed() does not hold a lock or cache adap->active_fe locally, dvb_usb_fe_sleep() can concurrently power down the hardware and reset adap->active_fe to -1. When dvb_usb_start_feed()随后 invokes d->props->streaming_ctrl(adap->fe[adap->active_fe], 1), it evaluates adap->fe[-1], which indexes out of bounds into the adjacent struct dvb_net (reading NULL). Passing fe = NULL to the driver's streaming_ctrl callback (ec168_streaming_ctrl) triggers a NULL pointer dereference when fe_to_d(fe) accesses fe->dvb at offset 0x308.
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=436c71c257f18c488712
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000061: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000308-0x000000000000030f] CPU: 1 UID: 0 PID: 6028 Comm: syz-executor140 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026 RIP: 0010:ec168_streaming_ctrl+0x73/0x210 drivers/media/usb/dvb-usb-v2/ec168.c:312 Code: c7 40 04 00 00 f3 f3 65 48 8b 05 70 5b 60 0d 48 89 44 24 58 31 c0 e8 3c 74 b3 f9 49 8d bc 24 08 03 00 00 48 89 f8 48 c1 e8 03 <42> 80 3c 28 00 0f 85 77 01 00 00 4d 8b a4 24 08 03 00 00 48 b8 00 RSP: 0018:ffffc9000360fac0 EFLAGS: 00010202 RAX: 0000000000000061 RBX: 0000000000000001 RCX: 0000000000000000 RDX: ffff888032d02580 RSI: ffffffff885b14a4 RDI: 0000000000000308 RBP: 1ffff920006c1f58 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000 R13: dffffc0000000000 R14: 1ffff920006c1f6e R15: ffff888059050000 FS: 00007f1d14ff96c0(0000) GS:ffff888122569000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd878908b8 CR3: 000000007eb0f000 CR4: 00000000003526f0 Call Trace: <TASK> dvb_usb_start_feed+0xa03/0xef0 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:308 dmx_ts_feed_start_filtering+0xf6/0x220 drivers/media/dvb-core/dvb_demux.c:747 dvb_dmxdev_start_feed+0x273/0x3f0 drivers/media/dvb-core/dmxdev.c:658 dvb_dmxdev_filter_start+0x1b6/0xdd0 drivers/media/dvb-core/dmxdev.c:769 dvb_dmxdev_pes_filter_set drivers/media/dvb-core/dmxdev.c:985 [inline] dvb_demux_do_ioctl+0xe64/0x1200 drivers/media/dvb-core/dmxdev.c:1099 dvb_usercopy+0x167/0x340 drivers/media/dvb-core/dvbdev.c:996 dvb_demux_ioctl+0x29/0x40 drivers/media/dvb-core/dmxdev.c:1208 vfs_ioctl fs/ioctl.c:52 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl fs/ioctl.c:584 [inline] __x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x7b0 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f1d1503188b Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00 RSP: 002b:00007f1d14ff90f0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007f1d1503188b RDX: 00007f1d14ff9150 RSI: 0000000040146f2c RDI: 0000000000000004 RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1d150ce100 R13: 00007f1d150ce140 R14: 00007f1d14ff9150 R15: 00007ffc0aa43958 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:ec168_streaming_ctrl+0x73/0x210 drivers/media/usb/dvb-usb-v2/ec168.c:312 Code: c7 40 04 00 00 f3 f3 65 48 8b 05 70 5b 60 0d 48 89 44 24 58 31 c0 e8 3c 74 b3 f9 49 8d bc 24 08 03 00 00 48 89 f8 48 c1 e8 03 <42> 80 3c 28 00 0f 85 77 01 00 00 4d 8b a4 24 08 03 00 00 48 b8 00 RSP: 0018:ffffc9000360fac0 EFLAGS: 00010202 RAX: 0000000000000061 RBX: 0000000000000001 RCX: 0000000000000000 RDX: ffff888032d02580 RSI: ffffffff885b14a4 RDI: 0000000000000308 RBP: 1ffff920006c1f58 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000 R13: dffffc0000000000 R14: 1ffff920006c1f6e R15: ffff888059050000 FS: 00007f1d14ff96c0(0000) GS:ffff888122569000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd878908b8 CR3: 000000007eb0f000 CR4: 00000000003526f0 ---------------- Code disassembly (best guess): 0: c7 40 04 00 00 f3 f3 movl $0xf3f30000,0x4(%rax) 7: 65 48 8b 05 70 5b 60 mov %gs:0xd605b70(%rip),%rax # 0xd605b7f e: 0d f: 48 89 44 24 58 mov %rax,0x58(%rsp) 14: 31 c0 xor %eax,%eax 16: e8 3c 74 b3 f9 call 0xf9b37457 1b: 49 8d bc 24 08 03 00 lea 0x308(%r12),%rdi 22: 00 23: 48 89 f8 mov %rdi,%rax 26: 48 c1 e8 03 shr $0x3,%rax * 2a: 42 80 3c 28 00 cmpb $0x0,(%rax,%r13,1) <-- trapping instruction 2f: 0f 85 77 01 00 00 jne 0x1ac 35: 4d 8b a4 24 08 03 00 mov 0x308(%r12),%r12 3c: 00 3d: 48 rex.W 3e: b8 .byte 0xb8
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
PATCH 1/1 media: dvb: reject dmxdev ioctl until adapter frontend init done
There is a race for usbv2 adapter dvb init and dmxdev ioctl:
CPU1 CPU2
==== ====
dvb_usbv2_probe()->
dvb_usbv2_init()->
dvb_usbv2_adapter_init()->
dvb_usbv2_adapter_dvb_init()->
dvb_dmxdev_init()
dmxdev is ready dvb_demux_ioctl()->
dvb_demux_do_ioctl()->
...
dvb_usb_start_feed()
In the current context, active_fe
is 0 and adapter->fe[0] is NULL
because frontend hasn't inited,
this potentially hitting [1] dvb_usbv2_adapter_frontend_init()
Move active_fe init to dvb_usbv2_adapter_init() before dmxdev init, this would reject dmxdev ioctl.
[1]
KASAN: null-ptr-deref in range [0x0000000000000308-0x000000000000030f] RIP: 0010:ec168_streaming_ctrl+0x73/0x210 drivers/media/usb/dvb-usb-v2/ec168.c:312 Call Trace: dvb_usb_start_feed+0xa03/0xef0 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:308 dmx_ts_feed_start_filtering+0xf6/0x220 drivers/media/dvb-core/dvb_demux.c:747 dvb_dmxdev_start_feed+0x273/0x3f0 drivers/media/dvb-core/dmxdev.c:658 dvb_dmxdev_filter_start+0x1b6/0xdd0 drivers/media/dvb-core/dmxdev.c:769 dvb_dmxdev_pes_filter_set drivers/media/dvb-core/dmxdev.c:985 [inline] dvb_demux_do_ioctl+0xe64/0x1200 drivers/media/dvb-core/dmxdev.c:1099 dvb_usercopy+0x167/0x340 drivers/media/dvb-core/dvbdev.c:996 dvb_demux_ioctl+0x29/0x40 drivers/media/dvb-core/dmxdev.c:1208
--- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +1 -1
@@ -637,7 +637,6 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)dev_dbg (&d->udev->dev,"%s: adap=%d\n" , __func__, adap->id);memset (adap->fe,0 ,sizeof (adap->fe)); - adap->active_fe =-1 ;if (d->props->frontend_attach) { ret = d->props->frontend_attach (adap);
@@ -760,6 +759,7 @@ static int dvb_usbv2_adapter_init(struct dvb_usb_device *d) adap = &d->adapter[i]; adap->id = i; adap->props = &d->props->adapter[i]; + adap->active_fe =-1 ;/* speed - when running at FULL speed we need a HW PID filter */ if (d->udev->speed == USB_SPEED_FULL &&
Signature · 1 line
2.43.0