[moderation] [fs?] KASAN: slab-use-after-free Read in lockref_get_not_dead

0 views
Skip to first unread message

syzbot

unread,
Mar 19, 2024, 1:42:25 AMMar 19
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16053481180000
kernel config: https://syzkaller.appspot.com/x/.config?x=aef2a55903e5791c
dashboard link: https://syzkaller.appspot.com/bug?extid=cbe4b96e1194b0e34db6
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
CC: [linux-...@vger.kernel.org linux-...@vger.kernel.org]

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/089e25869df5/disk-fe46a7dd.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/423b1787914f/vmlinux-fe46a7dd.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4c043e30c07d/bzImage-fe46a7dd.xz

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

==================================================================
BUG: KASAN: slab-use-after-free in __lock_acquire+0x2dd6/0x3b30 kernel/locking/lockdep.c:5005
Read of size 8 at addr ffff888042f3d250 by task syz-executor.4/19792

CPU: 1 PID: 19792 Comm: syz-executor.4 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114
print_address_description mm/kasan/report.c:377 [inline]
print_report+0xc3/0x620 mm/kasan/report.c:488
kasan_report+0xd9/0x110 mm/kasan/report.c:601
__lock_acquire+0x2dd6/0x3b30 kernel/locking/lockdep.c:5005
lock_acquire kernel/locking/lockdep.c:5754 [inline]
lock_acquire+0x1b1/0x540 kernel/locking/lockdep.c:5719
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:351 [inline]
lockref_get_not_dead+0x18/0x80 lib/lockref.c:184
get_stashed_dentry fs/libfs.c:1998 [inline]
path_from_stashed+0x160/0xe00 fs/libfs.c:2092
ns_get_path_cb fs/nsfs.c:59 [inline]
ns_get_path+0x5f/0x80 fs/nsfs.c:82
proc_ns_get_link+0x122/0x270 fs/proc/namespaces.c:61
pick_link fs/namei.c:1808 [inline]
step_into+0x1aed/0x2230 fs/namei.c:1874
open_last_lookups fs/namei.c:3589 [inline]
path_openat+0x448/0x2990 fs/namei.c:3796
do_filp_open+0x1dc/0x430 fs/namei.c:3826
do_sys_openat2+0x17a/0x1e0 fs/open.c:1406
do_sys_open fs/open.c:1421 [inline]
__do_sys_openat fs/open.c:1437 [inline]
__se_sys_openat fs/open.c:1432 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1432
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7fdcad87c9a0
Code: 48 89 44 24 20 75 93 44 89 54 24 0c e8 09 82 02 00 44 8b 54 24 0c 89 da 48 89 ee 41 89 c0 bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 77 38 44 89 c7 89 44 24 0c e8 5c 82 02 00 8b 44
RSP: 002b:00007fdcae698ff0 EFLAGS: 00000293 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fdcad87c9a0
RDX: 0000000000000000 RSI: 00007fdcad8c9265 RDI: 00000000ffffff9c
RBP: 00007fdcad8c9265 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000000
R13: 000000000000000b R14: 00007fdcad9ac050 R15: 00007ffc40f09798
</TASK>

Allocated by task 19791:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:312 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:338
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook mm/slub.c:3798 [inline]
slab_alloc_node mm/slub.c:3845 [inline]
kmem_cache_alloc_lru+0x142/0x6f0 mm/slub.c:3864
__d_alloc+0x31/0xaa0 fs/dcache.c:1624
prepare_anon_dentry fs/libfs.c:2032 [inline]
path_from_stashed+0x6eb/0xe00 fs/libfs.c:2099
ns_get_path_cb fs/nsfs.c:59 [inline]
ns_get_path+0x5f/0x80 fs/nsfs.c:82
proc_ns_get_link+0x122/0x270 fs/proc/namespaces.c:61
pick_link fs/namei.c:1808 [inline]
step_into+0x1aed/0x2230 fs/namei.c:1874
open_last_lookups fs/namei.c:3589 [inline]
path_openat+0x448/0x2990 fs/namei.c:3796
do_filp_open+0x1dc/0x430 fs/namei.c:3826
do_sys_openat2+0x17a/0x1e0 fs/open.c:1406
do_sys_open fs/open.c:1421 [inline]
__do_sys_openat fs/open.c:1437 [inline]
__se_sys_openat fs/open.c:1432 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1432
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6d/0x75

Freed by task 18096:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
poison_slab_object mm/kasan/common.c:240 [inline]
__kasan_slab_free+0x11d/0x1a0 mm/kasan/common.c:256
kasan_slab_free include/linux/kasan.h:184 [inline]
slab_free_hook mm/slub.c:2106 [inline]
slab_free mm/slub.c:4280 [inline]
kmem_cache_free+0x12e/0x360 mm/slub.c:4344
rcu_do_batch kernel/rcu/tree.c:2196 [inline]
rcu_core+0x828/0x16b0 kernel/rcu/tree.c:2471
__do_softirq+0x218/0x8de kernel/softirq.c:554

Last potentially related work creation:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
__kasan_record_aux_stack+0xba/0xd0 mm/kasan/generic.c:541
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2734
dentry_free+0xc2/0x160 fs/dcache.c:376
__dentry_kill+0x498/0x600 fs/dcache.c:622
dput.part.0+0x4b1/0x9b0 fs/dcache.c:845
dput+0x1f/0x30 fs/dcache.c:835
__fput+0x3bc/0xb80 fs/file_table.c:430
__fput_sync+0x47/0x50 fs/file_table.c:507
__do_sys_close fs/open.c:1556 [inline]
__se_sys_close fs/open.c:1541 [inline]
__x64_sys_close+0x86/0x100 fs/open.c:1541
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6d/0x75

The buggy address belongs to the object at ffff888042f3d1a0
which belongs to the cache dentry of size 312
The buggy address is located 176 bytes inside of
freed 312-byte region [ffff888042f3d1a0, ffff888042f3d2d8)

The buggy address belongs to the physical page:
page:ffffea00010bcf00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x42f3c
head:ffffea00010bcf00 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888066791e01
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888015ef03c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000150015 00000001ffffffff ffff888066791e01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Reclaimable, gfp_mask 0x1d20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 19791, tgid 19790 (syz-executor.4), ts 1264577584789, free_ts 1160902656352
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533
prep_new_page mm/page_alloc.c:1540 [inline]
get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311
__alloc_pages+0x22b/0x2410 mm/page_alloc.c:4569
__alloc_pages_node include/linux/gfp.h:238 [inline]
alloc_pages_node include/linux/gfp.h:261 [inline]
alloc_slab_page mm/slub.c:2175 [inline]
allocate_slab mm/slub.c:2338 [inline]
new_slab+0xcc/0x3a0 mm/slub.c:2391
___slab_alloc+0x66d/0x1790 mm/slub.c:3525
__slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3610
__slab_alloc_node mm/slub.c:3663 [inline]
slab_alloc_node mm/slub.c:3835 [inline]
kmem_cache_alloc_lru+0x379/0x6f0 mm/slub.c:3864
__d_alloc+0x31/0xaa0 fs/dcache.c:1624
prepare_anon_dentry fs/libfs.c:2032 [inline]
path_from_stashed+0x6eb/0xe00 fs/libfs.c:2099
ns_get_path_cb fs/nsfs.c:59 [inline]
ns_get_path+0x5f/0x80 fs/nsfs.c:82
proc_ns_get_link+0x122/0x270 fs/proc/namespaces.c:61
pick_link fs/namei.c:1808 [inline]
step_into+0x1aed/0x2230 fs/namei.c:1874
open_last_lookups fs/namei.c:3589 [inline]
path_openat+0x448/0x2990 fs/namei.c:3796
do_filp_open+0x1dc/0x430 fs/namei.c:3826
do_sys_openat2+0x17a/0x1e0 fs/open.c:1406
do_sys_open fs/open.c:1421 [inline]
__do_sys_openat fs/open.c:1437 [inline]
__se_sys_openat fs/open.c:1432 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1432
page last free pid 14503 tgid 14503 stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1140 [inline]
free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2346
free_unref_page+0x33/0x3c0 mm/page_alloc.c:2486
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook mm/slub.c:3798 [inline]
slab_alloc_node mm/slub.c:3845 [inline]
kmem_cache_alloc+0x136/0x320 mm/slub.c:3852
mt_alloc_one lib/maple_tree.c:162 [inline]
mas_alloc_nodes+0x176/0x860 lib/maple_tree.c:1242
mas_node_count_gfp+0x105/0x130 lib/maple_tree.c:1322
mas_preallocate+0x3bb/0x1020 lib/maple_tree.c:5558
vma_iter_prealloc mm/internal.h:1147 [inline]
vma_expand+0x76d/0x13c0 mm/mmap.c:658
mmap_region+0x17d4/0x2aa0 mm/mmap.c:2800
do_mmap+0x8ae/0xf10 mm/mmap.c:1387
vm_mmap_pgoff+0x1ab/0x3c0 mm/util.c:573
ksys_mmap_pgoff+0x425/0x5b0 mm/mmap.c:1433
__do_sys_mmap arch/x86/kernel/sys_x86_64.c:86 [inline]
__se_sys_mmap arch/x86/kernel/sys_x86_64.c:79 [inline]
__x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:79
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd2/0x260 arch/x86/entry/common.c:83

Memory state around the buggy address:
ffff888042f3d100: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
ffff888042f3d180: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
>ffff888042f3d200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888042f3d280: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
ffff888042f3d300: fc fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
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.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages