general protection fault in __media_device_register

Status: moderation: reported on 2026/11/25 00:37
Subsystems: media
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+465ba5a5ff721689b00d@syzkaller.appspotmail.com
First crash: 1h36m, last: 1h31m
✨ AI cause bisection: introduced by (AI job) :
commit 37ecc7b1278f4184a6869504f7074b4a54f112c5
Author: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Date: Wed Jan 27 09:07:24 2016 +0000

  [media] em28xx: add media controller support

✨ AI-generated root cause summary:

In drivers/media/usb/em28xx/em28xx-cards.c, em28xx_init_dev() calls em28xx_media_device_init() without checking its return value. When the kzalloc_obj(*mdev) allocation in em28xx_media_device_init() fails and returns -ENOMEM, dev->media_dev remains NULL while device initialization continues. Later in em28xx_usb_probe(), media_device_register(dev->media_dev) is called unconditionally with dev->media_dev == NULL, triggering a NULL-pointer dereference in __media_device_register() at mdev->devnode = devnode.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 8d7fe9885c62:

Root Cause Analysis

The crash is a NULL-pointer dereference caused by an unchecked error return from em28xx_media_device_init() in drivers/media/usb/em28xx/em28xx-cards.c, which leaves dev->media_dev as NULL and allows probing to proceed to media_device_register(dev->media_dev).

Detailed Mechanism

  1. Failed allocation ignored in em28xx_init_dev(): In drivers/media/usb/em28xx/em28xx-cards.c, em28xx_init_dev() invokes em28xx_media_device_init(dev, udev) at line 3947 without checking its return value:

    em28xx_media_device_init(dev, udev);
    

    Inside em28xx_media_device_init() (lines 3751–3771), when CONFIG_MEDIA_CONTROLLER is enabled, it allocates struct media_device *mdev:

    mdev = kzalloc_obj(*mdev);
    if (!mdev)
        return -ENOMEM;
    ...
    dev->media_dev = mdev;
    

    When kzalloc_obj(*mdev) fails (as triggered by failslab in the report), em28xx_media_device_init() returns -ENOMEM before assigning dev->media_dev, leaving dev->media_dev == NULL. Because em28xx_init_dev() discards the return value, it continues initialization and returns 0 to em28xx_usb_probe().

  2. Unconditional media_device_register() with NULL pointer: At the end of em28xx_usb_probe() (drivers/media/usb/em28xx/em28xx-cards.c:4444), the driver calls media_device_register() unconditionally on dev->media_dev:

    #ifdef CONFIG_MEDIA_CONTROLLER
    retval = media_device_register(dev->media_dev);
    #endif
    

    This macro expands to __media_device_register(dev->media_dev, THIS_MODULE) in drivers/media/mc/mc-device.c (lines 734–748). After allocating devnode, __media_device_register() immediately dereferences mdev at line 745:

    mdev->devnode = devnode;
    

    With mdev == NULL, writing to mdev->devnode (at offset 0x8 of struct media_device) triggers a NULL-pointer dereference in the range [0x0000000000000008-0x000000000000000f].

  3. Additional affected paths when dev->media_dev == NULL: Note that if em28xx_init_dev() succeeds with dev->media_dev == NULL, dev->media_dev can also be passed to media_device_register_entity() in em28xx_v4l2_create_entities() (drivers/media/usb/em28xx/em28xx-video.c:1160, 1181), which likewise dereferences mdev without a NULL check.

Fix Direction

Check and propagate the error return value of em28xx_media_device_init(dev, udev) in em28xx_init_dev() (returning the error and aborting probe if allocation fails), or ensure all dev->media_dev consumers (including em28xx_usb_probe() and em28xx_v4l2_create_entities()) guard against dev->media_dev == NULL if media controller initialization is intended to be optional.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
25f91b83 assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ✅ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ general protection fault in __media_device_register 2026/11/24 23:48 2026/11/24 23:48 2026/11/25 00:29 e76bb7a5
cc710625 bisect-cause IsRelease: ❌ ❓ general protection fault in __media_device_register 2026/11/24 23:48 2026/11/24 23:48 2026/11/25 00:30 e76bb7a5

Sample crash report:
em28xx 5-1:0.0: New device syz syz @ 480 Mbps (2040:0264, interface 0, class 0)
em28xx 5-1:0.0: Audio interface 0 found (Vendor Class)
em28xx 5-1:0.0: unknown em28xx chip ID (0)
FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 1
CPU: 0 UID: 0 PID: 5363 Comm: syz.0.0 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 fail_dump lib/fault-inject.c:80 [inline]
 should_fail_ex+0x3eb/0x540 lib/fault-inject.c:181
 should_failslab+0xa8/0x100 mm/failslab.c:46
 slab_pre_alloc_hook mm/slub.c:4675 [inline]
 slab_alloc_node mm/slub.c:5011 [inline]
 __kmalloc_cache_noprof+0x9e/0x600 mm/slub.c:5676
 _kmalloc_noprof include/linux/slab.h:991 [inline]
 _kzalloc_noprof include/linux/slab.h:1312 [inline]
 em28xx_media_device_init drivers/media/usb/em28xx/em28xx-cards.c:3757 [inline]
 em28xx_init_dev+0x857/0x2680 drivers/media/usb/em28xx/em28xx-cards.c:3947
 em28xx_usb_probe+0x17b2/0x2dd0 drivers/media/usb/em28xx/em28xx-cards.c:4323
 usb_probe_interface+0x751/0xe00 drivers/usb/core/driver.c:399
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x254/0xae0 drivers/base/dd.c:707
 __driver_probe_device+0x1e8/0x360 drivers/base/dd.c:869
 driver_probe_device+0x4f/0x240 drivers/base/dd.c:899
 __device_attach_driver+0x270/0x410 drivers/base/dd.c:1027
 bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
 __device_attach+0x2bd/0x430 drivers/base/dd.c:1131
 proc_ioctl+0x409/0x660 drivers/usb/core/devio.c:2370
 proc_ioctl_default+0xc4/0x110 drivers/usb/core/devio.c:2405
 usbdev_do_ioctl drivers/usb/core/devio.c:2769 [inline]
 usbdev_ioctl+0x139d/0x21a0 drivers/usb/core/devio.c:2829
 vfs_ioctl fs/ioctl.c:52 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f30039a9519
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f300489efe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f3003c36360 RCX: 00007f30039a9519
RDX: 0000200000000140 RSI: 00000000c0105512 RDI: 0000000000000004
RBP: 00007f300489f050 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007f3003c363f8 R14: 00007f3003c36360 R15: 00007ffc64430c58
 </TASK>
em28xx 5-1:0.0: Config register raw data: 0xfffffffb
em28xx 5-1:0.0: AC97 chip type couldn't be determined
em28xx 5-1:0.0: No AC97 audio processor
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 0 UID: 0 PID: 5363 Comm: syz.0.0 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:__media_device_register+0x6e/0x3c0 drivers/media/mc/mc-device.c:745
Code: 20 46 6f 06 ba 60 05 00 00 be c0 0d 00 00 e8 79 c5 0d fa 48 85 c0 0f 84 7a 01 00 00 49 89 c6 4d 8d 6f 08 4d 89 ec 49 c1 ec 03 <41> 80 3c 1c 00 74 08 4c 89 ef e8 c3 bd 19 fa 4c 89 2c 24 4d 89 75
RSP: 0018:ffffc9000e48f7c0 EFLAGS: 00010202
RAX: ffff8880360d0000 RBX: dffffc0000000000 RCX: 6db2fee0ac140f00
RDX: 00000000000014f3 RSI: ffffffff8e6af97e RDI: 00000000ffffffff
RBP: 0000000000000000 R08: ffffffff91be6abf R09: 1ffffffff237cd57
R10: dffffc0000000000 R11: fffffbfff237cd58 R12: 0000000000000001
R13: 0000000000000008 R14: ffff8880360d0000 R15: 0000000000000000
FS:  00007f300489f6c0(0000) GS:ffff88808a9e9000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f300489efe8 CR3: 0000000044767000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 em28xx_usb_probe+0x1c5e/0x2dd0 drivers/media/usb/em28xx/em28xx-cards.c:4444
 usb_probe_interface+0x751/0xe00 drivers/usb/core/driver.c:399
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x254/0xae0 drivers/base/dd.c:707
 __driver_probe_device+0x1e8/0x360 drivers/base/dd.c:869
 driver_probe_device+0x4f/0x240 drivers/base/dd.c:899
 __device_attach_driver+0x270/0x410 drivers/base/dd.c:1027
 bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
 __device_attach+0x2bd/0x430 drivers/base/dd.c:1131
 proc_ioctl+0x409/0x660 drivers/usb/core/devio.c:2370
 proc_ioctl_default+0xc4/0x110 drivers/usb/core/devio.c:2405
 usbdev_do_ioctl drivers/usb/core/devio.c:2769 [inline]
 usbdev_ioctl+0x139d/0x21a0 drivers/usb/core/devio.c:2829
 vfs_ioctl fs/ioctl.c:52 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f30039a9519
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f300489efe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f3003c36360 RCX: 00007f30039a9519
RDX: 0000200000000140 RSI: 00000000c0105512 RDI: 0000000000000004
RBP: 00007f300489f050 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007f3003c363f8 R14: 00007f3003c36360 R15: 00007ffc64430c58
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__media_device_register+0x6e/0x3c0 drivers/media/mc/mc-device.c:745
Code: 20 46 6f 06 ba 60 05 00 00 be c0 0d 00 00 e8 79 c5 0d fa 48 85 c0 0f 84 7a 01 00 00 49 89 c6 4d 8d 6f 08 4d 89 ec 49 c1 ec 03 <41> 80 3c 1c 00 74 08 4c 89 ef e8 c3 bd 19 fa 4c 89 2c 24 4d 89 75
RSP: 0018:ffffc9000e48f7c0 EFLAGS: 00010202
RAX: ffff8880360d0000 RBX: dffffc0000000000 RCX: 6db2fee0ac140f00
RDX: 00000000000014f3 RSI: ffffffff8e6af97e RDI: 00000000ffffffff
RBP: 0000000000000000 R08: ffffffff91be6abf R09: 1ffffffff237cd57
R10: dffffc0000000000 R11: fffffbfff237cd58 R12: 0000000000000001
R13: 0000000000000008 R14: ffff8880360d0000 R15: 0000000000000000
FS:  00007f300489f6c0(0000) GS:ffff88808a9e9000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0b2b70dad0 CR3: 0000000044767000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess), 4 bytes skipped:
   0:	ba 60 05 00 00       	mov    $0x560,%edx
   5:	be c0 0d 00 00       	mov    $0xdc0,%esi
   a:	e8 79 c5 0d fa       	call   0xfa0dc588
   f:	48 85 c0             	test   %rax,%rax
  12:	0f 84 7a 01 00 00    	je     0x192
  18:	49 89 c6             	mov    %rax,%r14
  1b:	4d 8d 6f 08          	lea    0x8(%r15),%r13
  1f:	4d 89 ec             	mov    %r13,%r12
  22:	49 c1 ec 03          	shr    $0x3,%r12
* 26:	41 80 3c 1c 00       	cmpb   $0x0,(%r12,%rbx,1) <-- trapping instruction
  2b:	74 08                	je     0x35
  2d:	4c 89 ef             	mov    %r13,%rdi
  30:	e8 c3 bd 19 fa       	call   0xfa19bdf8
  35:	4c 89 2c 24          	mov    %r13,(%rsp)
  39:	4d                   	rex.WRB
  3a:	89                   	.byte 0x89
  3b:	75                   	.byte 0x75

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/24 23:53 upstream 8d7fe9885c62 50451a16 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in __media_device_register
2026/11/24 23:48 upstream 8d7fe9885c62 50451a16 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root general protection fault in __media_device_register
* Struck through repros no longer work on HEAD.