KASAN: use-after-free Write in chroot_fs_refs

19 views
Skip to first unread message

syzbot

unread,
Nov 29, 2021, 8:53:28 AM11/29/21
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 0bbc71d87f4d ANDROID: usb: gadget: f_accessory: Mitgate ha..
git tree: android12-5.4
console output: https://syzkaller.appspot.com/x/log.txt?x=11cad381b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=8844969a6709ae53
dashboard link: https://syzkaller.appspot.com/bug?extid=c3df6147d464ff4c7652
compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c3df61...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in atomic_try_cmpxchg include/asm-generic/atomic-instrumented.h:693 [inline]
BUG: KASAN: use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:78 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock include/linux/spinlock.h:181 [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+0x5f/0x170 kernel/locking/spinlock.c:151
Write of size 4 at addr ffff8881e6e61584 by task syz-executor.3/15978

CPU: 0 PID: 15978 Comm: syz-executor.3 Not tainted 5.4.147-syzkaller-00011-g0bbc71d87f4d #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+0x18e/0x1de lib/dump_stack.c:118
print_address_description+0x9b/0x650 mm/kasan/report.c:384
__kasan_report+0x182/0x260 mm/kasan/report.c:516
kasan_report+0x30/0x60 mm/kasan/common.c:653
check_memory_region_inline mm/kasan/generic.c:141 [inline]
check_memory_region+0x2a5/0x2e0 mm/kasan/generic.c:191
atomic_try_cmpxchg include/asm-generic/atomic-instrumented.h:693 [inline]
queued_spin_lock include/asm-generic/qspinlock.h:78 [inline]
do_raw_spin_lock include/linux/spinlock.h:181 [inline]
__raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
_raw_spin_lock+0x5f/0x170 kernel/locking/spinlock.c:151
spin_lock include/linux/spinlock.h:338 [inline]
chroot_fs_refs+0xe9/0x4b0 fs/fs_struct.c:70
__do_sys_pivot_root fs/namespace.c:3720 [inline]
__se_sys_pivot_root+0x1d64/0x1e90 fs/namespace.c:3637
do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f1ba0808ae9
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:00007f1b9e55e188 EFLAGS: 00000246 ORIG_RAX: 000000000000009b
RAX: ffffffffffffffda RBX: 00007f1ba091c020 RCX: 00007f1ba0808ae9
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 00000000200000c0
RBP: 00007f1ba0862f6d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd742a158f R14: 00007f1b9e55e300 R15: 0000000000022000

Allocated by task 14122:
save_stack mm/kasan/common.c:70 [inline]
set_track mm/kasan/common.c:78 [inline]
__kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529
slab_post_alloc_hook mm/slab.h:584 [inline]
slab_alloc_node mm/slub.c:2822 [inline]
slab_alloc mm/slub.c:2830 [inline]
kmem_cache_alloc+0x115/0x290 mm/slub.c:2835
copy_fs_struct+0x48/0x220 fs/fs_struct.c:114
copy_fs kernel/fork.c:1450 [inline]
copy_process+0x1532/0x52c0 kernel/fork.c:2031
_do_fork+0x145/0x840 kernel/fork.c:2391
__do_sys_clone kernel/fork.c:2549 [inline]
__se_sys_clone kernel/fork.c:2530 [inline]
__x64_sys_clone+0x20d/0x250 kernel/fork.c:2530
do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 7:
save_stack mm/kasan/common.c:70 [inline]
set_track mm/kasan/common.c:78 [inline]
kasan_set_free_info mm/kasan/common.c:345 [inline]
__kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487
slab_free_hook mm/slub.c:1455 [inline]
slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1493
slab_free mm/slub.c:3073 [inline]
kmem_cache_free+0xb8/0x5f0 mm/slub.c:3089
io_send_recvmsg fs/io_uring.c:1712 [inline]
io_recvmsg fs/io_uring.c:1734 [inline]
__io_submit_sqe+0x109c/0x3980 fs/io_uring.c:2155
io_sq_wq_submit_work+0x6a0/0x1290 fs/io_uring.c:2268
process_one_work+0x679/0x1030 kernel/workqueue.c:2278
worker_thread+0xa6f/0x1400 kernel/workqueue.c:2424
kthread+0x30f/0x330 kernel/kthread.c:288
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881e6e61580
which belongs to the cache fs_cache of size 56
The buggy address is located 4 bytes inside of
56-byte region [ffff8881e6e61580, ffff8881e6e615b8)
The buggy address belongs to the page:
page:ffffea00079b9840 refcount:1 mapcount:0 mapping:ffff8881f5cf8f00 index:0x0
flags: 0x8000000000000200(slab)
raw: 8000000000000200 ffffea0007d73240 0000000900000009 ffff8881f5cf8f00
raw: 0000000000000000 0000000080200020 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)
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook mm/page_alloc.c:2165 [inline]
prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
__alloc_pages_nodemask+0x2d6/0x740 mm/page_alloc.c:4855
alloc_slab_page+0x39/0x3e0 mm/slub.c:343
allocate_slab mm/slub.c:1676 [inline]
new_slab+0x97/0x460 mm/slub.c:1742
new_slab_objects mm/slub.c:2499 [inline]
___slab_alloc+0x330/0x4c0 mm/slub.c:2660
__slab_alloc mm/slub.c:2700 [inline]
slab_alloc_node mm/slub.c:2785 [inline]
slab_alloc mm/slub.c:2830 [inline]
kmem_cache_alloc+0x18b/0x290 mm/slub.c:2835
copy_fs_struct+0x48/0x220 fs/fs_struct.c:114
copy_fs kernel/fork.c:1450 [inline]
copy_process+0x1532/0x52c0 kernel/fork.c:2031
_do_fork+0x145/0x840 kernel/fork.c:2391
__do_sys_clone kernel/fork.c:2549 [inline]
__se_sys_clone kernel/fork.c:2530 [inline]
__x64_sys_clone+0x20d/0x250 kernel/fork.c:2530
do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1176 [inline]
free_pcp_prepare+0x1a9/0x270 mm/page_alloc.c:1233
free_unref_page_prepare mm/page_alloc.c:3085 [inline]
free_unref_page mm/page_alloc.c:3134 [inline]
free_the_page mm/page_alloc.c:4915 [inline]
__free_pages+0x54/0x1e0 mm/page_alloc.c:4923
__vunmap+0x7b6/0x8f0 mm/vmalloc.c:2260
__do_replace+0x796/0x9b0 net/ipv6/netfilter/ip6_tables.c:1105
do_replace net/ipv6/netfilter/ip6_tables.c:1157 [inline]
do_ip6t_set_ctl+0x32f/0x4e0 net/ipv6/netfilter/ip6_tables.c:1683
nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
nf_setsockopt+0x2ad/0x2d0 net/netfilter/nf_sockopt.c:115
__sys_setsockopt+0x471/0x700 net/socket.c:2074
__do_sys_setsockopt net/socket.c:2090 [inline]
__se_sys_setsockopt net/socket.c:2087 [inline]
__x64_sys_setsockopt+0xb1/0xc0 net/socket.c:2087
do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
ffff8881e6e61480: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
ffff8881e6e61500: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
>ffff8881e6e61580: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
^
ffff8881e6e61600: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
ffff8881e6e61680: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
==================================================================
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 15978 Comm: syz-executor.3 Tainted: G B 5.4.147-syzkaller-00011-g0bbc71d87f4d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__write_once_size include/linux/compiler.h:293 [inline]
RIP: 0010:__pv_queued_spin_lock_slowpath+0x275/0xbf0 kernel/locking/qspinlock.c:470
Code: 85 4c 89 f0 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df 80 3c 18 00 74 08 4c 89 f7 e8 75 f1 43 00 49 03 2e 48 89 e8 48 c1 e8 03 <80> 3c 18 00 74 08 48 89 ef e8 dd f1 43 00 48 8b 44 24 20 48 89 45
RSP: 0018:ffff8881a53dfc08 EFLAGS: 00010202
RAX: 0cac4bef0e4c8a38 RBX: dffffc0000000000 RCX: 0000000000003fff
RDX: 0000000000000001 RSI: 0000000000000002 RDI: ffff8881e6e61586
RBP: 65625f78726451c3 R08: dffffc0000000000 R09: 0000000000000007
R10: ffffed103cdcc2b1 R11: 00000000000000fb R12: ffff8881e6e61584
R13: 1ffff1103cdcc2b0 R14: ffffffff8559eef0 R15: 1ffff1103edc9d21
FS: 00007f1b9e55e700(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000040 CR3: 00000001abebe000 CR4: 00000000003406f0
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:642 [inline]
queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:50 [inline]
queued_spin_lock include/asm-generic/qspinlock.h:81 [inline]
do_raw_spin_lock include/linux/spinlock.h:181 [inline]
__raw_spin_lock include/linux/spinlock_api_smp.h:143 [inline]
_raw_spin_lock+0xf3/0x170 kernel/locking/spinlock.c:151
spin_lock include/linux/spinlock.h:338 [inline]
chroot_fs_refs+0xe9/0x4b0 fs/fs_struct.c:70
__do_sys_pivot_root fs/namespace.c:3720 [inline]
__se_sys_pivot_root+0x1d64/0x1e90 fs/namespace.c:3637
do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f1ba0808ae9
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:00007f1b9e55e188 EFLAGS: 00000246 ORIG_RAX: 000000000000009b
RAX: ffffffffffffffda RBX: 00007f1ba091c020 RCX: 00007f1ba0808ae9
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 00000000200000c0
RBP: 00007f1ba0862f6d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd742a158f R14: 00007f1b9e55e300 R15: 0000000000022000
Modules linked in:
---[ end trace 81b8eb65b6fea7ea ]---
RIP: 0010:__write_once_size include/linux/compiler.h:293 [inline]
RIP: 0010:__pv_queued_spin_lock_slowpath+0x275/0xbf0 kernel/locking/qspinlock.c:470
Code: 85 4c 89 f0 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df 80 3c 18 00 74 08 4c 89 f7 e8 75 f1 43 00 49 03 2e 48 89 e8 48 c1 e8 03 <80> 3c 18 00 74 08 48 89 ef e8 dd f1 43 00 48 8b 44 24 20 48 89 45
RSP: 0018:ffff8881a53dfc08 EFLAGS: 00010202
RAX: 0cac4bef0e4c8a38 RBX: dffffc0000000000 RCX: 0000000000003fff
RDX: 0000000000000001 RSI: 0000000000000002 RDI: ffff8881e6e61586
RBP: 65625f78726451c3 R08: dffffc0000000000 R09: 0000000000000007
R10: ffffed103cdcc2b1 R11: 00000000000000fb R12: ffff8881e6e61584
R13: 1ffff1103cdcc2b0 R14: ffffffff8559eef0 R15: 1ffff1103edc9d21
FS: 00007f1b9e55e700(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000040 CR3: 00000001abebe000 CR4: 00000000003406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 85 4c 89 f0 test %ecx,-0x10(%rcx,%rcx,4)
4: 48 c1 e8 03 shr $0x3,%rax
8: 48 bb 00 00 00 00 00 movabs $0xdffffc0000000000,%rbx
f: fc ff df
12: 80 3c 18 00 cmpb $0x0,(%rax,%rbx,1)
16: 74 08 je 0x20
18: 4c 89 f7 mov %r14,%rdi
1b: e8 75 f1 43 00 callq 0x43f195
20: 49 03 2e add (%r14),%rbp
23: 48 89 e8 mov %rbp,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 80 3c 18 00 cmpb $0x0,(%rax,%rbx,1) <-- trapping instruction
2e: 74 08 je 0x38
30: 48 89 ef mov %rbp,%rdi
33: e8 dd f1 43 00 callq 0x43f215
38: 48 8b 44 24 20 mov 0x20(%rsp),%rax
3d: 48 rex.W
3e: 89 .byte 0x89
3f: 45 rex.RB


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Mar 29, 2022, 9:53:24 AM3/29/22
to syzkaller-a...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages