syzbot


KASAN: use-after-free Write in _free_event

Status: fixed on 2019/08/14 02:14
Subsystems: perf
[Documentation on labels]
Reported-by: syzbot+a24c397a29ad22d86c98@syzkaller.appspotmail.com
Fix commit: 1cf8dfe8a661 perf/core: Fix race between close() and fork()
First crash: 2345d, last: 2107d
Discussions (7)
Title Replies (including bot) Last reply
[PATCH 5.2 00/66] 5.2.4-stable review 78 (78) 2019/07/29 15:12
[PATCH 5.1 00/62] 5.1.21-stable review 68 (68) 2019/07/29 09:02
[PATCH 4.19 00/50] 4.19.62-stable review 56 (56) 2019/07/29 09:02
Reminder: 22 open syzbot bugs in perf subsystem 7 (7) 2019/07/03 11:34
[PATCH] perf: Fix race between close() and fork() 5 (5) 2019/07/01 09:24
KASAN: use-after-free Write in _free_event 7 (9) 2019/06/25 08:49
Re: [RFC PATCH] perf: Paper over the hw.target problems 2 (2) 2019/03/11 13:32
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Write in _free_event 5 1898d 1905d 0/1 auto-closed as invalid on 2020/01/26 08:58

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:222 [inline]
BUG: KASAN: use-after-free in put_task_struct include/linux/sched/task.h:95 [inline]
BUG: KASAN: use-after-free in _free_event+0x48d/0x1440 kernel/events/core.c:4451
Write of size 4 at addr ffff8801aab60760 by task syz-executor361/6988

CPU: 1 PID: 6988 Comm: syz-executor361 Not tainted 4.18.0-rc5+ #159
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278
 atomic_dec_and_test include/asm-generic/atomic-instrumented.h:222 [inline]
 put_task_struct include/linux/sched/task.h:95 [inline]
 _free_event+0x48d/0x1440 kernel/events/core.c:4451
 free_event+0xb4/0x180 kernel/events/core.c:4472
 perf_event_release_kernel+0x7d5/0x1050 kernel/events/core.c:4633
 perf_release+0x37/0x50 kernel/events/core.c:4647
 __fput+0x355/0x8b0 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x1ec/0x2a0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x1b08/0x2750 kernel/exit.c:865
 do_group_exit+0x177/0x440 kernel/exit.c:968
 get_signal+0x88e/0x1970 kernel/signal.c:2468
 do_signal+0x9c/0x21c0 arch/x86/kernel/signal.c:816
 exit_to_usermode_loop+0x2e0/0x370 arch/x86/entry/common.c:162
 prepare_exit_to_usermode+0x342/0x3b0 arch/x86/entry/common.c:197
 retint_user+0x8/0x18
RIP: 0033:0x445ea5
Code: 80 00 00 00 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 0f 83 fb 0d fc ff <c3> 66 2e 0f 1f 84 00 00 00 00 00 48 85 ff 41 57 4d 89 cf 41 56 41 
RSP: 002b:0000000020000040 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00000000006dbc24 RCX: 0000000000445e99
RDX: 0000000020000100 RSI: 0000000020000040 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000020000080 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000246 R12: 00000000006dbc20
R13: 0030656c69662f2e R14: 0001000000000002 R15: 0000000000000006

Allocated by task 6959:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc_node+0x144/0x780 mm/slab.c:3644
 alloc_task_struct_node kernel/fork.c:157 [inline]
 dup_task_struct kernel/fork.c:804 [inline]
 copy_process.part.39+0x16a1/0x70b0 kernel/fork.c:1666
 copy_process kernel/fork.c:1641 [inline]
 _do_fork+0x291/0x12a0 kernel/fork.c:2124
 __do_sys_clone kernel/fork.c:2231 [inline]
 __se_sys_clone kernel/fork.c:2225 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2225
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6959:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kmem_cache_free+0x86/0x2d0 mm/slab.c:3756
 free_task_struct kernel/fork.c:162 [inline]
 free_task+0x16e/0x1f0 kernel/fork.c:417
 copy_process.part.39+0x15b5/0x70b0 kernel/fork.c:2059
 copy_process kernel/fork.c:1641 [inline]
 _do_fork+0x291/0x12a0 kernel/fork.c:2124
 __do_sys_clone kernel/fork.c:2231 [inline]
 __se_sys_clone kernel/fork.c:2225 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2225
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801aab60740
 which belongs to the cache task_struct of size 5952
The buggy address is located 32 bytes inside of
 5952-byte region [ffff8801aab60740, ffff8801aab61e80)
The buggy address belongs to the page:
page:ffffea0006aad800 count:1 mapcount:0 mapping:ffff8801da94b200 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea0007592388 ffffea0006aa2a08 ffff8801da94b200
raw: 0000000000000000 ffff8801aab60740 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801aab60600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801aab60680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801aab60700: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                       ^
 ffff8801aab60780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801aab60800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (112):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/07/22 16:27 upstream 45ae4df92207 8cc079c3 .config console log report syz C ci-upstream-kasan-gce-root
2018/07/10 02:15 upstream 092150a25cb7 f25e5770 .config console log report syz C ci-upstream-kasan-gce-root
2018/07/21 15:09 linux-next 89cf55353308 8cc079c3 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/03/03 09:32 upstream c027c7cf1577 1c0e457a .config console log report ci-upstream-kasan-gce-smack-root
2019/01/25 18:46 upstream d73aba1115cf b5d78bce .config console log report ci-upstream-kasan-gce
2018/12/14 11:23 upstream 65e08c5e8631 fe7127be .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/02 09:04 upstream 4b78317679c4 5a581673 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/18 12:11 upstream 1ce80e0fe98e adf636a8 .config console log report ci-upstream-kasan-gce-root
2018/11/14 06:03 upstream ccda4af0f4b9 5f5f6d14 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/11 18:22 upstream e255aee5b66c 7b5f8621 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/06 11:39 upstream 163c8d54a997 8bd6bd63 .config console log report ci-upstream-kasan-gce-root
2018/11/05 18:09 upstream 651022382c7f 8bd6bd63 .config console log report ci-upstream-kasan-gce-smack-root
2018/10/18 21:02 upstream fa520c47eaa1 9aba67b5 .config console log report ci-upstream-kasan-gce-smack-root
2018/10/15 04:58 upstream 3a27203102eb caf12900 .config console log report ci-upstream-kasan-gce-root
2018/10/08 16:09 upstream 0854ba5ff5c9 8b311eaf .config console log report ci-upstream-kasan-gce-root
2018/10/07 20:57 upstream fb1c592cf4c9 8b311eaf .config console log report ci-upstream-kasan-gce-smack-root
2018/10/07 02:40 upstream c1d84a1b42ef 8b311eaf .config console log report ci-upstream-kasan-gce-selinux-root
2018/10/06 00:27 upstream b2e45b46d85b 8b311eaf .config console log report ci-upstream-kasan-gce-root
2018/10/05 07:54 upstream befad944e231 8b311eaf .config console log report ci-upstream-kasan-gce-smack-root
2018/10/05 00:01 upstream 10be83cc6418 8b311eaf .config console log report ci-upstream-kasan-gce-smack-root
2018/10/04 00:14 upstream 6bebe37927f3 8b311eaf .config console log report ci-upstream-kasan-gce-selinux-root
2018/10/03 06:14 upstream 1d2ba7fee28b 0f3e0261 .config console log report ci-upstream-kasan-gce-smack-root
2018/09/28 04:23 upstream c127e59bee3e 0c2fa87b .config console log report ci-upstream-kasan-gce-selinux-root
2018/09/25 02:54 upstream 02214bfc89c7 0e7547d7 .config console log report ci-upstream-kasan-gce
2018/09/14 05:37 upstream 1d176582c795 19e9088b .config console log report ci-upstream-kasan-gce-smack-root
2018/09/12 04:35 upstream 5e335542de83 3c88136c .config console log report ci-upstream-kasan-gce-smack-root
2018/09/12 03:14 upstream 5e335542de83 4ae17b1f .config console log report ci-upstream-kasan-gce-smack-root
2018/09/09 15:33 upstream f8f65382c98a 6b5120a4 .config console log report ci-upstream-kasan-gce-smack-root
2018/09/09 02:32 upstream d7b686ebf704 6b5120a4 .config console log report ci-upstream-kasan-gce-root
2018/09/05 13:21 upstream 28619527b8a7 196410e4 .config console log report ci-upstream-kasan-gce-selinux-root
2018/08/19 21:48 upstream 08b5fa819970 2dc4378f .config console log report ci-upstream-kasan-gce-root
2018/08/17 22:00 upstream edb0a2000936 738da825 .config console log report ci-upstream-kasan-gce-root
2018/07/08 21:17 upstream b2d44d145d2a f25e5770 .config console log report ci-upstream-kasan-gce-root
2018/07/15 10:39 upstream c31496dbacc2 92a49505 .config console log report ci-upstream-kasan-gce-386
2018/11/24 09:00 linux-next 442b8cea2477 ecc7c870 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/11/04 16:26 linux-next 25e9471b6a27 8bd6bd63 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/16 04:00 linux-next ca0591d03a2d 8cd30605 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/10 04:15 linux-next 570b7bdeaf18 8b311eaf .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/06 13:45 linux-next 12ffaa1197f5 8b311eaf .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/30 11:56 linux-next 4794a36bf08d 41e4b329 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/26 00:33 linux-next 8b7a6ebdd4a5 b7e11289 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/24 04:42 linux-next 46c163a036b4 28d9ac76 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/21 05:50 linux-next a0cb0cabe4bb 6cee973c .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/11 04:30 linux-next f2b6e66e9885 8c88323f .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/08 16:06 linux-next f2b6e66e9885 6b5120a4 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/05 17:57 linux-next f2b6e66e9885 196410e4 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/04 05:08 linux-next f2b6e66e9885 a4718693 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/01 09:21 linux-next a880148cb2af a4718693 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/08/22 02:01 linux-next b0d11efd08e3 95b5c82b .config console log report ci-upstream-linux-next-kasan-gce-root
2018/08/21 00:57 linux-next 812667578394 95b5c82b .config console log report ci-upstream-linux-next-kasan-gce-root
2018/08/18 01:56 linux-next d7857ae43dcc 738da825 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.