syzbot


KASAN: use-after-free Read in pipe_read

Status: fixed on 2018/07/09 18:05
Subsystems: fs
[Documentation on labels]
Fix commit: 66e58e0ef80a bpfilter: fix race in pipe access
First crash: 2209d, last: 2207d

Sample crash report:
bpfilter: read fail -512
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3888/0x5140 kernel/locking/lockdep.c:3310
Read of size 8 at addr ffff8801d205ed20 by task syz-executor396/11405

CPU: 0 PID: 11405 Comm: syz-executor396 Not tainted 4.17.0-rc7+ #82
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:3310
 lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0x16d/0x17f0 kernel/locking/mutex.c:893
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
 __pipe_lock fs/pipe.c:83 [inline]
 pipe_read+0xc9/0x940 fs/pipe.c:260
 call_read_iter include/linux/fs.h:1778 [inline]
 new_sync_read fs/read_write.c:406 [inline]
 __vfs_read+0x696/0xa50 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
 sctp_getsockopt+0x466/0x7b4b net/sctp/socket.c:7216
 sock_common_getsockopt+0x9a/0xe0 net/core/sock.c:3018
 __sys_getsockopt+0x1a5/0x370 net/socket.c:1940
 __do_sys_getsockopt net/socket.c:1951 [inline]
 __se_sys_getsockopt net/socket.c:1948 [inline]
 __x64_sys_getsockopt+0xbe/0x150 net/socket.c:1948
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4481d9
RSP: 002b:00007f547ee51ce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
RAX: ffffffffffffffda RBX: 00000000006dec64 RCX: 00000000004481d9
RDX: 0000000000000043 RSI: 0000000000000000 RDI: 0000000000000006
RBP: 00000000006dec60 R08: 0000000020000040 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe5333e01f R14: 00007f547ee529c0 R15: 0000000000000008

Allocated by task 2200:
 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:512 [inline]
 kzalloc include/linux/slab.h:701 [inline]
 alloc_pipe_info+0x16d/0x580 fs/pipe.c:633
 get_pipe_inode fs/pipe.c:712 [inline]
 create_pipe_files+0xd0/0x940 fs/pipe.c:745
 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 2200:
 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:684
 put_pipe_info+0xd0/0xf0 fs/pipe.c:556
 pipe_release+0x1de/0x270 fs/pipe.c:577
 __fput+0x34d/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
 __do_sys_exit_group kernel/exit.c:979 [inline]
 __se_sys_exit_group kernel/exit.c:977 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:977
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d205ecc0
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 96 bytes inside of
 512-byte region [ffff8801d205ecc0, ffff8801d205eec0)
The buggy address belongs to the page:
page:ffffea0007481780 count:1 mapcount:0 mapping:ffff8801d205e040 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801d205e040 0000000000000000 0000000100000006
raw: ffffea0007353920 ffffea0007351ea0 ffff8801da800940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d205ec00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8801d205ec80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801d205ed00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8801d205ed80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d205ee00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/06/07 23:29 net-next-old 7170e6045a6a 645e75f8 .config console log report syz C ci-upstream-net-kasan-gce
2018/06/08 07:01 upstream 68abbe729567 f7b27b7a .config console log report ci-upstream-kasan-gce-386
2018/06/09 06:07 net-next-old 3a979e8c07e3 866118af .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.