syzbot


KASAN: use-after-free Write in usb_anchor_suspend_wakeups

Status: upstream: reported C repro on 2023/05/24 03:23
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+987bb9afc00ca2700db0@syzkaller.appspotmail.com
First crash: 335d, last: 28d
Bug presence (1)
Date Name Commit Repro Result
2023/05/24 upstream (ToT) 9d646009f65d C [report] KASAN: slab-use-after-free Write in usb_anchor_suspend_wakeups
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Write in usb_anchor_suspend_wakeups usb C done unreliable 14 169d 357d 0/26 auto-obsoleted due to no activity on 2024/02/14 08:18
upstream KASAN: slab-use-after-free Write in usb_anchor_suspend_wakeups (2) usb C error 3 19d 21d 0/26 upstream: reported C repro on 2024/04/01 16:50
Fix bisection attempts (8)
Created Duration User Patch Repo Result
2024/03/25 21:36 1h51m bisect fix linux-5.15.y job log (0) log
2024/02/24 17:54 2h47m bisect fix linux-5.15.y job log (0) log
2024/01/17 00:27 2h11m bisect fix linux-5.15.y job log (0) log
2023/12/16 17:25 1h54m bisect fix linux-5.15.y job log (0) log
2023/11/15 15:00 1h43m bisect fix linux-5.15.y job log (0) log
2023/10/13 04:13 2h04m bisect fix linux-5.15.y job log (0) log
2023/09/01 19:40 2h45m bisect fix linux-5.15.y job log (0) log
2023/06/24 21:05 49m bisect fix linux-5.15.y job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_inc include/linux/atomic/atomic-instrumented.h:181 [inline]
BUG: KASAN: use-after-free in usb_anchor_suspend_wakeups+0x24/0x40 drivers/usb/core/urb.c:940
Write of size 4 at addr ffff88807e352910 by task udevd/3540

CPU: 1 PID: 3540 Comm: udevd Not tainted 5.15.112-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_inc include/linux/atomic/atomic-instrumented.h:181 [inline]
 usb_anchor_suspend_wakeups+0x24/0x40 drivers/usb/core/urb.c:940
 __usb_hcd_giveback_urb+0x25d/0x530 drivers/usb/core/hcd.c:1657
 dummy_timer+0x8ad/0x3200 drivers/usb/gadget/udc/dummy_hcd.c:1987
 call_timer_fn+0x16d/0x560 kernel/time/timer.c:1421
 expire_timers kernel/time/timer.c:1466 [inline]
 __run_timers+0x67c/0x890 kernel/time/timer.c:1737
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1750
 __do_softirq+0x3b3/0x93a kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x155/0x240 kernel/softirq.c:636
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x91/0xb0 arch/x86/kernel/apic/apic.c:1096
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:check_kcov_mode kernel/kcov.c:174 [inline]
RIP: 0010:write_comp_data kernel/kcov.c:218 [inline]
RIP: 0010:__sanitizer_cov_trace_switch+0x83/0xe0 kernel/kcov.c:320
Code: 8b 74 d6 10 65 8b 05 24 82 82 7e a9 00 01 ff 00 74 11 a9 00 01 00 00 74 de 41 83 bb 34 16 00 00 00 74 d4 41 8b 83 10 16 00 00 <83> f8 03 75 c8 49 8b 8b 18 16 00 00 45 8b bb 14 16 00 00 49 c1 e7
RSP: 0018:ffffc90002e6f778 EFLAGS: 00000246
RAX: 0000000000000000 RBX: ffffffff8af97042 RCX: 000000000000008b
RDX: 0000000000000000 RSI: ffffffff8cf28b40 RDI: 000000000000000a
RBP: ffffc90002e6f890 R08: 0000000000000001 R09: ffffffff842b13cc
R10: 0000000000000002 R11: ffff888072540000 R12: ffffffff8af97042
R13: 1ffff920005cdf04 R14: 0000000000000000 R15: 000000000000000a
 format_decode+0x22c/0x1f10 lib/vsprintf.c:2540
 vsnprintf+0x14d/0x1c70 lib/vsprintf.c:2758
 vscnprintf+0x29/0x80 lib/vsprintf.c:2909
 sysfs_emit_at+0x126/0x1a0 fs/sysfs/file.c:770
 uevent_show+0x279/0x320 drivers/base/core.c:2399
 dev_attr_show+0x50/0xb0 drivers/base/core.c:2095
 sysfs_kf_seq_show+0x313/0x4e0 fs/sysfs/file.c:61
 seq_read_iter+0x43a/0xd10 fs/seq_file.c:230
 call_read_iter include/linux/fs.h:2097 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xa9f/0xe10 fs/read_write.c:485
 ksys_read+0x1a2/0x2c0 fs/read_write.c:623
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f73d15a9b6a
Code: 00 3d 00 00 41 00 75 0d 50 48 8d 3d 2d 08 0a 00 e8 ea 7d 01 00 31 c0 e9 07 ff ff ff 64 8b 04 25 18 00 00 00 85 c0 75 1b 0f 05 <48> 3d 00 f0 ff ff 76 6c 48 8b 15 8f a2 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffd95faad88 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000055b0fe7814f0 RCX: 00007f73d15a9b6a
RDX: 0000000000001000 RSI: 000055b0fe76a950 RDI: 0000000000000008
RBP: 000055b0fe7814f0 R08: 0000000000000008 R09: 0000000000000200
R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000003fff R14: 00007ffd95fab268 R15: 000000000000000a
 </TASK>

Allocated by task 5408:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 usbtmc_open+0x8f/0x880 drivers/usb/class/usbtmc.c:175
 usb_open+0x21a/0x2f0 drivers/usb/core/file.c:48
 chrdev_open+0x54a/0x630 fs/char_dev.c:414
 do_dentry_open+0x807/0xfb0 fs/open.c:826
 do_open fs/namei.c:3538 [inline]
 path_openat+0x2702/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 5408:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 usbtmc_release+0x24b/0x280 drivers/usb/class/usbtmc.c:261
 __fput+0x3bf/0x890 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:175
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x5d/0x250 kernel/entry/common.c:301
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88807e352800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 272 bytes inside of
 1024-byte region [ffff88807e352800, ffff88807e352c00)
The buggy address belongs to the page:
page:ffffea0001f8d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e350
head:ffffea0001f8d400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888011c41dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3341, ts 34385932326, free_ts 34369924782
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5421
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 load_elf_phdrs fs/binfmt_elf.c:480 [inline]
 load_elf_binary+0x2ec/0x2750 fs/binfmt_elf.c:860
 search_binary_handler fs/exec.c:1734 [inline]
 exec_binprm fs/exec.c:1775 [inline]
 bprm_execve+0x8fd/0x17c0 fs/exec.c:1844
 do_execveat_common+0x583/0x720 fs/exec.c:1949
 do_execve fs/exec.c:2019 [inline]
 __do_sys_execve fs/exec.c:2095 [inline]
 __se_sys_execve fs/exec.c:2090 [inline]
 __x64_sys_execve+0x8e/0xa0 fs/exec.c:2090
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 getname_flags+0xb8/0x4e0 fs/namei.c:138
 do_sys_openat2+0xd2/0x500 fs/open.c:1205
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88807e352800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e352880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e352900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88807e352980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e352a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	8b 74 d6 10          	mov    0x10(%rsi,%rdx,8),%esi
   4:	65 8b 05 24 82 82 7e 	mov    %gs:0x7e828224(%rip),%eax        # 0x7e82822f
   b:	a9 00 01 ff 00       	test   $0xff0100,%eax
  10:	74 11                	je     0x23
  12:	a9 00 01 00 00       	test   $0x100,%eax
  17:	74 de                	je     0xfffffff7
  19:	41 83 bb 34 16 00 00 	cmpl   $0x0,0x1634(%r11)
  20:	00
  21:	74 d4                	je     0xfffffff7
  23:	41 8b 83 10 16 00 00 	mov    0x1610(%r11),%eax
* 2a:	83 f8 03             	cmp    $0x3,%eax <-- trapping instruction
  2d:	75 c8                	jne    0xfffffff7
  2f:	49 8b 8b 18 16 00 00 	mov    0x1618(%r11),%rcx
  36:	45 8b bb 14 16 00 00 	mov    0x1614(%r11),%r15d
  3d:	49                   	rex.WB
  3e:	c1                   	.byte 0xc1
  3f:	e7                   	.byte 0xe7

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/24 03:22 linux-5.15.y 9d6bde853685 4bce1a3e .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Write in usb_anchor_suspend_wakeups
* Struck through repros no longer work on HEAD.