syzbot


KASAN: use-after-free Read in finish_wait

Status: fixed on 2018/07/09 18:05
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+e80e13fc7c6ecb3cc4df@syzkaller.appspotmail.com
Fix commit: 66e58e0ef80a bpfilter: fix race in pipe access
First crash: 2314d, last: 2311d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in finish_wait (2) net 1 2261d 2261d 0/28 auto-closed as invalid on 2019/02/22 10:29
upstream KASAN: use-after-free Read in finish_wait (3) usb input 1 1878d 1878d 0/28 closed as invalid on 2019/08/19 12:27

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3888/0x5140 kernel/locking/lockdep.c:3314
Read of size 8 at addr ffff8801cda6e158 by task syz-executor4/4585

CPU: 1 PID: 4585 Comm: syz-executor4 Not tainted 4.17.0+ #93
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+0x1b9/0x294 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
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __lock_acquire+0x3888/0x5140 kernel/locking/lockdep.c:3314
 lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3924
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
 finish_wait+0x116/0x420 kernel/sched/wait.c:364
 pipe_wait+0x1b4/0x2a0 fs/pipe.c:117
 pipe_read+0x37c/0x940 fs/pipe.c:333
 call_read_iter include/linux/fs.h:1787 [inline]
 new_sync_read fs/read_write.c:406 [inline]
 __vfs_read+0x6c0/0xa60 fs/read_write.c:418
 vfs_read+0x17f/0x3d0 fs/read_write.c:452
 kernel_read+0xab/0x120 fs/read_write.c:431
 __bpfilter_process_sockopt+0x238/0x35b net/bpfilter/bpfilter_kern.c:74
 bpfilter_mbox_request+0x4d/0xb0 net/ipv4/bpfilter/sockopt.c:25
 bpfilter_ip_get_sockopt+0x6b/0x90 net/ipv4/bpfilter/sockopt.c:42
 ip_getsockopt+0x238/0x2a0 net/ipv4/ip_sockglue.c:1563
 tcp_getsockopt+0x93/0xe0 net/ipv4/tcp.c:3532
 sock_common_getsockopt+0x9a/0xe0 net/core/sock.c:3012
 __sys_getsockopt+0x1a5/0x370 net/socket.c:1972
 __do_sys_getsockopt net/socket.c:1983 [inline]
 __se_sys_getsockopt net/socket.c:1980 [inline]
 __x64_sys_getsockopt+0xbe/0x150 net/socket.c:1980
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4584ea
Code: b8 34 01 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 1d 8f fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 37 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 fa 8e fb ff c3 66 0f 1f 84 00 00 00 00 00 
RSP: 002b:0000000000a3e328 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
RAX: ffffffffffffffda RBX: 0000000000a3e350 RCX: 00000000004584ea
RDX: 0000000000000040 RSI: 0000000000000000 RDI: 0000000000000013
RBP: 0000000000706f20 R08: 0000000000a3e34c R09: 0000000000004000
R10: 0000000000a3e350 R11: 0000000000000246 R12: 0000000000000013
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000704d60

Allocated by task 2223:
 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:706 [inline]
 alloc_pipe_info+0x16d/0x580 fs/pipe.c:636
 get_pipe_inode fs/pipe.c:715 [inline]
 create_pipe_files+0xd0/0x940 fs/pipe.c:748
 umh_pipe_setup+0x17b/0x430 kernel/umh.c:442
 call_usermodehelper_exec_async+0x3c0/0x9e0 kernel/umh.c:93
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412

Freed by task 2223:
 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
 free_pipe_info+0x253/0x300 fs/pipe.c:687
 put_pipe_info+0xd0/0xf0 fs/pipe.c:559
 pipe_release+0x1de/0x270 fs/pipe.c:580
 __fput+0x353/0x890 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x1e4/0x290 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x1aee/0x2730 kernel/exit.c:865
 do_group_exit+0x16f/0x430 kernel/exit.c:968
 get_signal+0x886/0x1960 kernel/signal.c:2478
 do_signal+0x98/0x2040 arch/x86/kernel/signal.c:810
 exit_to_usermode_loop+0x28a/0x310 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:265 [inline]
 do_syscall_64+0x6ac/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801cda6e0c0
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 152 bytes inside of
 512-byte region [ffff8801cda6e0c0, ffff8801cda6e2c0)
The buggy address belongs to the page:
page:ffffea0007369b80 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea00075ab1c8 ffffea0007637748 ffff8801da800940
raw: 0000000000000000 ffff8801cda6e0c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cda6e000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801cda6e080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801cda6e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8801cda6e180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801cda6e200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/06/10 04:24 upstream a16afaf7928b 866118af .config console log report ci-upstream-kasan-gce
2018/06/10 09:45 upstream a16afaf7928b 866118af .config console log report ci-upstream-kasan-gce-386
2018/06/10 09:31 upstream a16afaf7928b 866118af .config console log report ci-upstream-kasan-gce-386
2018/06/09 10:19 net-next-old 3a979e8c07e3 866118af .config console log report ci-upstream-net-kasan-gce
2018/06/09 06:55 net-next-old 3a979e8c07e3 866118af .config console log report ci-upstream-net-kasan-gce
2018/06/08 11:34 net-next-old 3a979e8c07e3 f7b27b7a .config console log report ci-upstream-net-kasan-gce
2018/06/07 18:45 net-next-old 7170e6045a6a 645e75f8 .config console log report ci-upstream-net-kasan-gce
2018/06/07 14:01 net-next-old 7170e6045a6a 645e75f8 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.