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

5 views
Skip to first unread message

syzbot

unread,
Jul 26, 2023, 9:35:58 AM7/26/23
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ae867bc97b71 Add linux-next specific files for 20230721
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10a85c6aa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c403a6b36e7c85ac
dashboard link: https://syzkaller.appspot.com/bug?extid=ada2f14ec3d1638c67d2
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
CC: [gre...@linuxfoundation.org linux-...@vger.kernel.org linux-...@vger.kernel.org raf...@kernel.org]

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a76b93f21f84/disk-ae867bc9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/8eb30097a952/vmlinux-ae867bc9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/7506a6b3ec38/bzImage-ae867bc9.xz

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

==================================================================
BUG: KASAN: slab-use-after-free in d_inode include/linux/dcache.h:516 [inline]
BUG: KASAN: slab-use-after-free in fsnotify_parent include/linux/fsnotify.h:60 [inline]
BUG: KASAN: slab-use-after-free in fsnotify_file include/linux/fsnotify.h:101 [inline]
BUG: KASAN: slab-use-after-free in fsnotify_close include/linux/fsnotify.h:343 [inline]
BUG: KASAN: slab-use-after-free in __fput+0xa1b/0xac0 fs/file_table.c:370
Read of size 8 at addr ffff88808306f4f8 by task syz-executor.0/8670

CPU: 1 PID: 8670 Comm: syz-executor.0 Not tainted 6.5.0-rc2-next-20230721-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
d_inode include/linux/dcache.h:516 [inline]
fsnotify_parent include/linux/fsnotify.h:60 [inline]
fsnotify_file include/linux/fsnotify.h:101 [inline]
fsnotify_close include/linux/fsnotify.h:343 [inline]
__fput+0xa1b/0xac0 fs/file_table.c:370
task_work_run+0x14d/0x240 kernel/task_work.c:179
get_signal+0x106f/0x27b0 kernel/signal.c:2664
arch_do_signal_or_restart+0x89/0x5f0 arch/x86/kernel/signal.c:308
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7ffb5887cb29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffb596300c8 EFLAGS: 00000246 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffea RBX: 00007ffb5899bf80 RCX: 00007ffb5887cb29
RDX: 0000000000000019 RSI: 0000000000600003 RDI: 0000000020000000
RBP: 00007ffb588c847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007ffb5899bf80 R15: 00007ffcf7d7b2a8
</TASK>

Allocated by task 8670:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
__kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
kasan_slab_alloc include/linux/kasan.h:186 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slub.c:3478 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc_lru+0x21a/0x630 mm/slub.c:3509
__d_alloc+0x32/0xac0 fs/dcache.c:1769
d_alloc_pseudo+0x1c/0x70 fs/dcache.c:1899
alloc_file_pseudo+0xdc/0x240 fs/file_table.c:329
__shmem_file_setup mm/shmem.c:4464 [inline]
__shmem_file_setup+0x1fa/0x2f0 mm/shmem.c:4435
shmem_kernel_file_setup mm/shmem.c:4483 [inline]
shmem_zero_setup+0x93/0x1b0 mm/shmem.c:4527
mmap_region+0x190d/0x2640 mm/mmap.c:2779
do_mmap+0x87c/0xed0 mm/mmap.c:1353
vm_mmap_pgoff+0x1a6/0x3b0 mm/util.c:543
ksys_mmap_pgoff+0x7d/0x5b0 mm/mmap.c:1399
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 8678:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1800 [inline]
slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
slab_free mm/slub.c:3809 [inline]
kmem_cache_free+0xf0/0x490 mm/slub.c:3831
__d_free fs/dcache.c:298 [inline]
dentry_free+0xdd/0x160 fs/dcache.c:375
__dentry_kill+0x4c1/0x640 fs/dcache.c:621
dentry_kill fs/dcache.c:733 [inline]
dput+0x8dd/0xfd0 fs/dcache.c:913
__fput+0x53c/0xac0 fs/file_table.c:392
task_work_run+0x14d/0x240 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
dentry_free+0xc2/0x160 fs/dcache.c:377
__dentry_kill+0x4c1/0x640 fs/dcache.c:621
dentry_kill fs/dcache.c:745 [inline]
dput+0x703/0xfd0 fs/dcache.c:913
find_next_child fs/libfs.c:508 [inline]
simple_recursive_removal+0x13a/0x7d0 fs/libfs.c:523
debugfs_remove+0x5d/0x80 fs/debugfs/inode.c:764
kvm_destroy_vm_debugfs+0xc6/0x250 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1012
kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:1282 [inline]
kvm_put_kvm+0x107/0xad0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1347
kvm_vm_release+0x42/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1370
__fput+0x3fd/0xac0 fs/file_table.c:384
task_work_run+0x14d/0x240 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
dentry_free+0xc2/0x160 fs/dcache.c:377
__dentry_kill+0x4c1/0x640 fs/dcache.c:621
dentry_kill fs/dcache.c:745 [inline]
dput+0x703/0xfd0 fs/dcache.c:913
do_unlinkat+0x3e9/0x6d0 fs/namei.c:4398
__do_sys_unlink fs/namei.c:4443 [inline]
__se_sys_unlink fs/namei.c:4441 [inline]
__x64_sys_unlink+0xc8/0x110 fs/namei.c:4441
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

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

The buggy address belongs to the physical page:
page:ffffea00020c1b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x8306e
head:ffffea00020c1b80 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888060610f01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff8880146758c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000150015 00000001ffffffff ffff888060610f01
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 5336, tgid 5336 (udevd), ts 286140445887, free_ts 261350343305
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1569
prep_new_page mm/page_alloc.c:1576 [inline]
get_page_from_freelist+0x10d7/0x31b0 mm/page_alloc.c:3256
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4512
alloc_pages+0x1a9/0x270 mm/mempolicy.c:2279
alloc_slab_page mm/slub.c:1870 [inline]
allocate_slab+0x24e/0x380 mm/slub.c:2017
new_slab mm/slub.c:2070 [inline]
___slab_alloc+0x8bc/0x1570 mm/slub.c:3223
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
__slab_alloc_node mm/slub.c:3375 [inline]
slab_alloc_node mm/slub.c:3468 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc_lru+0x4e4/0x630 mm/slub.c:3509
__d_alloc+0x32/0xac0 fs/dcache.c:1769
d_alloc+0x4e/0x220 fs/dcache.c:1849
lookup_one_qstr_excl+0xc7/0x180 fs/namei.c:1601
do_unlinkat+0x294/0x6d0 fs/namei.c:4381
__do_sys_unlink fs/namei.c:4443 [inline]
__se_sys_unlink fs/namei.c:4441 [inline]
__x64_sys_unlink+0xc8/0x110 fs/namei.c:4441
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1160 [inline]
__free_pages_ok+0x6b3/0xef0 mm/page_alloc.c:1299
kvfree+0x47/0x50 mm/util.c:650
kmem_free fs/xfs/kmem.h:62 [inline]
xlog_write_log_records+0x308/0x3e0 fs/xfs/xfs_log_recover.c:1586
xlog_clear_stale_blocks+0x1fb/0x450 fs/xfs/xfs_log_recover.c:1681
xlog_find_tail+0x854/0x9d0 fs/xfs/xfs_log_recover.c:1365
xlog_recover+0x90/0x500 fs/xfs/xfs_log_recover.c:3360
xfs_log_mount+0x256/0x540 fs/xfs/xfs_log.c:724
xfs_mountfs+0x10c3/0x1de0 fs/xfs/xfs_mount.c:819
xfs_fs_fill_super+0x145b/0x1e50 fs/xfs/xfs_super.c:1710
get_tree_bdev+0x43e/0x7d0 fs/super.c:1318
vfs_get_tree+0x88/0x350 fs/super.c:1519
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
ffff88808306f380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88808306f400: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
>ffff88808306f480: fc fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808306f500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808306f580: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
==================================================================


---
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 bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

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

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

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Sep 21, 2023, 4:39:37 AM9/21/23
to syzkaller-upst...@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