syzbot


KASAN: use-after-free Read in lock_get_status

Status: premoderation: reported on 2024/11/27 19:59
Reported-by: syzbot+4cda8178e22b0c201ea0@syzkaller.appspotmail.com
First crash: 24d, last: 8d05h

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in file_inode include/linux/fs.h:1343 [inline]
BUG: KASAN: use-after-free in lock_get_status+0x209/0x9a0 fs/locks.c:2861
Read of size 8 at addr ffff88810fe80320 by task syz.1.10989/4569

CPU: 0 PID: 4569 Comm: syz.1.10989 Tainted: G        W         5.10.230-syzkaller-00201-ga359b995b6bb #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 file_inode include/linux/fs.h:1343 [inline]
 lock_get_status+0x209/0x9a0 fs/locks.c:2861
 locks_show+0x234/0x350 fs/locks.c:2936
 traverse+0x1d0/0x530 fs/seq_file.c:111
 seq_lseek+0x170/0x270 fs/seq_file.c:323
 pde_lseek fs/proc/inode.c:283 [inline]
 proc_reg_llseek+0x1db/0x2b0 fs/proc/inode.c:294
 vfs_llseek fs/read_write.c:300 [inline]
 ksys_lseek fs/read_write.c:313 [inline]
 __do_sys_lseek fs/read_write.c:324 [inline]
 __se_sys_lseek fs/read_write.c:322 [inline]
 __x64_sys_lseek+0x160/0x1f0 fs/read_write.c:322
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7eff15cc0d19
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007eff14332038 EFLAGS: 00000246 ORIG_RAX: 0000000000000008
RAX: ffffffffffffffda RBX: 00007eff15eb0fa0 RCX: 00007eff15cc0d19
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000003
RBP: 00007eff15d3ca20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007eff15eb0fa0 R15: 00007fffe89c97a8

Allocated by task 2117:
 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
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 __alloc_file+0x29/0x330 fs/file_table.c:101
 alloc_empty_file+0x95/0x180 fs/file_table.c:151
 alloc_file+0x5a/0x4e0 fs/file_table.c:193
 alloc_file_pseudo+0x259/0x2f0 fs/file_table.c:233
 sock_alloc_file+0xbb/0x260 net/socket.c:412
 sock_map_fd net/socket.c:436 [inline]
 __sys_socket+0x194/0x370 net/socket.c:1533
 __do_sys_socket net/socket.c:1538 [inline]
 __se_sys_socket net/socket.c:1536 [inline]
 __x64_sys_socket+0x7a/0x90 net/socket.c:1536
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 4014:
 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
 file_free_rcu+0x9f/0xb0 fs/file_table.c:50
 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
 file_free fs/file_table.c:58 [inline]
 __fput+0x5e4/0x7b0 fs/file_table.c:299
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x129/0x190 kernel/task_work.c:189
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xa2/0x1a0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 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+0xe/0x10 mm/kasan/generic.c:353
 task_work_add+0x27/0x1d0 kernel/task_work.c:38
 fput_many+0xef/0x1b0 fs/file_table.c:342
 fput+0x1a/0x20 fs/file_table.c:358
 filp_close+0x106/0x150 fs/open.c:1333
 __close_fd+0x33/0x50 fs/file.c:699
 __do_sys_close fs/open.c:1346 [inline]
 __se_sys_close fs/open.c:1344 [inline]
 __x64_sys_close+0x68/0xc0 fs/open.c:1344
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88810fe80300
 which belongs to the cache filp of size 296
The buggy address is located 32 bytes inside of
 296-byte region [ffff88810fe80300, ffff88810fe80428)
The buggy address belongs to the page:
page:ffffea00043fa000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10fe80
head:ffffea00043fa000 order:1 compound_mapcount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 0000000000000000 0000000100000001 ffff88810018be00
raw: 0000000000000000 0000000000150015 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 95, ts 89329022713, free_ts 89302071053
 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
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 __alloc_file+0x29/0x330 fs/file_table.c:101
 alloc_empty_file+0x95/0x180 fs/file_table.c:151
 path_openat+0x105/0x3000 fs/namei.c:3495
 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
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
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_pages+0x7c/0x90 mm/page_alloc.c:5429
 tlb_batch_list_free mm/mmu_gather.c:61 [inline]
 tlb_finish_mmu+0x253/0x320 mm/mmu_gather.c:329
 exit_mmap+0x312/0x5c0 mm/mmap.c:3357
 __mmput+0x95/0x2d0 kernel/fork.c:1153
 mmput+0x59/0x170 kernel/fork.c:1176
 exit_mm kernel/exit.c:539 [inline]
 do_exit+0xbda/0x2a50 kernel/exit.c:850
 do_group_exit+0x141/0x310 kernel/exit.c:985
 get_signal+0x10a0/0x1410 kernel/signal.c:2793
 arch_do_signal_or_restart+0xbd/0x17c0 arch/x86/kernel/signal.c:805
 handle_signal_work kernel/entry/common.c:145 [inline]
 exit_to_user_mode_loop+0x9b/0xd0 kernel/entry/common.c:169
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xa2/0x1a0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88810fe80200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810fe80280: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
>ffff88810fe80300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88810fe80380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810fe80400: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/14 06:31 android13-5.10-lts a359b995b6bb 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in lock_get_status
2024/12/10 19:29 android13-5.10-lts 0eb852f47fe5 cfc402b4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in lock_get_status
2024/12/05 05:16 android13-5.10-lts 144b70d4e926 b50eb251 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in lock_get_status
2024/11/27 19:58 android13-5.10-lts 139a6bb26d9d 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in lock_get_status
* Struck through repros no longer work on HEAD.