syzbot


KASAN: use-after-free Read in i2c_put_adapter
Status: upstream: reported on 2022/03/30 17:43
Reported-by: syzbot+509a39149506f9c2fe34@syzkaller.appspotmail.com
First crash: 60d, last: 19d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in i2c_put_adapter drivers/i2c/i2c-core-base.c:2471 [inline]
BUG: KASAN: use-after-free in i2c_put_adapter+0x4c/0x50 drivers/i2c/i2c-core-base.c:2465
Read of size 8 at addr ffff88804ab45050 by task syz-executor.3/11145

CPU: 1 PID: 11145 Comm: syz-executor.3 Not tainted 5.18.0-rc5-syzkaller-00178-g30c8e80f7932 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 i2c_put_adapter drivers/i2c/i2c-core-base.c:2471 [inline]
 i2c_put_adapter+0x4c/0x50 drivers/i2c/i2c-core-base.c:2465
 i2cdev_release+0x55/0xb0 drivers/i2c/i2c-dev.c:619
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
 exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:294
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7ff7c023bd2b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ff7c08cfb80 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 000000000000000c RCX: 00007ff7c023bd2b
RDX: 0000001b2d120000 RSI: 00007ff7c0200000 RDI: 000000000000000b
RBP: 00007ff7c039d960 R08: 0000000000000000 R09: 00000000327e0c1d
R10: 00007ffcc471b090 R11: 0000000000000293 R12: 00000000000606a5
R13: 00007ff7c08cfc80 R14: 00007ff7c08cfca0 R15: 0000000000000032
 </TASK>

The buggy address belongs to the physical page:
page:ffffea00012ad140 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ab45
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 ffffffff00000201 0000000000000000
raw: 0000000000000000 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 0x140dc0(GFP_USER|__GFP_COMP|__GFP_ZERO), pid 3664, tgid 3664 (kworker/1:7), ts 393341970647, free_ts 395030722929
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 kmalloc_order+0x34/0xf0 mm/slab_common.c:953
 kmalloc_order_trace+0x14/0x120 mm/slab_common.c:969
 kmalloc_large include/linux/slab.h:510 [inline]
 kmalloc include/linux/slab.h:574 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 dvb_usb_device_init+0x113/0x640 drivers/media/usb/dvb-usb/dvb-usb-init.c:279
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:542 [inline]
 really_probe+0x23e/0xb20 drivers/base/dd.c:621
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:752
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:782
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:899
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:970
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xb83/0x1e20 drivers/base/core.c:3405
 usb_set_configuration+0x101e/0x1900 drivers/usb/core/message.c:2170
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1356 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1406
 free_unref_page_prepare mm/page_alloc.c:3328 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3423
 dvb_usb_exit drivers/media/usb/dvb-usb/dvb-usb-init.c:150 [inline]
 dvb_usb_device_exit+0x396/0x510 drivers/media/usb/dvb-usb/dvb-usb-init.c:336
 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458
 device_remove drivers/base/dd.c:532 [inline]
 device_remove+0x11f/0x170 drivers/base/dd.c:524
 __device_release_driver drivers/base/dd.c:1200 [inline]
 device_release_driver_internal+0x4a3/0x680 drivers/base/dd.c:1223
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x4f3/0xc80 drivers/base/core.c:3592
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x278/0x6ec drivers/usb/core/hub.c:2228
 hub_port_connect drivers/usb/core/hub.c:5207 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5507 [inline]
 port_event drivers/usb/core/hub.c:5665 [inline]
 hub_event+0x1e74/0x4680 drivers/usb/core/hub.c:5747
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 process_scheduled_works kernel/workqueue.c:2352 [inline]
 worker_thread+0x854/0x1080 kernel/workqueue.c:2438
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Memory state around the buggy address:
 ffff88804ab44f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88804ab44f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88804ab45000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                 ^
 ffff88804ab45080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88804ab45100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/05/08 13:28 upstream 30c8e80f7932 e60b1103 .config log report info KASAN: use-after-free Read in i2c_put_adapter
ci-upstream-kasan-gce 2022/05/05 06:49 upstream a7391ad35724 dc9e5259 .config log report info KASAN: use-after-free Read in i2c_put_adapter
ci-upstream-kasan-gce-root 2022/03/27 19:56 upstream f022814633e1 89bc8608 .config log report info KASAN: use-after-free Read in i2c_put_adapter
ci-upstream-linux-next-kasan-gce-root 2022/04/16 21:42 linux-next 40354149f4d7 8bcc32a6 .config log report info KASAN: use-after-free Read in i2c_put_adapter