syzbot


KASAN: use-after-free Write in chroot_fs_refs

Status: closed as invalid on 2022/03/01 11:11
Reported-by: syzbot+d7375b91594353bfd054@syzkaller.appspotmail.com
First crash: 1045d, last: 1038d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in chroot_fs_refs 1 1013d 1013d 0/2 auto-closed as invalid on 2022/03/29 13:53

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_try_cmpxchg_acquire include/asm-generic/atomic-instrumented.h:705 [inline]
BUG: KASAN: use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:82 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock include/linux/spinlock.h:183 [inline]
BUG: KASAN: use-after-free in __raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
BUG: KASAN: use-after-free in _raw_spin_lock+0x96/0x1b0 kernel/locking/spinlock.c:151
Write of size 4 at addr ffff888156d15004 by task syz-executor.5/15978

CPU: 1 PID: 15978 Comm: syz-executor.5 Not tainted 5.10.76-syzkaller-01178-g4944ec82ebb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:135 [inline]
 kasan_check_range+0x2b6/0x2f0 mm/kasan/generic.c:186
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_try_cmpxchg_acquire include/asm-generic/atomic-instrumented.h:705 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:82 [inline]
 do_raw_spin_lock include/linux/spinlock.h:183 [inline]
 __raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
 _raw_spin_lock+0x96/0x1b0 kernel/locking/spinlock.c:151
 spin_lock include/linux/spinlock.h:354 [inline]
 chroot_fs_refs+0xe8/0x4b0 fs/fs_struct.c:70
 __do_sys_pivot_root fs/namespace.c:3792 [inline]
 __se_sys_pivot_root+0x1e6d/0x1f90 fs/namespace.c:3709
 __x64_sys_pivot_root+0x5b/0x70 fs/namespace.c:3709
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fe03fa58ae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe03d7cf188 EFLAGS: 00000246 ORIG_RAX: 000000000000009b
RAX: ffffffffffffffda RBX: 00007fe03fb6bf60 RCX: 00007fe03fa58ae9
RDX: 0000000000000000 RSI: 00000000200004c0 RDI: 0000000020000340
RBP: 00007fe03fab2f25 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc5bdd7d2f R14: 00007fe03d7cf300 R15: 0000000000022000

Allocated by task 382:
 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:428 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2948 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2961
 copy_fs_struct+0x4e/0x230 fs/fs_struct.c:114
 copy_fs kernel/fork.c:1489 [inline]
 copy_process+0x13bc/0x5330 kernel/fork.c:2137
 kernel_clone+0x21f/0x9a0 kernel/fork.c:2507
 __do_sys_clone kernel/fork.c:2626 [inline]
 __se_sys_clone kernel/fork.c:2610 [inline]
 __x64_sys_clone+0x258/0x2d0 kernel/fork.c:2610
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888156d15000
 which belongs to the cache fs_cache of size 56
The buggy address is located 4 bytes inside of
 56-byte region [ffff888156d15000, ffff888156d15038)
The buggy address belongs to the page:
page:ffffea00055b4540 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888156d15c80 pfn:0x156d15
flags: 0x8000000000000200(slab)
raw: 8000000000000200 ffffea00045a1b40 0000000600000006 ffff888100066480
raw: ffff888156d15c80 0000000080200000 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 383, ts 260627176068, free_ts 260619141589
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1807 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1809
 new_slab mm/slub.c:1870 [inline]
 new_slab_objects mm/slub.c:2629 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2792
 __slab_alloc mm/slub.c:2832 [inline]
 slab_alloc_node mm/slub.c:2914 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc+0x26f/0x380 mm/slub.c:2961
 copy_fs_struct+0x4e/0x230 fs/fs_struct.c:114
 copy_fs kernel/fork.c:1489 [inline]
 copy_process+0x13bc/0x5330 kernel/fork.c:2137
 kernel_clone+0x21f/0x9a0 kernel/fork.c:2507
 __do_sys_clone kernel/fork.c:2626 [inline]
 __se_sys_clone kernel/fork.c:2610 [inline]
 __x64_sys_clone+0x258/0x2d0 kernel/fork.c:2610
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 free_pcp_prepare+0x18f/0x1c0 mm/page_alloc.c:1405
 free_unref_page_prepare mm/page_alloc.c:3291 [inline]
 free_unref_page mm/page_alloc.c:3341 [inline]
 free_the_page mm/page_alloc.c:5165 [inline]
 __free_pages+0x2e3/0x4a0 mm/page_alloc.c:5173
 __free_slab+0xdf/0x1a0 mm/slub.c:1895
 free_slab mm/slub.c:1910 [inline]
 discard_slab mm/slub.c:1916 [inline]
 __slab_free+0x458/0x4e0 mm/slub.c:3132
 do_slab_free mm/slub.c:3192 [inline]
 ___cache_free+0x131/0x150 mm/slub.c:3211
 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146
 qlist_free_all mm/kasan/quarantine.c:165 [inline]
 kasan_quarantine_reduce+0x178/0x1d0 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2948 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc_trace+0x1a5/0x3a0 mm/slub.c:2973
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 kernfs_iop_get_link+0x65/0x5c0 fs/kernfs/symlink.c:135
 vfs_readlink+0x17b/0x420 fs/namei.c:4627
 do_readlinkat+0x28f/0x3b0 fs/stat.c:427
 __do_sys_readlink fs/stat.c:448 [inline]
 __se_sys_readlink fs/stat.c:445 [inline]
 __x64_sys_readlink+0x7f/0x90 fs/stat.c:445
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff888156d14f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888156d14f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888156d15000: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
                   ^
 ffff888156d15080: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
 ffff888156d15100: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
==================================================================
================================================================================
UBSAN: array-index-out-of-bounds in kernel/locking/qspinlock.c:130:9
index 16382 is out of range for type 'unsigned long [8]'
CPU: 1 PID: 15978 Comm: syz-executor.5 Tainted: G    B             5.10.76-syzkaller-01178-g4944ec82ebb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 dump_stack+0x15/0x1d lib/dump_stack.c:135
 ubsan_epilogue lib/ubsan.c:148 [inline]
 __ubsan_handle_out_of_bounds+0x107/0x160 lib/ubsan.c:356
 decode_tail kernel/locking/qspinlock.c:130 [inline]
 __pv_queued_spin_lock_slowpath+0xc9b/0xcf0 kernel/locking/qspinlock.c:468
 pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:554 [inline]
 queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:85 [inline]
 do_raw_spin_lock include/linux/spinlock.h:183 [inline]
 __raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
 _raw_spin_lock+0x136/0x1b0 kernel/locking/spinlock.c:151
 spin_lock include/linux/spinlock.h:354 [inline]
 chroot_fs_refs+0xe8/0x4b0 fs/fs_struct.c:70
 __do_sys_pivot_root fs/namespace.c:3792 [inline]
 __se_sys_pivot_root+0x1e6d/0x1f90 fs/namespace.c:3709
 __x64_sys_pivot_root+0x5b/0x70 fs/namespace.c:3709
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fe03fa58ae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe03d7cf188 EFLAGS: 00000246 ORIG_RAX: 000000000000009b
RAX: ffffffffffffffda RBX: 00007fe03fb6bf60 RCX: 00007fe03fa58ae9
RDX: 0000000000000000 RSI: 00000000200004c0 RDI: 0000000020000340
RBP: 00007fe03fab2f25 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc5bdd7d2f R14: 00007fe03d7cf300 R15: 0000000000022000
================================================================================
general protection fault, probably for non-canonical address 0xe01c72659fd7e3ba: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x00e3b32cfebf1dd0-0x00e3b32cfebf1dd7]
CPU: 1 PID: 15978 Comm: syz-executor.5 Tainted: G    B             5.10.76-syzkaller-01178-g4944ec82ebb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__pv_queued_spin_lock_slowpath+0x2e4/0xcf0 kernel/locking/qspinlock.c:471
Code: 00 00 00 00 fc ff df 80 3c 08 00 74 08 4c 89 ef e8 71 ba 53 00 49 03 5d 00 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 4c 8b 6c 24 20 74 08 48 89 df e8 e9 ba 53 00 4c 89 2b
RSP: 0018:ffffc9000200fac0 EFLAGS: 00010202
RAX: 001c76659fd7e3ba RBX: 00e3b32cfebf1dd1 RCX: dffffc0000000000
RDX: ffffc90004736000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: ffffc9000200fbb0 R08: ffffffff82714cec R09: fffff52000401e79
R10: fffff52000401e79 R11: 0000000000000000 R12: ffff888156d15004
R13: ffffffff85d70670 R14: 1ffff1103ee29e11 R15: 1ffff1102ada2a00
FS:  00007fe03d7cf700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000164d1d000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:554 [inline]
 queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:85 [inline]
 do_raw_spin_lock include/linux/spinlock.h:183 [inline]
 __raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
 _raw_spin_lock+0x136/0x1b0 kernel/locking/spinlock.c:151
 spin_lock include/linux/spinlock.h:354 [inline]
 chroot_fs_refs+0xe8/0x4b0 fs/fs_struct.c:70
 __do_sys_pivot_root fs/namespace.c:3792 [inline]
 __se_sys_pivot_root+0x1e6d/0x1f90 fs/namespace.c:3709
 __x64_sys_pivot_root+0x5b/0x70 fs/namespace.c:3709
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fe03fa58ae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe03d7cf188 EFLAGS: 00000246 ORIG_RAX: 000000000000009b
RAX: ffffffffffffffda RBX: 00007fe03fb6bf60 RCX: 00007fe03fa58ae9
RDX: 0000000000000000 RSI: 00000000200004c0 RDI: 0000000020000340
RBP: 00007fe03fab2f25 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc5bdd7d2f R14: 00007fe03d7cf300 R15: 0000000000022000
Modules linked in:
---[ end trace 7ab40b37aa8211aa ]---
RIP: 0010:__pv_queued_spin_lock_slowpath+0x2e4/0xcf0 kernel/locking/qspinlock.c:471
Code: 00 00 00 00 fc ff df 80 3c 08 00 74 08 4c 89 ef e8 71 ba 53 00 49 03 5d 00 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 4c 8b 6c 24 20 74 08 48 89 df e8 e9 ba 53 00 4c 89 2b
RSP: 0018:ffffc9000200fac0 EFLAGS: 00010202
RAX: 001c76659fd7e3ba RBX: 00e3b32cfebf1dd1 RCX: dffffc0000000000
RDX: ffffc90004736000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: ffffc9000200fbb0 R08: ffffffff82714cec R09: fffff52000401e79
R10: fffff52000401e79 R11: 0000000000000000 R12: ffff888156d15004
R13: ffffffff85d70670 R14: 1ffff1103ee29e11 R15: 1ffff1102ada2a00
FS:  00007fe03d7cf700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000164d1d000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 6 bytes skipped:
   0:	df 80 3c 08 00 74    	filds  0x7400083c(%rax)
   6:	08 4c 89 ef          	or     %cl,-0x11(%rcx,%rcx,4)
   a:	e8 71 ba 53 00       	callq  0x53ba80
   f:	49 03 5d 00          	add    0x0(%r13),%rbx
  13:	48 89 d8             	mov    %rbx,%rax
  16:	48 c1 e8 03          	shr    $0x3,%rax
  1a:	48 b9 00 00 00 00 00 	movabs $0xdffffc0000000000,%rcx
  21:	fc ff df
* 24:	80 3c 08 00          	cmpb   $0x0,(%rax,%rcx,1) <-- trapping instruction
  28:	4c 8b 6c 24 20       	mov    0x20(%rsp),%r13
  2d:	74 08                	je     0x37
  2f:	48 89 df             	mov    %rbx,%rdi
  32:	e8 e9 ba 53 00       	callq  0x53bb20
  37:	4c 89 2b             	mov    %r13,(%rbx)

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/04 03:54 android12-5.10-lts 4944ec82ebb9 4c1be0be .config console log report info ci2-android-5-10 KASAN: use-after-free Write in chroot_fs_refs
2021/10/28 06:12 android12-5.10-lts 4944ec82ebb9 be531bb4 .config console log report info ci2-android-5-10 KASAN: use-after-free Write in chroot_fs_refs
* Struck through repros no longer work on HEAD.