syzbot


KASAN: use-after-free Read in bpf_tcp_close (2)

Status: auto-closed as invalid on 2019/03/23 04:55
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+579adfa56843da894bc5@syzkaller.appspotmail.com
First crash: 2030d, last: 2012d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in bpf_tcp_close (2) 2 (3) 2019/03/23 07:24
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in bpf_tcp_close bpf C 1748 2094d 2133d 8/26 fixed on 2018/07/09 18:05

Sample crash report:
PF_BRIDGE: br_mdb_parse() with unknown ifindex
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x37c2/0x4ec0 kernel/locking/lockdep.c:3290
Read of size 8 at addr ffff8801d83366f8 by task syz-executor1/7197

CPU: 1 PID: 7197 Comm: syz-executor1 Not tainted 4.19.0-rc5+ #28
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+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __lock_acquire+0x37c2/0x4ec0 kernel/locking/lockdep.c:3290
 lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3900
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168
 bpf_tcp_close+0x670/0x10c0 kernel/bpf/sockmap.c:349
 inet_release+0x104/0x1f0 net/ipv4/af_inet.c:428
 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:457
 __sock_release+0xd7/0x250 net/socket.c:579
 sock_close+0x19/0x20 net/socket.c:1141
 __fput+0x385/0xa30 fs/file_table.c:278
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 get_signal+0x155e/0x1980 kernel/signal.c:2343
 do_signal+0x9c/0x21e0 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
RIP: 0033:0x457679
Code: 1d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 eb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f66e788cc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002f
RAX: 0000000000000000 RBX: 00007f66e788d6d4 RCX: 0000000000457679
RDX: 0000000000000000 RSI: 0000000020000540 RDI: 0000000000000006
RBP: 000000000072bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000004d4fa8 R14: 00000000004c336a R15: 0000000000000001

Allocated by task 7202:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:513 [inline]
 kzalloc include/linux/slab.h:707 [inline]
 sock_map_alloc+0x209/0x430 kernel/bpf/sockmap.c:1653
 find_and_alloc_map kernel/bpf/syscall.c:130 [inline]
 map_create+0x3bd/0x10f0 kernel/bpf/syscall.c:510
 __do_sys_bpf kernel/bpf/syscall.c:2357 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2334 [inline]
 __x64_sys_bpf+0x303/0x510 kernel/bpf/syscall.c:2334
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 5680:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 sock_map_remove_complete kernel/bpf/sockmap.c:1561 [inline]
 sock_map_free+0x424/0x570 kernel/bpf/sockmap.c:1756
 bpf_map_free_deferred+0xba/0xf0 kernel/bpf/syscall.c:291
 process_one_work+0xc90/0x1b90 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x420 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:413

The buggy address belongs to the object at ffff8801d83365c0
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 312 bytes inside of
 512-byte region [ffff8801d83365c0, ffff8801d83367c0)
The buggy address belongs to the page:
page:ffffea000760cd80 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0007637048 ffffea0007607b88 ffff8801da800940
raw: 0000000000000000 ffff8801d83360c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d8336580: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8801d8336600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801d8336680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff8801d8336700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8336780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/09/24 04:54 upstream 6bf4ca7fbc85 28d9ac76 .config console log report ci-upstream-kasan-gce-smack-root
2018/09/22 07:49 upstream 10dc890d4228 37079712 .config console log report ci-upstream-kasan-gce-root
2018/09/06 00:31 bpf-next 11f026b4e306 873745f2 .config console log report ci-upstream-bpf-next-kasan-gce
2018/09/23 04:33 linux-next 46c163a036b4 37079712 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.