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: 238d, last: 50d
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:183 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:681 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0xa65/0xb90 kernel/locking/mutex.c:747
Read of size 8 at addr ffff888126845b40 by task v4l_id/28119

CPU: 0 UID: 0 PID: 28119 Comm: v4l_id Not tainted 6.16.0-rc4-syzkaller-00311-gd1b07cc0868f #0 PREEMPT(voluntary) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/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+0xcd/0x680 mm/kasan/report.c:521
 kasan_report+0xe0/0x110 mm/kasan/report.c:634
 __mutex_waiter_is_first kernel/locking/mutex.c:183 [inline]
 __mutex_lock_common kernel/locking/mutex.c:681 [inline]
 __mutex_lock+0xa65/0xb90 kernel/locking/mutex.c:747
 em28xx_v4l2_open+0x22c/0x7e0 drivers/media/usb/em28xx/em28xx-video.c:2150
 v4l2_open+0x225/0x490 drivers/media/v4l2-core/v4l2-dev.c:429
 chrdev_open+0x234/0x6a0 fs/char_dev.c:414
 do_dentry_open+0x6da/0x13a0 fs/open.c:964
 vfs_open+0x82/0x3f0 fs/open.c:1094
 do_open fs/namei.c:3896 [inline]
 path_openat+0x1de4/0x2cb0 fs/namei.c:4055
 do_filp_open+0x20b/0x470 fs/namei.c:4082
 do_sys_openat2+0x11b/0x1d0 fs/open.c:1437
 do_sys_open fs/open.c:1452 [inline]
 __do_sys_openat fs/open.c:1468 [inline]
 __se_sys_openat fs/open.c:1463 [inline]
 __x64_sys_openat+0x174/0x210 fs/open.c:1463
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1be8476407
Code: 48 89 fa 4c 89 df e8 38 aa 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffc58c5b290 EFLAGS: 00000202 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f1be8388880 RCX: 00007f1be8476407
RDX: 0000000000000000 RSI: 00007ffc58c5cf21 RDI: ffffffffffffff9c
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
R13: 00007ffc58c5b4e0 R14: 00007f1be8c0c000 R15: 000056396e9dc4d8
 </TASK>

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888126845ee0 pfn:0x126845
flags: 0x200000000000000(node=0|zone=2)
raw: 0200000000000000 0000000000000000 00000000ffffffff 0000000000000000
raw: ffff888126845ee0 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_ZERO|__GFP_COMP), pid 7646, tgid 7646 (kworker/0:7), ts 2669754993837, free_ts 2672412056868
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1704
 prep_new_page mm/page_alloc.c:1712 [inline]
 get_page_from_freelist+0xf98/0x2ce0 mm/page_alloc.c:3669
 __alloc_frozen_pages_noprof+0x259/0x21e0 mm/page_alloc.c:4959
 __alloc_pages_noprof+0xb/0x1b0 mm/page_alloc.c:4993
 __alloc_pages_node_noprof include/linux/gfp.h:284 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:311 [inline]
 ___kmalloc_large_node+0x84/0x1e0 mm/slub.c:4272
 __kmalloc_large_noprof+0x1c/0x70 mm/slub.c:4290
 kmalloc_noprof include/linux/slab.h:902 [inline]
 kzalloc_noprof include/linux/slab.h:1039 [inline]
 em28xx_usb_probe+0x1dc/0x3770 drivers/media/usb/em28xx/em28xx-cards.c:3908
 usb_probe_interface+0x303/0x9c0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:579 [inline]
 really_probe+0x23e/0xa90 drivers/base/dd.c:657
 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:799
 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:829
 __device_attach_driver+0x1df/0x310 drivers/base/dd.c:957
 bus_for_each_drv+0x156/0x1e0 drivers/base/bus.c:462
 __device_attach+0x1e4/0x4b0 drivers/base/dd.c:1029
 bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
 device_add+0x1148/0x1a70 drivers/base/core.c:3692
page last free pid 7646 tgid 7646 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1248 [inline]
 __free_frozen_pages+0x78a/0x1040 mm/page_alloc.c:2706
 __folio_put+0x1e7/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+0x1dd/0x9a0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:569 [inline]
 device_remove+0x125/0x170 drivers/base/dd.c:561
 __device_release_driver drivers/base/dd.c:1272 [inline]
 device_release_driver_internal+0x44b/0x620 drivers/base/dd.c:1295
 bus_remove_device+0x22f/0x420 drivers/base/bus.c:579
 device_del+0x396/0x9f0 drivers/base/core.c:3881
 usb_disable_device+0x355/0x7d0 drivers/usb/core/message.c:1418
 usb_disconnect+0x2e1/0x9c0 drivers/usb/core/hub.c:2344
 hub_port_connect drivers/usb/core/hub.c:5406 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5706 [inline]
 port_event drivers/usb/core/hub.c:5866 [inline]
 hub_event+0x1aa0/0x5030 drivers/usb/core/hub.c:5948
 process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238
 process_scheduled_works kernel/workqueue.c:3321 [inline]
 worker_thread+0x6c8/0xf10 kernel/workqueue.c:3402
 kthread+0x3c2/0x780 kernel/kthread.c:464
 ret_from_fork+0x5b3/0x6c0 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Memory state around the buggy address:
 ffff888126845a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888126845a80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888126845b00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                           ^
 ffff888126845b80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888126845c00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/08 09:45 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing d1b07cc0868f 4f67c4ae .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: use-after-free Read in em28xx_v4l2_open
2025/06/28 13:58 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing eb90d36bfa06 fc9d8ee5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-usb KASAN: use-after-free Read in em28xx_v4l2_open
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.