KASAN: use-after-free Read in bpf_tcp_remove

7 views
Skip to first unread message

syzbot

unread,
Jun 8, 2019, 9:18:05 PM6/8/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: e109a984 Linux 4.19.48
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17bc7e92a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=2d14dd88554f26bc
dashboard link: https://syzkaller.appspot.com/bug?extid=faa4eda7d7f7cfa5a2de
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15a1292ea00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+faa4ed...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x33b2/0x48f0
kernel/locking/lockdep.c:3290
Read of size 8 at addr ffff8880a669ddf8 by task syz-executor.1/21922

CPU: 1 PID: 21922 Comm: syz-executor.1 Not tainted 4.19.48 #20
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+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report mm/kasan/report.c:412 [inline]
kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
__lock_acquire+0x33b2/0x48f0 kernel/locking/lockdep.c:3290
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
_raw_spin_lock_bh+0x33/0x50 kernel/locking/spinlock.c:168
bpf_tcp_remove+0x42a/0xa20 kernel/bpf/sockmap.c:335
bpf_tcp_close+0x130/0x390 kernel/bpf/sockmap.c:403
inet_release+0xff/0x1e0 net/ipv4/af_inet.c:428
inet6_release+0x53/0x80 net/ipv6/af_inet6.c:472
__sock_release+0xce/0x2a0 net/socket.c:579
sock_close+0x1b/0x30 net/socket.c:1140
__fput+0x2dd/0x8b0 fs/file_table.c:278
____fput+0x16/0x20 fs/file_table.c:309
task_work_run+0x145/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x53d/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x412f40
Code: 01 f0 ff ff 0f 83 30 1b 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f
44 00 00 83 3d 4d 33 66 00 00 75 14 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff
ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff
RSP: 002b:00007ffc7290c418 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000412f40
RDX: 0000001b2e020000 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffff
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000007610a8
R13: 0000000000000003 R14: 0000000000000000 R15: 000000000075bf2c

Allocated by task 21922:
save_stack+0x45/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc mm/kasan/kasan.c:553 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
sock_map_alloc kernel/bpf/sockmap.c:1675 [inline]
sock_map_alloc+0x203/0x430 kernel/bpf/sockmap.c:1657
find_and_alloc_map kernel/bpf/syscall.c:130 [inline]
map_create+0x372/0xe90 kernel/bpf/syscall.c:510
__do_sys_bpf kernel/bpf/syscall.c:2382 [inline]
__se_sys_bpf kernel/bpf/syscall.c:2359 [inline]
__x64_sys_bpf+0x2c2/0x4c0 kernel/bpf/syscall.c:2359
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10530:
save_stack+0x45/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:3503 [inline]
kfree+0xcf/0x220 mm/slab.c:3822
sock_map_remove_complete kernel/bpf/sockmap.c:1583 [inline]
sock_map_free+0x345/0x440 kernel/bpf/sockmap.c:1778
bpf_map_free_deferred+0xb4/0xe0 kernel/bpf/syscall.c:291
process_one_work+0x989/0x1750 kernel/workqueue.c:2153
worker_thread+0x98/0xe40 kernel/workqueue.c:2296
kthread+0x354/0x420 kernel/kthread.c:246
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff8880a669dcc0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 312 bytes inside of
512-byte region [ffff8880a669dcc0, ffff8880a669dec0)
The buggy address belongs to the page:
page:ffffea000299a740 count:1 mapcount:0 mapping:ffff88812c3f0940
index:0xffff8880a669d040
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffffea0002816bc8 ffffea00024956c8 ffff88812c3f0940
raw: ffff8880a669d040 ffff8880a669d040 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a669dc80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8880a669dd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8880a669dd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a669de00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a669de80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Oct 15, 2022, 4:10:43 PM10/15/22
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13d18cc2880000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=faa4eda7d7f7cfa5a2de
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=120ef49a880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14c72d34880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/98c0bdb4abb3/disk-3f8a27f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea228ff02669/vmlinux-3f8a27f9.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+faa4ed...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x2cb4/0x3ff0 kernel/locking/lockdep.c:3295
Read of size 8 at addr ffff88809bb581f8 by task syz-executor347/12160

CPU: 0 PID: 12160 Comm: syz-executor347 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
__lock_acquire+0x2cb4/0x3ff0 kernel/locking/lockdep.c:3295
lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
_raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:168
bpf_tcp_remove+0x427/0xa00 kernel/bpf/sockmap.c:335
bpf_tcp_close+0x12b/0x390 kernel/bpf/sockmap.c:403
inet_release+0xd7/0x1e0 net/ipv4/af_inet.c:427
__sock_release+0xcd/0x2a0 net/socket.c:599
sock_close+0x15/0x20 net/socket.c:1214
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
exit_task_work include/linux/task_work.h:22 [inline]
do_exit+0xbf3/0x2be0 kernel/exit.c:870
do_group_exit+0x125/0x310 kernel/exit.c:967
__do_sys_exit_group kernel/exit.c:978 [inline]
__se_sys_exit_group kernel/exit.c:976 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7eff5089ec69
Code: 00 49 c7 c0 c0 ff ff ff be e7 00 00 00 ba 3c 00 00 00 eb 12 0f 1f 44 00 00 89 d0 0f 05 48 3d 00 f0 ff ff 77 1c f4 89 f0 0f 05 <48> 3d 00 f0 ff ff 76 e7 f7 d8 64 41 89 00 eb df 0f 1f 80 00 00 00
RSP: 002b:00007ffe684d9748 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007eff50913330 RCX: 00007eff5089ec69
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000246 R12: 00007eff50913330
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001

Allocated by task 12160:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
sock_map_alloc kernel/bpf/sockmap.c:1675 [inline]
sock_map_alloc+0x2b8/0x510 kernel/bpf/sockmap.c:1657
find_and_alloc_map kernel/bpf/syscall.c:130 [inline]
map_create kernel/bpf/syscall.c:510 [inline]
__do_sys_bpf kernel/bpf/syscall.c:2408 [inline]
__se_sys_bpf+0x82a/0x3a20 kernel/bpf/syscall.c:2384
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8140:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
process_one_work+0x864/0x1570 kernel/workqueue.c:2153
worker_thread+0x64c/0x1130 kernel/workqueue.c:2296
kthread+0x33f/0x460 kernel/kthread.c:259
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff88809bb580c0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 312 bytes inside of
512-byte region [ffff88809bb580c0, ffff88809bb582c0)
The buggy address belongs to the page:
page:ffffea00026ed600 count:1 mapcount:0 mapping:ffff88813bff0940 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea000270e808 ffffea00026f21c8 ffff88813bff0940
raw: 0000000000000000 ffff88809bb580c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809bb58080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff88809bb58100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809bb58180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809bb58200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809bb58280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Reply all
Reply to author
Forward
0 new messages