syzbot


KASAN: use-after-free Read in trylock_super

Status: upstream: reported on 2024/12/27 15:01
Reported-by: syzbot+10c96292c72592b68d40@syzkaller.appspotmail.com
First crash: 18d, last: 18d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Write in trylock_super vfs origin:lts syz error 45 1d17h 770d 0/2 premoderation: reported syz repro on 2022/12/07 03:02
upstream KASAN: slab-use-after-free Read in trylock_super fs 1 654d 650d 0/28 auto-obsoleted due to no activity on 2023/07/01 04:40
android-54 KASAN: use-after-free Write in trylock_super 4 583d 672d 0/2 auto-obsoleted due to no activity on 2023/09/19 19:51
android-5-10 KASAN: use-after-free Write in trylock_super vfs syz inconclusive 76 1d10h 776d 0/2 premoderation: reported syz repro on 2022/11/30 20:27

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __down_read_trylock kernel/locking/rwsem.c:1270 [inline]
BUG: KASAN: use-after-free in down_read_trylock+0xa8/0x3b0 kernel/locking/rwsem.c:1537
Read of size 8 at addr ffff88807b2400d8 by task kworker/u4:5/4233

CPU: 1 PID: 4233 Comm: kworker/u4:5 Not tainted 5.15.175-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: writeback wb_workfn (flush-7:5)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 __down_read_trylock kernel/locking/rwsem.c:1270 [inline]
 down_read_trylock+0xa8/0x3b0 kernel/locking/rwsem.c:1537
 trylock_super+0x1b/0xf0 fs/super.c:418
 __writeback_inodes_wb+0xfe/0x400 fs/fs-writeback.c:1992
 wb_writeback+0x465/0xc50 fs/fs-writeback.c:2106
 wb_check_old_data_flush fs/fs-writeback.c:2206 [inline]
 wb_do_writeback fs/fs-writeback.c:2259 [inline]
 wb_workfn+0xc55/0x1130 fs/fs-writeback.c:2288
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 4208:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc_node_track_caller+0x195/0x390 mm/slub.c:4963
 kmalloc_reserve net/core/skbuff.c:356 [inline]
 __alloc_skb+0x12c/0x590 net/core/skbuff.c:427
 alloc_skb include/linux/skbuff.h:1162 [inline]
 nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:664 [inline]
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:721 [inline]
 nsim_dev_trap_report_work+0x25e/0xab0 drivers/net/netdevsim/dev.c:762
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Freed by task 4208:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 skb_free_head net/core/skbuff.c:655 [inline]
 skb_release_data+0x73a/0x8a0 net/core/skbuff.c:677
 skb_release_all net/core/skbuff.c:742 [inline]
 __kfree_skb net/core/skbuff.c:756 [inline]
 consume_skb+0xa3/0x140 net/core/skbuff.c:914
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:737 [inline]
 nsim_dev_trap_report_work+0x788/0xab0 drivers/net/netdevsim/dev.c:762
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3e0 kernel/workqueue.c:1366
 __queue_work+0x963/0xd00 kernel/workqueue.c:1532
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1559
 rcu_do_batch kernel/rcu/tree.c:2523 [inline]
 rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2763
 handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
 __do_softirq kernel/softirq.c:592 [inline]
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
 put_super fs/super.c:313 [inline]
 deactivate_locked_super+0xd4/0x110 fs/super.c:346
 cleanup_mnt+0x44e/0x500 fs/namespace.c:1143
 task_work_run+0x129/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff88807b240000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 216 bytes inside of
 4096-byte region [ffff88807b240000, ffff88807b241000)
The buggy address belongs to the page:
page:ffffea0001ec9000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7b240
head:ffffea0001ec9000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017442140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4260, ts 209915059678, free_ts 209695492831
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5465
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1668
 do_dentry_open+0x315/0xfb0 fs/open.c:813
 do_open fs/namei.c:3608 [inline]
 path_openat+0x2705/0x2f20 fs/namei.c:3742
 do_filp_open+0x21c/0x460 fs/namei.c:3769
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
 do_sys_open fs/open.c:1269 [inline]
 __do_sys_openat fs/open.c:1285 [inline]
 __se_sys_openat fs/open.c:1280 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1280
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 vm_area_dup kernel/fork.c:358 [inline]
 dup_mmap kernel/fork.c:557 [inline]
 dup_mm kernel/fork.c:1466 [inline]
 copy_mm+0x8d2/0x1370 kernel/fork.c:1518
 copy_process+0x1816/0x3ef0 kernel/fork.c:2205
 kernel_clone+0x210/0x960 kernel/fork.c:2603
 __do_sys_clone kernel/fork.c:2720 [inline]
 __se_sys_clone kernel/fork.c:2704 [inline]
 __x64_sys_clone+0x23f/0x290 kernel/fork.c:2704
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff88807b23ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88807b240000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807b240080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807b240100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807b240180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/27 15:00 linux-5.15.y 91786f140358 d3ccff63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in trylock_super
* Struck through repros no longer work on HEAD.