syzbot


KASAN: slab-use-after-free Read in ovl_dentry_init_reval

Status: moderation: reported on 2024/04/14 06:05
Subsystems: overlayfs
[Documentation on labels]
Reported-by: syzbot+25f525d4387e496e4a89@syzkaller.appspotmail.com
First crash: 41d, last: 41d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in ovl_dentry_init_flags fs/overlayfs/util.c:188 [inline]
BUG: KASAN: slab-use-after-free in ovl_dentry_init_reval+0x204/0x210 fs/overlayfs/util.c:178
Read of size 4 at addr ffff88805f576000 by task syz-executor.1/5949

CPU: 1 PID: 5949 Comm: syz-executor.1 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 ovl_dentry_init_flags fs/overlayfs/util.c:188 [inline]
 ovl_dentry_init_reval+0x204/0x210 fs/overlayfs/util.c:178
 ovl_lookup+0x2572/0x2a60 fs/overlayfs/namei.c:1343
 lookup_open fs/namei.c:3475 [inline]
 open_last_lookups fs/namei.c:3566 [inline]
 path_openat+0x1033/0x3240 fs/namei.c:3796
 do_filp_open+0x235/0x490 fs/namei.c:3826
 do_sys_openat2+0x13e/0x1d0 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+0x247/0x2a0 fs/open.c:1432
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7effa427de69
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:00007effa4fc00c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007effa43abf80 RCX: 00007effa427de69
RDX: 0000000000000401 RSI: 00000000200004c0 RDI: ffffffffffffff9c
RBP: 00007effa42ca47a R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000000ca R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007effa43abf80 R15: 00007ffd1b2773b8
 </TASK>

Allocated by task 5949:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:312 [inline]
 __kasan_slab_alloc+0x66/0x80 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+0x178/0x350 mm/slub.c:3864
 __d_alloc+0x31/0x700 fs/dcache.c:1624
 d_alloc fs/dcache.c:1704 [inline]
 d_alloc_parallel+0xdf/0x1600 fs/dcache.c:2462
 __lookup_slow+0x117/0x3f0 fs/namei.c:1677
 lookup_one+0x1a9/0x2f0 fs/namei.c:2786
 ovl_lookup_upper fs/overlayfs/overlayfs.h:401 [inline]
 ovl_create_upper fs/overlayfs/dir.c:335 [inline]
 ovl_create_or_link+0x845/0x1670 fs/overlayfs/dir.c:606
 ovl_link+0x25d/0x320 fs/overlayfs/dir.c:724
 vfs_link+0x4f5/0x690 fs/namei.c:4608
 do_linkat+0x356/0x760 fs/namei.c:4679
 __do_sys_linkat fs/namei.c:4707 [inline]
 __se_sys_linkat fs/namei.c:4704 [inline]
 __x64_sys_linkat+0xdd/0xf0 fs/namei.c:4704
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Freed by task 2422:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 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+0x102/0x2b0 mm/slub.c:4344
 rcu_do_batch kernel/rcu/tree.c:2196 [inline]
 rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2471
 __do_softirq+0x2bc/0x943 kernel/softirq.c:554

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541
 __call_rcu_common kernel/rcu/tree.c:2734 [inline]
 call_rcu+0x167/0xa70 kernel/rcu/tree.c:2838
 __dentry_kill+0x497/0x630 fs/dcache.c:622
 dput+0x19f/0x2b0 fs/dcache.c:845
 ovl_get_inode+0xd8e/0xfd0 fs/overlayfs/inode.c:1254
 ovl_lookup+0x2323/0x2a60 fs/overlayfs/namei.c:1332
 lookup_open fs/namei.c:3475 [inline]
 open_last_lookups fs/namei.c:3566 [inline]
 path_openat+0x1033/0x3240 fs/namei.c:3796
 do_filp_open+0x235/0x490 fs/namei.c:3826
 do_sys_openat2+0x13e/0x1d0 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+0x247/0x2a0 fs/open.c:1432
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

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

The buggy address belongs to the physical page:
page:ffffea00017d5d80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88805f576178 pfn:0x5f576
head:ffffea00017d5d80 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff88802d86e601
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888015aeda00 ffffea0001fc0880 dead000000000004
raw: ffff88805f576178 0000000000150014 00000001ffffffff ffff88802d86e601
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 5076, tgid 5076 (syz-executor.3), ts 87753226067, free_ts 26764610516
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
 __alloc_pages+0x256/0x680 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+0x5f/0x160 mm/slub.c:2175
 allocate_slab mm/slub.c:2338 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2391
 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525
 __slab_alloc mm/slub.c:3610 [inline]
 __slab_alloc_node mm/slub.c:3663 [inline]
 slab_alloc_node mm/slub.c:3835 [inline]
 kmem_cache_alloc_lru+0x253/0x350 mm/slub.c:3864
 __d_alloc+0x31/0x700 fs/dcache.c:1624
 d_alloc_pseudo+0x1f/0xb0 fs/dcache.c:1756
 alloc_path_pseudo fs/file_table.c:330 [inline]
 alloc_file_pseudo+0x123/0x290 fs/file_table.c:346
 sock_alloc_file+0xb8/0x290 net/socket.c:469
 sock_map_fd net/socket.c:494 [inline]
 __sys_socket+0x1dd/0x3c0 net/socket.c:1715
 __do_sys_socket net/socket.c:1720 [inline]
 __se_sys_socket net/socket.c:1718 [inline]
 __x64_sys_socket+0x7a/0x90 net/socket.c:1718
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
page last free pid 1 tgid 1 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+0x95d/0xa80 mm/page_alloc.c:2346
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
 free_contig_range+0x9e/0x160 mm/page_alloc.c:6547
 destroy_args+0x8a/0x890 mm/debug_vm_pgtable.c:1036
 debug_vm_pgtable+0x4be/0x550 mm/debug_vm_pgtable.c:1416
 do_one_initcall+0x238/0x830 init/main.c:1241
 do_initcall_level+0x157/0x210 init/main.c:1303
 do_initcalls+0x3f/0x80 init/main.c:1319
 kernel_init_freeable+0x435/0x5d0 init/main.c:1550
 kernel_init+0x1d/0x2a0 init/main.c:1439
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243

Memory state around the buggy address:
 ffff88805f575f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88805f575f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88805f576000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88805f576080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805f576100: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fa
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/10 05:53 upstream fe46a7dd189e 171ec371 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ovl_dentry_init_reval
* Struck through repros no longer work on HEAD.