syzbot


KASAN: use-after-free Read in ep_scan_ready_list

Status: fixed on 2019/11/20 22:01
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+78b902c73c69102cb767@syzkaller.appspotmail.com
Fix commit: 430ac66eb4c5 net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree()
First crash: 2345d, last: 2310d
Fix bisection: fixed by (bisect log) :
commit 430ac66eb4c5b5c4eb846b78ebf65747510b30f1
Author: Tomas Bortoli <tomasbortoli@gmail.com>
Date: Fri Jul 20 09:27:30 2018 +0000

  net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree()

  
Discussions (3)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in ep_scan_ready_list 0 (2) 2019/11/08 18:53
Reminder: 18 open syzbot bugs in "fs/9p" subsystem 1 (1) 2019/07/24 01:46
Reminder: 18 open syzbot bugs in "fs/9p" subsystem 1 (1) 2019/07/02 06:29

Sample crash report:
random: sshd: uninitialized urandom read (32 bytes read)
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:47 [inline]
BUG: KASAN: use-after-free in __mutex_trylock_or_owner kernel/locking/mutex.c:84 [inline]
BUG: KASAN: use-after-free in __mutex_trylock kernel/locking/mutex.c:125 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:927 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0x185/0x1680 kernel/locking/mutex.c:1073
Read of size 8 at addr ffff8801c62d85b8 by task kworker/0:2/2137

CPU: 0 PID: 2137 Comm: kworker/0:2 Not tainted 4.18.0-rc4-next-20180711+ #4
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events p9_poll_workfn
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/0x30d 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_read+0x11/0x20 mm/kasan/kasan.c:272
 atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline]
 atomic_long_read include/asm-generic/atomic-long.h:47 [inline]
 __mutex_trylock_or_owner kernel/locking/mutex.c:84 [inline]
 __mutex_trylock kernel/locking/mutex.c:125 [inline]
 __mutex_lock_common kernel/locking/mutex.c:927 [inline]
 __mutex_lock+0x185/0x1680 kernel/locking/mutex.c:1073
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1088
 ep_scan_ready_list+0xb77/0xf50 fs/eventpoll.c:681
 ep_eventpoll_poll+0x192/0x200 fs/eventpoll.c:937
 vfs_poll include/linux/poll.h:86 [inline]
 p9_fd_poll+0x1ce/0x2b0 net/9p/trans_fd.c:248
 p9_poll_mux net/9p/trans_fd.c:617 [inline]
 p9_poll_workfn+0x463/0x6d0 net/9p/trans_fd.c:1107
 process_one_work+0xc73/0x1ba0 kernel/workqueue.c:2153
 worker_thread+0x189/0x13c0 kernel/workqueue.c:2296
 kthread+0x345/0x410 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415

Allocated by task 4472:
 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
 kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
 kmalloc include/linux/slab.h:513 [inline]
 kzalloc include/linux/slab.h:707 [inline]
 ep_alloc fs/eventpoll.c:1016 [inline]
 do_epoll_create+0x170/0x5c0 fs/eventpoll.c:1952
 __do_sys_epoll_create1 fs/eventpoll.c:1983 [inline]
 __se_sys_epoll_create1 fs/eventpoll.c:1981 [inline]
 __x64_sys_epoll_create1+0x31/0x40 fs/eventpoll.c:1981
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4472:
 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]
 kfree+0xd9/0x260 mm/slab.c:3813
 ep_free+0x273/0x310 fs/eventpoll.c:856
 ep_eventpoll_release+0x44/0x60 fs/eventpoll.c:864
 __fput+0x35d/0x930 fs/file_table.c:252
 ____fput+0x15/0x20 fs/file_table.c:288
 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:869
 do_group_exit+0x177/0x440 kernel/exit.c:972
 get_signal+0x88e/0x1970 kernel/signal.c:2467
 do_signal+0x9c/0x21c0 arch/x86/kernel/signal.c:816
 exit_to_usermode_loop+0x2e5/0x380 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801c62d8580
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 56 bytes inside of
 512-byte region [ffff8801c62d8580, ffff8801c62d8780)
The buggy address belongs to the page:
page:ffffea000718b600 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0006b54dc8 ffffea000764a188 ffff8801da800940
raw: 0000000000000000 ffff8801c62d8080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801c62d8480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801c62d8500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801c62d8580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff8801c62d8600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801c62d8680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (39):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/07/11 13:05 linux-next 98be45067040 2e0e3130 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/07/11 13:36 upstream 1e09177acae3 2e0e3130 .config console log report syz ci-upstream-kasan-gce-386
2018/08/15 20:55 upstream 31130a16d459 9ccc1d45 .config console log report ci-upstream-kasan-gce-root
2018/08/12 16:32 upstream ec0c96714e7d 7a88b141 .config console log report ci-upstream-kasan-gce-root
2018/08/12 15:03 upstream ec0c96714e7d 7a88b141 .config console log report ci-upstream-kasan-gce-root
2018/08/12 09:57 upstream ec0c96714e7d 7a88b141 .config console log report ci-upstream-kasan-gce-root
2018/08/10 20:20 upstream f313b43be461 1fb62d58 .config console log report ci-upstream-kasan-gce-root
2018/08/08 21:38 upstream fedb8da96355 2eeda842 .config console log report ci-upstream-kasan-gce-root
2018/08/07 21:58 upstream 1236568ee3cb 1beb8136 .config console log report ci-upstream-kasan-gce-root
2018/08/07 10:47 upstream 1236568ee3cb 1beb8136 .config console log report ci-upstream-kasan-gce-root
2018/08/05 21:20 upstream a8c199208cd6 1beb8136 .config console log report ci-upstream-kasan-gce-root
2018/08/05 17:43 upstream a8c199208cd6 1beb8136 .config console log report ci-upstream-kasan-gce-root
2018/08/04 13:12 upstream 0b5b1f9a78b5 df7f6947 .config console log report ci-upstream-kasan-gce-root
2018/08/04 04:47 upstream 0b5b1f9a78b5 df7f6947 .config console log report ci-upstream-kasan-gce-root
2018/08/03 22:14 upstream 0585df468e8f cc4f6d0a .config console log report ci-upstream-kasan-gce-root
2018/08/03 14:24 upstream 0585df468e8f cc4f6d0a .config console log report ci-upstream-kasan-gce-root
2018/08/03 00:11 upstream e30cb13c5a09 5b7e23bb .config console log report ci-upstream-kasan-gce-root
2018/08/02 03:15 upstream 44960f2a7b63 0a7cf4ec .config console log report ci-upstream-kasan-gce-root
2018/08/01 18:31 upstream 44960f2a7b63 0a7cf4ec .config console log report ci-upstream-kasan-gce-root
2018/08/01 15:37 upstream c1d61e7fe376 1477993e .config console log report ci-upstream-kasan-gce-root
2018/08/01 12:04 upstream c1d61e7fe376 1477993e .config console log report ci-upstream-kasan-gce-root
2018/07/30 08:12 upstream 3cfb6772d4cf 1a381291 .config console log report ci-upstream-kasan-gce-root
2018/07/11 19:35 upstream 1e09177acae3 2e0e3130 .config console log report ci-upstream-kasan-gce-root
2018/07/11 06:59 upstream 30c2c32d7f70 2e0e3130 .config console log report ci-upstream-kasan-gce
2018/07/11 06:59 upstream 30c2c32d7f70 2e0e3130 .config console log report ci-upstream-kasan-gce-root
2018/07/12 07:36 upstream c25c74b7476e 2e0e3130 .config console log report ci-upstream-kasan-gce-386
2018/07/11 23:36 upstream c25c74b7476e 2e0e3130 .config console log report ci-upstream-kasan-gce-386
2018/07/11 19:50 upstream 1e09177acae3 2e0e3130 .config console log report ci-upstream-kasan-gce-386
2018/07/11 18:58 upstream 1e09177acae3 2e0e3130 .config console log report ci-upstream-kasan-gce-386
2018/07/11 17:06 upstream 1e09177acae3 2e0e3130 .config console log report ci-upstream-kasan-gce-386
2018/07/12 05:17 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 23:54 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 22:27 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 22:27 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 19:24 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 13:14 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 11:35 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 07:11 linux-next 98be45067040 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/07/11 07:00 linux-next 3951bd9fe3e2 2e0e3130 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.