syzbot


KASAN: use-after-free Read in print_report

Status: closed as dup on 2022/04/05 08:40
Subsystems: serial
[Documentation on labels]
Reported-by: syzbot+2e05e258b9240c2861e7@syzkaller.appspotmail.com
First crash: 1001d, last: 1001d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Read in tty_release io-uring serial C done 23 1000d 1010d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __wake_up_common+0x255/0x4e0
Read of size 8 at addr ffff88801a663430 by task syz-executor.3/18348

CPU: 0 PID: 18348 Comm: syz-executor.3 Tainted: G        W         5.17.0-syzkaller-13532-gb4a5ea09b293 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x65/0x4b0 mm/kasan/report.c:313
 print_report+0xf4/0x200 mm/kasan/report.c:429
 kasan_report+0x109/0x140 mm/kasan/report.c:491
 __wake_up_common+0x255/0x4e0
 __wake_up_common_lock kernel/sched/wait.c:137 [inline]
 __wake_up+0x115/0x1c0 kernel/sched/wait.c:156
 tty_release+0x4a9/0xef0 drivers/tty/tty_io.c:1781
 __fput+0x3f6/0x860 fs/file_table.c:317
 task_work_run+0x146/0x1c0 kernel/task_work.c:164
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:183 [inline]
 exit_to_user_mode_prepare+0x1d2/0x1f0 kernel/entry/common.c:215
 __syscall_exit_to_user_mode_work kernel/entry/common.c:297 [inline]
 syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:308
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f395483bc8b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffe41873890 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00007f395483bc8b
RDX: 00007f39549a0b80 RSI: ffffffffffffffff RDI: 0000000000000004
RBP: 00007f395499d960 R08: 0000000000000000 R09: 00007f39549a0b88
R10: 00007ffe41873990 R11: 0000000000000293 R12: 0000000000074866
R13: 00007ffe41873990 R14: 00007f395499bf60 R15: 0000000000000032
 </TASK>

Allocated by task 18344:
 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:436 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:515
 kasan_kmalloc include/linux/kasan.h:234 [inline]
 kmem_cache_alloc_trace+0x9d/0x330 mm/slub.c:3258
 kmalloc include/linux/slab.h:581 [inline]
 io_arm_poll_handler+0x3bd/0x710 fs/io_uring.c:6248
 io_queue_sqe_arm_apoll fs/io_uring.c:7499 [inline]
 __io_queue_sqe+0x23d/0x10b0 fs/io_uring.c:7541
 io_queue_sqe fs/io_uring.c:7568 [inline]
 io_submit_sqe fs/io_uring.c:7776 [inline]
 io_submit_sqes+0x12da/0xbb40 fs/io_uring.c:7882
 __do_sys_io_uring_enter fs/io_uring.c:10924 [inline]
 __se_sys_io_uring_enter+0x31f/0x2f00 fs/io_uring.c:10850
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x50 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 8:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x136/0x1e0 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1754
 slab_free mm/slub.c:3510 [inline]
 kfree+0xc6/0x390 mm/slub.c:4552
 io_flush_apoll_cache fs/io_uring.c:10038 [inline]
 io_ring_ctx_free+0x48d/0xfee fs/io_uring.c:10064
 io_ring_exit_work+0x64d/0x6ba fs/io_uring.c:10244
 process_one_work+0x83c/0x11a0 kernel/workqueue.c:2289
 worker_thread+0xa6c/0x1290 kernel/workqueue.c:2436
 kthread+0x2a3/0x2d0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:348
 kvfree_call_rcu+0x119/0x880 kernel/rcu/tree.c:3595
 cfg80211_update_known_bss+0x174/0x9a0
 cfg80211_bss_update+0x17a/0x2170 net/wireless/scan.c:1715
 cfg80211_inform_single_bss_frame_data net/wireless/scan.c:2471 [inline]
 cfg80211_inform_bss_frame_data+0x9e2/0x2190 net/wireless/scan.c:2504
 ieee80211_bss_info_update+0x75b/0xbe0 net/mac80211/scan.c:190
 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline]
 ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline]
 ieee80211_ibss_rx_queued_mgmt+0x1690/0x2b30 net/mac80211/ibss.c:1639
 ieee80211_iface_process_skb net/mac80211/iface.c:1527 [inline]
 ieee80211_iface_work+0x713/0xca0 net/mac80211/iface.c:1581
 process_one_work+0x83c/0x11a0 kernel/workqueue.c:2289
 worker_thread+0xa6c/0x1290 kernel/workqueue.c:2436
 kthread+0x2a3/0x2d0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30

The buggy address belongs to the object at ffff88801a663400
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 48 bytes inside of
 96-byte region [ffff88801a663400, ffff88801a663460)

The buggy address belongs to the physical page:
page:ffffea00006998c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1a663
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0000456c80 dead000000000005 ffff888011441780
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 3602, tgid 3602 (syz-executor.0), ts 55856330390, free_ts 55843896899
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0x708/0xa80 mm/page_alloc.c:4182
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5408
 alloc_slab_page+0x70/0xf0 mm/slub.c:1799
 allocate_slab+0x5d/0x380 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x40e/0xcc0 mm/slub.c:3005
 __slab_alloc mm/slub.c:3092 [inline]
 slab_alloc_node mm/slub.c:3183 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmalloc+0x2eb/0x380 mm/slub.c:4410
 kmalloc include/linux/slab.h:586 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 tomoyo_encode2+0x25a/0x560 security/tomoyo/realpath.c:45
 tomoyo_encode security/tomoyo/realpath.c:80 [inline]
 tomoyo_realpath_from_path+0x5c3/0x610 security/tomoyo/realpath.c:288
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x238/0x660 security/tomoyo/file.c:822
 tomoyo_path_rmdir+0xcc/0x100 security/tomoyo/tomoyo.c:182
 security_path_rmdir+0xc3/0x140 security/security.c:1165
 do_rmdir+0x2d1/0x6e0 fs/namei.c:4076
 __do_sys_rmdir fs/namei.c:4099 [inline]
 __se_sys_rmdir fs/namei.c:4097 [inline]
 __x64_sys_rmdir+0x45/0x50 fs/namei.c:4097
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x50 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1356 [inline]
 free_pcp_prepare+0xcfc/0xe70 mm/page_alloc.c:1406
 free_unref_page_prepare mm/page_alloc.c:3328 [inline]
 free_unref_page_list+0x140/0xa10 mm/page_alloc.c:3460
 release_pages+0x2aa1/0x2d40 mm/swap.c:978
 tlb_batch_pages_flush mm/mmu_gather.c:50 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:243 [inline]
 tlb_flush_mmu+0x780/0x910 mm/mmu_gather.c:250
 tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:341
 exit_mmap+0x1dc/0x530 mm/mmap.c:3150
 __mmput+0x111/0x3a0 kernel/fork.c:1183
 exit_mm+0x211/0x2f0 kernel/exit.c:510
 do_exit+0x566/0x20c0 kernel/exit.c:782
 do_group_exit+0x2af/0x2b0 kernel/exit.c:925
 get_signal+0x23bd/0x23c0 kernel/signal.c:2904
 arch_do_signal_or_restart+0x8e/0x740 arch/x86/kernel/signal.c:867
 exit_to_user_mode_loop kernel/entry/common.c:180 [inline]
 exit_to_user_mode_prepare+0x128/0x1f0 kernel/entry/common.c:215
 __syscall_exit_to_user_mode_work kernel/entry/common.c:297 [inline]
 syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:308
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff88801a663300: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff88801a663380: 00 00 00 00 00 00 00 00 03 fc fc fc fc fc fc fc
>ffff88801a663400: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                                     ^
 ffff88801a663480: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88801a663500: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/03/31 20:05 upstream b4a5ea09b293 c4c32d8c .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in print_report
* Struck through repros no longer work on HEAD.