syzbot


KASAN: use-after-free Read in em28xx_v4l2_open

Status: upstream: reported on 2025/01/10 13:44
Subsystems: media
[Documentation on labels]
Reported-by: syzbot+f49137d13c521670729e@syzkaller.appspotmail.com
First crash: 135d, last: 47d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [media?] KASAN: use-after-free Read in em28xx_v4l2_open 1 (2) 2025/01/10 13:47

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __mutex_waiter_is_first kernel/locking/mutex.c:172 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:664 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0x9eb/0xb10 kernel/locking/mutex.c:730
Read of size 8 at addr ffff88811e081b40 by task v4l_id/7297

CPU: 1 UID: 0 PID: 7297 Comm: v4l_id Not tainted 6.14.0-rc6-syzkaller-ged492c95f13a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0xc3/0x670 mm/kasan/report.c:521
 kasan_report+0xd9/0x110 mm/kasan/report.c:634
 __mutex_waiter_is_first kernel/locking/mutex.c:172 [inline]
 __mutex_lock_common kernel/locking/mutex.c:664 [inline]
 __mutex_lock+0x9eb/0xb10 kernel/locking/mutex.c:730
 em28xx_v4l2_open+0x22c/0x7e0 drivers/media/usb/em28xx/em28xx-video.c:2150
 v4l2_open+0x222/0x490 drivers/media/v4l2-core/v4l2-dev.c:429
 chrdev_open+0x237/0x6a0 fs/char_dev.c:414
 do_dentry_open+0x6cb/0x1390 fs/open.c:956
 vfs_open+0x82/0x3f0 fs/open.c:1086
 do_open fs/namei.c:3830 [inline]
 path_openat+0x1e88/0x2d80 fs/namei.c:3989
 do_filp_open+0x20c/0x470 fs/namei.c:4016
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1428
 do_sys_open fs/open.c:1443 [inline]
 __do_sys_openat fs/open.c:1459 [inline]
 __se_sys_openat fs/open.c:1454 [inline]
 __x64_sys_openat+0x175/0x210 fs/open.c:1454
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4959ccd9a4
Code: 24 20 48 8d 44 24 30 48 89 44 24 28 64 8b 04 25 18 00 00 00 85 c0 75 2c 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 76 60 48 8b 15 55 a4 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffd1729ba60 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007ffd1729bc78 RCX: 00007f4959ccd9a4
RDX: 0000000000000000 RSI: 00007ffd1729cf23 RDI: 00000000ffffff9c
RBP: 00007ffd1729cf23 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd1729bc90 R14: 000055fdfcd7d670 R15: 00007f495a11ca80
 </TASK>

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x4 pfn:0x11e081
flags: 0x200000000000000(node=0|zone=2)
raw: 0200000000000000 0000000000000000 ffffffffffffffff 0000000000000000
raw: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), pid 2807, tgid 2807 (kworker/1:2), ts 364392425977, free_ts 366861223181
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551
 prep_new_page mm/page_alloc.c:1559 [inline]
 get_page_from_freelist+0xe76/0x2b90 mm/page_alloc.c:3477
 __alloc_frozen_pages_noprof+0x21c/0x2290 mm/page_alloc.c:4740
 __alloc_pages_noprof+0xb/0x1b0 mm/page_alloc.c:4774
 __alloc_pages_node_noprof include/linux/gfp.h:265 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:292 [inline]
 ___kmalloc_large_node+0x84/0x1b0 mm/slub.c:4239
 __kmalloc_large_noprof+0x1c/0x70 mm/slub.c:4256
 kmalloc_noprof include/linux/slab.h:898 [inline]
 kzalloc_noprof include/linux/slab.h:1037 [inline]
 em28xx_usb_probe+0x1d0/0x3740 drivers/media/usb/em28xx/em28xx-cards.c:3908
 usb_probe_interface+0x300/0x9c0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:579 [inline]
 really_probe+0x23e/0xa90 drivers/base/dd.c:658
 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:800
 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:830
 __device_attach_driver+0x1df/0x310 drivers/base/dd.c:958
 bus_for_each_drv+0x157/0x1e0 drivers/base/bus.c:462
 __device_attach+0x1e8/0x4b0 drivers/base/dd.c:1030
 bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
 device_add+0x114b/0x1a70 drivers/base/core.c:3666
page last free pid 5483 tgid 5483 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_frozen_pages+0x653/0xde0 mm/page_alloc.c:2660
 __folio_put+0x1e8/0x2d0 mm/swap.c:112
 em28xx_free_device drivers/media/usb/em28xx/em28xx-cards.c:3566 [inline]
 kref_put include/linux/kref.h:65 [inline]
 em28xx_usb_disconnect+0x3a5/0x610 drivers/media/usb/em28xx/em28xx-cards.c:4207
 usb_unbind_interface+0x1da/0x9a0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 device_remove+0x122/0x170 drivers/base/dd.c:561
 __device_release_driver drivers/base/dd.c:1273 [inline]
 device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296
 bus_remove_device+0x22f/0x420 drivers/base/bus.c:579
 device_del+0x396/0x9f0 drivers/base/core.c:3855
 usb_disable_device+0x368/0x7e0 drivers/usb/core/message.c:1418
 usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2316
 hub_port_connect drivers/usb/core/hub.c:5371 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5671 [inline]
 port_event drivers/usb/core/hub.c:5831 [inline]
 hub_event+0x1bed/0x4f40 drivers/usb/core/hub.c:5913
 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3238
 process_scheduled_works kernel/workqueue.c:3319 [inline]
 worker_thread+0x6c8/0xf00 kernel/workqueue.c:3400
 kthread+0x3af/0x750 kernel/kthread.c:464
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffff88811e081a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811e081a80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88811e081b00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                           ^
 ffff88811e081b80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811e081c00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/03/30 21:47 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing ed492c95f13a d3999433 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: use-after-free Read in em28xx_v4l2_open
2025/01/04 05:34 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing f1a2241778d9 f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: use-after-free Read in em28xx_v4l2_open
2025/01/01 06:16 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing f097a36ef88d d3ccff63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: use-after-free Read in em28xx_v4l2_open
* Struck through repros no longer work on HEAD.