KASAN: use-after-free Read in sk_psock_unlink

22 views
Skip to first unread message

syzbot

unread,
Oct 26, 2018, 3:37:02 AM10/26/18
to dan...@iogearbox.net, da...@davemloft.net, john.fa...@gmail.com, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 8c60c36d0b8c Add linux-next specific files for 20181019
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17356dbd400000
kernel config: https://syzkaller.appspot.com/x/.config?x=8b6d7c4c81535e89
dashboard link: https://syzkaller.appspot.com/bug?extid=3acd9f67a6a15766686e
compiler: gcc (GCC) 8.0.1 20180413 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

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

EXT4-fs (loop5): couldn't mount RDWR because of unsupported optional
features (80)
EXT4-fs (loop5): couldn't mount RDWR because of unsupported optional
features (80)
input: as /devices/virtual/input/input21
==================================================================
BUG: KASAN: use-after-free in sk_psock_unlink+0x4d8/0x700
net/core/sock_map.c:992
Read of size 4 at addr ffff8801b7fc1018 by task syz-executor4/21409

CPU: 0 PID: 21409 Comm: syz-executor4 Not tainted 4.19.0-rc8-next-20181019+
#98
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+0x244/0x39d lib/dump_stack.c:113
print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
sk_psock_unlink+0x4d8/0x700 net/core/sock_map.c:992
tcp_bpf_remove+0xd0/0x130 net/ipv4/tcp_bpf.c:511
tcp_bpf_close+0x1c6/0x4a0 net/ipv4/tcp_bpf.c:551
inet_release+0x104/0x1f0 net/ipv4/af_inet.c:428
__sock_release+0xd7/0x250 net/socket.c:580
sock_close+0x19/0x20 net/socket.c:1142
__fput+0x3bc/0xa70 fs/file_table.c:279
____fput+0x15/0x20 fs/file_table.c:312
task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
get_signal+0x1550/0x1970 kernel/signal.c:2347
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
RIP: 0033:0x457569
Code: fd b3 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 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fd88965ec78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: 0000000000280000 RBX: 0000000000000006 RCX: 0000000000457569
RDX: fffffffffffffe6e RSI: 0000000020a88f88 RDI: 0000000000000003
RBP: 000000000072bf00 R08: 0000000020e68000 R09: 0000000000000010
R10: 0000000020000000 R11: 0000000000000246 R12: 00007fd88965f6d4
R13: 00000000004c3915 R14: 00000000004d57c0 R15: 00000000ffffffff

Allocated by task 21423:
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:546 [inline]
kzalloc include/linux/slab.h:741 [inline]
sock_hash_alloc+0x1eb/0x5a0 net/core/sock_map.c:801
find_and_alloc_map kernel/bpf/syscall.c:129 [inline]
map_create+0x3bd/0x1100 kernel/bpf/syscall.c:509
__do_sys_bpf kernel/bpf/syscall.c:2394 [inline]
__se_sys_bpf kernel/bpf/syscall.c:2371 [inline]
__x64_sys_bpf+0x303/0x510 kernel/bpf/syscall.c:2371
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10109:
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:3817
sock_hash_free+0x450/0x640 net/core/sock_map.c:864
bpf_map_free_deferred+0xd9/0x110 kernel/bpf/syscall.c:290
process_one_work+0xc8b/0x1c40 kernel/workqueue.c:2153
worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
kthread+0x35a/0x440 kernel/kthread.c:246
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8801b7fc1000
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 24 bytes inside of
512-byte region [ffff8801b7fc1000, ffff8801b7fc1200)
The buggy address belongs to the page:
page:ffffea0006dff040 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea0006ee5888 ffffea00071fc6c8 ffff8801da800940
raw: 0000000000000000 ffff8801b7fc1000 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801b7fc0f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8801b7fc0f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> ffff8801b7fc1000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801b7fc1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801b7fc1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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#bug-status-tracking for how to communicate with
syzbot.

syzbot

unread,
May 22, 2019, 10:45:07 AM5/22/19
to a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, john.fa...@gmail.com, ka...@fb.com, linux-...@vger.kernel.org, net...@vger.kernel.org, songliu...@fb.com, syzkall...@googlegroups.com, y...@fb.com
syzbot has found a reproducer for the following crash on:

HEAD commit: f49aa1de Merge tag 'for-5.2-rc1-tag' of git://git.kernel.o..
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17279a52a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=fc045131472947d7
dashboard link: https://syzkaller.appspot.com/bug?extid=3acd9f67a6a15766686e
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13adf56ca00000

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

==================================================================
BUG: KASAN: use-after-free in sock_hash_delete_from_link
net/core/sock_map.c:585 [inline]
BUG: KASAN: use-after-free in sk_psock_unlink+0x443/0x4b0
net/core/sock_map.c:998
Read of size 8 at addr ffff88808b760600 by task syz-executor.5/26193

CPU: 1 PID: 26193 Comm: syz-executor.5 Not tainted 5.2.0-rc1+ #1
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:188
__kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
kasan_report+0x12/0x20 mm/kasan/common.c:614
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
sock_hash_delete_from_link net/core/sock_map.c:585 [inline]
sk_psock_unlink+0x443/0x4b0 net/core/sock_map.c:998
tcp_bpf_remove+0x21/0x50 net/ipv4/tcp_bpf.c:535
tcp_bpf_close+0x130/0x390 net/ipv4/tcp_bpf.c:575
inet_release+0xff/0x1e0 net/ipv4/af_inet.c:432
inet6_release+0x53/0x80 net/ipv6/af_inet6.c:474
__sock_release+0xce/0x2a0 net/socket.c:607
sock_close+0x1b/0x30 net/socket.c:1279
__fput+0x2ff/0x890 fs/file_table.c:279
____fput+0x16/0x20 fs/file_table.c:312
task_work_run+0x145/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:188 [inline]
exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:168
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
do_syscall_64+0x58e/0x680 arch/x86/entry/common.c:304
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x412f61
Code: 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 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48
89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007ffdbbd18870 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000412f61
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 0000000000000000 R08: ffffffffffffffff R09: ffffffffffffffff
R10: 00007ffdbbd18950 R11: 0000000000000293 R12: 00000000007610a8
R13: 0000000000036769 R14: 0000000000036796 R15: 000000000075bfcc

Allocated by task 26195:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_kmalloc mm/kasan/common.c:489 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
kmem_cache_alloc_trace+0x151/0x750 mm/slab.c:3555
kmalloc include/linux/slab.h:547 [inline]
kzalloc include/linux/slab.h:742 [inline]
sock_hash_alloc net/core/sock_map.c:802 [inline]
sock_hash_alloc+0x1e3/0x5b0 net/core/sock_map.c:786
find_and_alloc_map kernel/bpf/syscall.c:129 [inline]
map_create kernel/bpf/syscall.c:570 [inline]
__do_sys_bpf+0x730/0x43d0 kernel/bpf/syscall.c:2795
__se_sys_bpf kernel/bpf/syscall.c:2772 [inline]
__x64_sys_bpf+0x73/0xb0 kernel/bpf/syscall.c:2772
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8823:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
__cache_free mm/slab.c:3432 [inline]
kfree+0xcf/0x220 mm/slab.c:3755
sock_hash_free+0x327/0x4a0 net/core/sock_map.c:865
bpf_map_free_deferred+0xb4/0xe0 kernel/bpf/syscall.c:310
process_one_work+0x989/0x1790 kernel/workqueue.c:2268
worker_thread+0x98/0xe40 kernel/workqueue.c:2414
kthread+0x354/0x420 kernel/kthread.c:254
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff88808b760500
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 256 bytes inside of
512-byte region [ffff88808b760500, ffff88808b760700)
The buggy address belongs to the page:
page:ffffea00022dd800 refcount:1 mapcount:0 mapping:ffff8880aa400940
index:0xffff88808b760a00
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00029e2508 ffffea00023ff008 ffff8880aa400940
raw: ffff88808b760a00 ffff88808b760000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808b760500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808b760580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff88808b760600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808b760680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808b760700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
May 22, 2019, 5:49:01 PM5/22/19
to a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, john.fa...@gmail.com, ka...@fb.com, linux-...@vger.kernel.org, net...@vger.kernel.org, songliu...@fb.com, syzkall...@googlegroups.com, torv...@linux-foundation.org, y...@fb.com
syzbot has bisected this bug to:

commit 48a3c64b4649b5b23a4ca756af93b4ee820ff883
Author: Linus Torvalds <torv...@linux-foundation.org>
Date: Fri Jun 29 14:11:03 2018 +0000

Merge tag 'drm-fixes-2018-06-29' of
git://anongit.freedesktop.org/drm/drm

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11f92d6ca00000
start commit: f49aa1de Merge tag 'for-5.2-rc1-tag' of git://git.kernel.o..
git tree: net-next
final crash: https://syzkaller.appspot.com/x/report.txt?x=13f92d6ca00000
console output: https://syzkaller.appspot.com/x/log.txt?x=15f92d6ca00000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13adf56ca00000

Reported-by: syzbot+3acd9f...@syzkaller.appspotmail.com
Fixes: 48a3c64b4649 ("Merge tag 'drm-fixes-2018-06-29' of
git://anongit.freedesktop.org/drm/drm")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Linus Torvalds

unread,
May 22, 2019, 6:58:47 PM5/22/19
to syzbot, Alexei Starovoitov, b...@vger.kernel.org, Daniel Borkmann, David Miller, john.fa...@gmail.com, ka...@fb.com, Linux List Kernel Mailing, Netdev, songliu...@fb.com, syzkaller-bugs, y...@fb.com
On Wed, May 22, 2019 at 2:49 PM syzbot
<syzbot+3acd9f...@syzkaller.appspotmail.com> wrote:
>
> syzbot has bisected this bug to:
>
> commit 48a3c64b4649 ("Merge tag 'drm-fixes-2018-06-29' of git://anongit.freedesktop.org/drm/drm")

That looks very unlikely indeed. I strongly suspect your bisection is broken.

Looking at the bisection log, the problem sometimes happens only once
out of the ten tries. Presumably it then happened zero times a couple
of times, and the bisection went off into the weeds.

Any possibility of re-doing the bisection (the ones marked "bad" are
clearly bad, so you don't need to redo it _all_) with many more runs
for each test point?

Linus

syzbot

unread,
Apr 12, 2023, 7:58:35 PM4/12/23
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages