syzbot


KASAN: use-after-free Read in fast_dput

Status: premoderation: reported on 2024/07/14 22:05
Reported-by: syzbot+5160e74f03ef759c598a@syzkaller.appspotmail.com
First crash: 91d, last: 16d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in fast_dput+0x1f2/0x2a0 fs/dcache.c:750
Read of size 4 at addr ffff888110645cc0 by task syz-executor/4917

CPU: 0 PID: 4917 Comm: syz-executor Tainted: G        W         5.10.225-syzkaller-00513-g8d23314f588a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 fast_dput+0x1f2/0x2a0 fs/dcache.c:750
 dput+0x21/0x80 fs/dcache.c:870
 incfs_free_mount_info+0x60/0x210 fs/incfs/data_mgmt.c:166
 incfs_kill_sb+0x1c2/0x220 fs/incfs/vfs.c:1979
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 __do_sys_exit_group kernel/exit.c:996 [inline]
 __se_sys_exit_group kernel/exit.c:994 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:994
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fd27343af39
Code: Unable to access opcode bytes at RIP 0x7fd27343af0f.
RSP: 002b:00007fff00c801d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fd2734ad114 RCX: 00007fd27343af39
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000009 R08: 00007fff00c7df77 R09: 00007fff00c81490
R10: 0000000000000009 R11: 0000000000000246 R12: 00007fff00c81490
R13: 00007fd2734ad0b4 R14: 000055557c3de4a8 R15: 00007fff00c82550

Allocated by task 9905:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 __kasan_slab_alloc+0xb1/0xe0 mm/kasan/common.c:463
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 __d_alloc+0x2d/0x6c0 fs/dcache.c:1714
 d_alloc fs/dcache.c:1793 [inline]
 d_alloc_parallel+0xec/0x1370 fs/dcache.c:2547
 __lookup_slow+0x154/0x400 fs/namei.c:1625
 lookup_one_len+0x180/0x2c0 fs/namei.c:2656
 incfs_lookup_dentry+0x5f/0xb0 fs/incfs/data_mgmt.c:210
 open_or_create_special_dir+0x4f/0x1d0 fs/incfs/vfs.c:469
 incfs_mount_fs+0x48d/0xa10 fs/incfs/vfs.c:1867
 legacy_get_tree+0xf1/0x190 fs/fs_context.c:593
 vfs_get_tree+0x88/0x290 fs/super.c:1570
 do_new_mount+0x2ba/0xb30 fs/namespace.c:2910
 path_mount+0x56f/0xcb0 fs/namespace.c:3240
 do_mount fs/namespace.c:3253 [inline]
 __do_sys_mount fs/namespace.c:3461 [inline]
 __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3438
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3438
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 9944:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kmem_cache_free+0xa9/0x1e0 mm/slub.c:3219
 __d_free+0x23/0x30 fs/dcache.c:271
 rcu_do_batch+0x597/0xc40 kernel/rcu/tree.c:2494
 rcu_core+0x5ad/0xe40 kernel/rcu/tree.c:2735
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2748
 __do_softirq+0x268/0x5bb kernel/softirq.c:309

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2976 [inline]
 call_rcu+0x135/0x11f0 kernel/rcu/tree.c:3050
 dentry_free+0xbf/0x160
 __dentry_kill+0x505/0x650 fs/dcache.c:597
 dentry_kill+0xc0/0x2a0
 dput+0x40/0x80 fs/dcache.c:883
 incfs_free_mount_info+0x60/0x210 fs/incfs/data_mgmt.c:166
 incfs_kill_sb+0x1c2/0x220 fs/incfs/vfs.c:1979
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 __do_sys_exit_group kernel/exit.c:996 [inline]
 __se_sys_exit_group kernel/exit.c:994 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:994
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2976 [inline]
 call_rcu+0x135/0x11f0 kernel/rcu/tree.c:3050
 dentry_free+0xbf/0x160
 __dentry_kill+0x505/0x650 fs/dcache.c:597
 dentry_kill+0xc0/0x2a0
 dput+0x40/0x80 fs/dcache.c:883
 do_unlinkat+0x44d/0x8b0 fs/namei.c:4038
 __do_sys_unlink fs/namei.c:4082 [inline]
 __se_sys_unlink fs/namei.c:4080 [inline]
 __x64_sys_unlink+0x49/0x50 fs/namei.c:4080
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff888110645cc0
 which belongs to the cache dentry of size 208
The buggy address is located 0 bytes inside of
 208-byte region [ffff888110645cc0, ffff888110645d90)
The buggy address belongs to the page:
page:ffffea0004419140 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888110645330 pfn:0x110645
flags: 0x4000000000000200(slab)
raw: 4000000000000200 ffffea00040119c8 ffffea000441abc8 ffff888100192480
raw: ffff888110645330 00000000000f0007 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x112cd0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_RECLAIMABLE), pid 4917, ts 397490637708, free_ts 381746765106
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x1b9/0x2e0 mm/slub.c:2960
 __d_alloc+0x2d/0x6c0 fs/dcache.c:1714
 d_alloc_anon fs/dcache.c:1812 [inline]
 d_alloc_cursor+0x41/0xd0 fs/dcache.c:1818
 dcache_dir_open+0x3b/0x80 fs/libfs.c:81
 do_dentry_open+0x7c1/0x10d0 fs/open.c:819
 vfs_open+0x73/0x80 fs/open.c:942
 do_open fs/namei.c:3391 [inline]
 path_openat+0x2660/0x3000 fs/namei.c:3509
 do_filp_open+0x21c/0x460 fs/namei.c:3536
 do_sys_openat2+0x13f/0x710 fs/open.c:1217
 do_sys_open fs/open.c:1233 [inline]
 __do_sys_openat fs/open.c:1249 [inline]
 __se_sys_openat fs/open.c:1244 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1244
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 free_pcp_prepare mm/page_alloc.c:1421 [inline]
 free_unref_page_prepare+0x2ae/0x2d0 mm/page_alloc.c:3336
 free_unref_page mm/page_alloc.c:3391 [inline]
 free_the_page+0x9e/0x370 mm/page_alloc.c:5407
 __free_pages+0x67/0xc0 mm/page_alloc.c:5418
 __free_slab+0xcf/0x190 mm/slub.c:1894
 free_slab mm/slub.c:1909 [inline]
 discard_slab mm/slub.c:1915 [inline]
 unfreeze_partials+0x15e/0x190 mm/slub.c:2410
 put_cpu_partial+0xbf/0x180 mm/slub.c:2446
 __slab_free+0x2c8/0x3a0 mm/slub.c:3095
 do_slab_free mm/slub.c:3191 [inline]
 ___cache_free+0x111/0x130 mm/slub.c:3210
 qlink_free+0x50/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x47/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:440
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 getname_flags+0xba/0x520 fs/namei.c:141
 user_path_at_empty+0x2d/0x50 fs/namei.c:2740

Memory state around the buggy address:
 ffff888110645b80: fc fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb
 ffff888110645c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888110645c80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
                                           ^
 ffff888110645d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888110645d80: fb fb fc fc fc fc fc fc fc fc fb fb fb fb fb fb
==================================================================
------------[ cut here ]------------
WARNING: CPU: 1 PID: 4917 at fs/dcache.c:766 fast_dput+0x256/0x2a0 fs/dcache.c:766
Modules linked in:
CPU: 1 PID: 4917 Comm: syz-executor Tainted: G    B   W         5.10.225-syzkaller-00513-g8d23314f588a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
RIP: 0010:fast_dput+0x256/0x2a0 fs/dcache.c:766
Code: f1 ff e9 d4 fe ff ff 44 89 e9 80 e1 07 80 c1 03 38 c1 0f 8c f7 fe ff ff 4c 89 ef e8 54 bb f1 ff e9 ea fe ff ff e8 ca 20 b4 ff <0f> 0b e9 c0 fe ff ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c 2a ff ff
RSP: 0018:ffffc90000e37b20 EFLAGS: 00010293
RAX: ffffffff81b68c16 RBX: ffff888110645d1c RCX: ffff88810ce693c0
RDX: 0000000000000000 RSI: 00000000ffffff80 RDI: 0000000000000001
RBP: ffffc90000e37b58 R08: ffffffff81b68b6b R09: 0000000000000003
R10: fffff520001c6f54 R11: dffffc0000000001 R12: 00000000ffffff80
R13: ffff888110645cc0 R14: ffff888110645d18 R15: dffffc0000000000
FS:  0000000000000000(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005590ba13a0c8 CR3: 000000000660f000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 dput+0x21/0x80 fs/dcache.c:870
 incfs_free_mount_info+0x60/0x210 fs/incfs/data_mgmt.c:166
 incfs_kill_sb+0x1c2/0x220 fs/incfs/vfs.c:1979
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 __do_sys_exit_group kernel/exit.c:996 [inline]
 __se_sys_exit_group kernel/exit.c:994 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:994
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fd27343af39
Code: Unable to access opcode bytes at RIP 0x7fd27343af0f.
RSP: 002b:00007fff00c801d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fd2734ad114 RCX: 00007fd27343af39
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000009 R08: 00007fff00c7df77 R09: 00007fff00c81490
R10: 0000000000000009 R11: 0000000000000246 R12: 00007fff00c81490
R13: 00007fd2734ad0b4 R14: 000055557c3de4a8 R15: 00007fff00c82550
---[ end trace f5fc0b42c9ce9fa7 ]---
list_del corruption. prev->next should be ffff8881106451a0, but was ffff888123e561a0
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:61!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 4917 Comm: syz-executor Tainted: G    B   W         5.10.225-syzkaller-00513-g8d23314f588a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
RIP: 0010:__list_del_entry_valid+0x10c/0x120 lib/list_debug.c:59
Code: 4c 89 f6 e8 3c c9 55 02 0f 0b 48 c7 c7 80 29 60 85 4c 89 f6 e8 2b c9 55 02 0f 0b 48 c7 c7 e0 29 60 85 4c 89 f6 e8 1a c9 55 02 <0f> 0b 48 c7 c7 40 2a 60 85 4c 89 f6 e8 09 c9 55 02 0f 0b cc 55 48
RSP: 0018:ffffc90000e37a98 EFLAGS: 00010246
RAX: 0000000000000054 RBX: ffff888123e56800 RCX: d000022dfab5f300
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000
RBP: ffffc90000e37ab8 R08: ffffffff81522098 R09: ffffed103ee0a5f8
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff888110645168 R14: ffff8881106451a0 R15: ffff888123e56920
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000010cc02000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 __list_del_entry include/linux/list.h:132 [inline]
 dentry_unlist fs/dcache.c:526 [inline]
 __dentry_kill+0x250/0x650 fs/dcache.c:579
 dentry_kill+0xc0/0x2a0
 dput+0x40/0x80 fs/dcache.c:883
 incfs_free_mount_info+0x80/0x210 fs/incfs/data_mgmt.c:167
 incfs_kill_sb+0x1c2/0x220 fs/incfs/vfs.c:1979
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863
 do_group_exit+0x141/0x310 kernel/exit.c:985
 __do_sys_exit_group kernel/exit.c:996 [inline]
 __se_sys_exit_group kernel/exit.c:994 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:994
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fd27343af39
Code: Unable to access opcode bytes at RIP 0x7fd27343af0f.
RSP: 002b:00007fff00c801d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fd2734ad114 RCX: 00007fd27343af39
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000009 R08: 00007fff00c7df77 R09: 00007fff00c81490
R10: 0000000000000009 R11: 0000000000000246 R12: 00007fff00c81490
R13: 00007fd2734ad0b4 R14: 000055557c3de4a8 R15: 00007fff00c82550
Modules linked in:
---[ end trace f5fc0b42c9ce9fa8 ]---
RIP: 0010:__list_del_entry_valid+0x10c/0x120 lib/list_debug.c:59
Code: 4c 89 f6 e8 3c c9 55 02 0f 0b 48 c7 c7 80 29 60 85 4c 89 f6 e8 2b c9 55 02 0f 0b 48 c7 c7 e0 29 60 85 4c 89 f6 e8 1a c9 55 02 <0f> 0b 48 c7 c7 40 2a 60 85 4c 89 f6 e8 09 c9 55 02 0f 0b cc 55 48
RSP: 0018:ffffc90000e37a98 EFLAGS: 00010246
RAX: 0000000000000054 RBX: ffff888123e56800 RCX: d000022dfab5f300
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000
RBP: ffffc90000e37ab8 R08: ffffffff81522098 R09: ffffed103ee0a5f8
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff888110645168 R14: ffff8881106451a0 R15: ffff888123e56920
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000010cc02000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/27 15:39 android13-5.10-lts 8d23314f588a 9314348a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in fast_dput
2024/08/25 14:53 android13-5.10-lts 0890c03b8b7d d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in fast_dput
2024/08/11 18:55 android13-5.10-lts fd58936f3c1f 6f4edef4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in fast_dput
2024/07/14 22:04 android13-5.10-lts 3feee789f446 eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in fast_dput
* Struck through repros no longer work on HEAD.