syzbot


KASAN: use-after-free Read in kernfs_get

Status: auto-obsoleted due to no activity on 2024/11/11 11:50
Reported-by: syzbot+fbd24f64111eab50c02a@syzkaller.appspotmail.com
First crash: 146d, last: 100d
Similar bugs (8)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in kernfs_get kernfs 8 861d 983d 0/28 auto-obsoleted due to no activity on 2022/11/11 09:18
android-5-15 KASAN: use-after-free Read in kernfs_get (2) 7 11d 129d 0/2 premoderation: reported on 2024/07/15 05:15
upstream KASAN: use-after-free Read in kernfs_get (2) kernfs 2 643d 730d 0/28 auto-obsoleted due to no activity on 2023/06/16 19:32
android-5-15 KASAN: use-after-free Read in kernfs_get 3 640d 764d 0/2 auto-obsoleted due to no activity on 2023/05/20 22:47
linux-5.15 KASAN: use-after-free Read in kernfs_get 1 98d 98d 0/3 upstream: reported on 2024/08/15 10:42
android-6-1 KASAN: use-after-free Write in kernfs_get 1 2d04h 2d04h 0/2 premoderation: reported on 2024/11/19 13:51
upstream KASAN: slab-use-after-free Read in kernfs_get kernfs 1 279d 279d 0/28 auto-obsoleted due to no activity on 2024/05/26 00:41
android-5-15 KASAN: use-after-free Write in kernfs_get 3 395d 482d 0/2 auto-obsoleted due to no activity on 2024/01/21 14:31

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in kernfs_get+0x21/0x90 fs/kernfs/dir.c:519
Read of size 4 at addr ffff888113de74b0 by task kworker/0:0/6

CPU: 0 PID: 6 Comm: kworker/0:0 Not tainted 6.1.90-syzkaller-00004-g79436849ef1d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: events flush_stashed_error_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
 kernfs_get+0x21/0x90 fs/kernfs/dir.c:519
 sysfs_notify+0x9a/0xd0 fs/sysfs/file.c:187
 ext4_notify_error_sysfs+0x25/0x30 fs/ext4/sysfs.c:518
 flush_stashed_error_work+0x2fe/0x320
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>

Allocated by task 3000:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:608
 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:684
 kernfs_create_dir_ns+0x44/0x130 fs/kernfs/dir.c:1035
 sysfs_create_dir_ns+0x185/0x390 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:63 [inline]
 kobject_add_internal+0x635/0xbf0 lib/kobject.c:231
 kobject_add_varg lib/kobject.c:366 [inline]
 kobject_init_and_add+0x120/0x190 lib/kobject.c:449
 ext4_register_sysfs+0xbf/0x2c0 fs/ext4/sysfs.c:531
 __ext4_fill_super fs/ext4/super.c:5495 [inline]
 ext4_fill_super+0x7930/0x8460 fs/ext4/super.c:5651
 get_tree_bdev+0x440/0x680 fs/super.c:1357
 ext4_get_tree+0x1c/0x20 fs/ext4/super.c:5681
 vfs_get_tree+0x88/0x290 fs/super.c:1564
 do_new_mount+0x2ba/0xb30 fs/namespace.c:3051
 path_mount+0x671/0x1070 fs/namespace.c:3381
 do_mount fs/namespace.c:3394 [inline]
 __do_sys_mount fs/namespace.c:3602 [inline]
 __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3579
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3579
 x64_sys_call+0x49d/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:166
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 292:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 kmem_cache_free+0x291/0x510 mm/slub.c:3706
 kernfs_put+0x392/0x520 fs/kernfs/dir.c:562
 sysfs_put include/linux/sysfs.h:657 [inline]
 __kobject_del+0x10f/0x300 lib/kobject.c:597
 kobject_del+0x45/0x60 lib/kobject.c:619
 ext4_unregister_sysfs+0x91/0xa0 fs/ext4/sysfs.c:565
 ext4_put_super+0x7d/0xd60 fs/ext4/super.c:1215
 generic_shutdown_super+0x14f/0x370 fs/super.c:503
 kill_block_super+0x7e/0xe0 fs/super.c:1461
 deactivate_locked_super+0xad/0x110 fs/super.c:334
 deactivate_super+0xbe/0xf0 fs/super.c:365
 cleanup_mnt+0x485/0x510 fs/namespace.c:1186
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1193
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff888113de74b0
 which belongs to the cache kernfs_node_cache of size 136
The buggy address is located 0 bytes inside of
 136-byte region [ffff888113de74b0, ffff888113de7538)

The buggy address belongs to the physical page:
page:ffffea00044f79c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x113de7
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004d98180 dead00000000000a ffff8881002b2180
raw: 0000000000000000 0000000000140014 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 1836, tgid 1835 (syz.0.313), ts 95686600868, free_ts 95640417471
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x1b9/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:608
 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:684
 kernfs_create_dir_ns+0x44/0x130 fs/kernfs/dir.c:1035
 sysfs_create_dir_ns+0x185/0x390 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:63 [inline]
 kobject_add_internal+0x635/0xbf0 lib/kobject.c:231
 kset_register lib/kobject.c:859 [inline]
 kset_create_and_add+0x214/0x2b0 lib/kobject.c:996
 register_queue_kobjects net/core/net-sysfs.c:1762 [inline]
 netdev_register_kobject+0x1a6/0x320 net/core/net-sysfs.c:2015
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3646
 release_pages+0xf7f/0xfe0 mm/swap.c:1063
 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:315
 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
 tlb_flush_mmu mm/mmu_gather.c:261 [inline]
 tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361
 exit_mmap+0x421/0x940 mm/mmap.c:3348
 __mmput+0x95/0x310 kernel/fork.c:1298
 mmput+0x56/0x170 kernel/fork.c:1321
 exit_mm kernel/exit.c:566 [inline]
 do_exit+0xb29/0x2b80 kernel/exit.c:862
 do_group_exit+0x21a/0x2d0 kernel/exit.c:1025
 get_signal+0x169d/0x1820 kernel/signal.c:2880
 arch_do_signal_or_restart+0xb0/0x16f0 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x74/0xa0 kernel/entry/common.c:174
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87

Memory state around the buggy address:
 ffff888113de7380: fb fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb
 ffff888113de7400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
>ffff888113de7480: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
                                     ^
 ffff888113de7500: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fa
 ffff888113de7580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
general protection fault, probably for non-canonical address 0xe08e5c2d6000002e: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x0473016b00000170-0x0473016b00000177]
CPU: 0 PID: 6 Comm: kworker/0:0 Tainted: G    B              6.1.90-syzkaller-00004-g79436849ef1d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: events flush_stashed_error_work
RIP: 0010:kernfs_root fs/kernfs/kernfs-internal.h:68 [inline]
RIP: 0010:kernfs_find_and_get_ns+0x52/0x110 fs/kernfs/dir.c:895
Code: 08 48 89 f8 48 c1 e8 03 42 80 3c 30 00 74 05 e8 54 01 d4 ff 49 8b 5d 08 48 85 db 49 0f 44 dd 48 83 c3 50 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 2f 01 d4 ff 4c 8b 33 49 83 c6 60
RSP: 0018:ffffc90000067c68 EFLAGS: 00010207
RAX: 008e602d6000002e RBX: 0473016b00000174 RCX: ffffffff81e8bf3c
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff888113de74b8
RBP: ffffc90000067c90 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: ffffffff85b4b860
R13: ffff888113de74b0 R14: dffffc0000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4185ec1d58 CR3: 0000000006e0f000 CR4: 00000000003526b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 kernfs_find_and_get include/linux/kernfs.h:614 [inline]
 sysfs_notify+0x73/0xd0 fs/sysfs/file.c:190
 ext4_notify_error_sysfs+0x25/0x30 fs/ext4/sysfs.c:518
 flush_stashed_error_work+0x2fe/0x320
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:kernfs_root fs/kernfs/kernfs-internal.h:68 [inline]
RIP: 0010:kernfs_find_and_get_ns+0x52/0x110 fs/kernfs/dir.c:895
Code: 08 48 89 f8 48 c1 e8 03 42 80 3c 30 00 74 05 e8 54 01 d4 ff 49 8b 5d 08 48 85 db 49 0f 44 dd 48 83 c3 50 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 2f 01 d4 ff 4c 8b 33 49 83 c6 60
RSP: 0018:ffffc90000067c68 EFLAGS: 00010207
RAX: 008e602d6000002e RBX: 0473016b00000174 RCX: ffffffff81e8bf3c
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff888113de74b8
RBP: ffffc90000067c90 R08: dffffc0000000000 R09: 0000000000000003
R10: ffffffffffffffff R11: dffffc0000000001 R12: ffffffff85b4b860
R13: ffff888113de74b0 R14: dffffc0000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000056289fb2e0c8 CR3: 000000010f9e7000 CR4: 00000000003526b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	08 48 89             	or     %cl,-0x77(%rax)
   3:	f8                   	clc
   4:	48 c1 e8 03          	shr    $0x3,%rax
   8:	42 80 3c 30 00       	cmpb   $0x0,(%rax,%r14,1)
   d:	74 05                	je     0x14
   f:	e8 54 01 d4 ff       	call   0xffd40168
  14:	49 8b 5d 08          	mov    0x8(%r13),%rbx
  18:	48 85 db             	test   %rbx,%rbx
  1b:	49 0f 44 dd          	cmove  %r13,%rbx
  1f:	48 83 c3 50          	add    $0x50,%rbx
  23:	48 89 d8             	mov    %rbx,%rax
  26:	48 c1 e8 03          	shr    $0x3,%rax
* 2a:	42 80 3c 30 00       	cmpb   $0x0,(%rax,%r14,1) <-- trapping instruction
  2f:	74 08                	je     0x39
  31:	48 89 df             	mov    %rbx,%rdi
  34:	e8 2f 01 d4 ff       	call   0xffd40168
  39:	4c 8b 33             	mov    (%rbx),%r14
  3c:	49 83 c6 60          	add    $0x60,%r14

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/13 11:44 android14-6.1 79436849ef1d 7b0f4b46 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in kernfs_get
2024/06/28 18:31 android14-6.1 6aaa06c15d9b 757f06b1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in kernfs_get
* Struck through repros no longer work on HEAD.