[syzbot] BUG: stack guard page was hit in inet6_release

13 views
Skip to first unread message

syzbot

unread,
Dec 6, 2022, 3:14:46 PM12/6/22
to b...@vger.kernel.org, da...@davemloft.net, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6a30d3e3491d selftests: net: Use "grep -E" instead of "egr..
git tree: net
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1576b11d880000
kernel config: https://syzkaller.appspot.com/x/.config?x=cc4b2e0a8e8a8366
dashboard link: https://syzkaller.appspot.com/bug?extid=04c21ed96d861dccc5cd
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14e1656b880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1077da23880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/bbee3d5fc908/disk-6a30d3e3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bf9e258de70e/vmlinux-6a30d3e3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/afaa6696b9e0/bzImage-6a30d3e3.xz

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

BUG: TASK stack guard page was hit at ffffc90003cd7fa8 (stack is ffffc90003cd8000..ffffc90003ce0000)
stack guard page: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 3636 Comm: syz-executor238 Not tainted 6.1.0-rc7-syzkaller-00135-g6a30d3e3491d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:mark_lock.part.0+0x26/0x1910 kernel/locking/lockdep.c:4593
Code: 00 00 00 00 41 57 41 56 41 55 41 89 d5 48 ba 00 00 00 00 00 fc ff df 41 54 49 89 f4 55 53 48 81 ec 38 01 00 00 48 8d 5c 24 38 <48> 89 3c 24 48 c7 44 24 38 b3 8a b5 41 48 c1 eb 03 48 c7 44 24 40
RSP: 0018:ffffc90003cd7fb8 EFLAGS: 00010096
RAX: 0000000000000004 RBX: ffffc90003cd7ff0 RCX: ffffffff8162a7bf
RDX: dffffc0000000000 RSI: ffff88801f65e238 RDI: ffff88801f65d7c0
RBP: ffff88801f65e25a R08: 0000000000000000 R09: ffffffff910f4aff
R10: fffffbfff221e95f R11: 0000000000000000 R12: ffff88801f65e238
R13: 0000000000000002 R14: 0000000000000000 R15: 0000000000040000
FS: 0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffc90003cd7fa8 CR3: 000000000c28e000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
mark_lock kernel/locking/lockdep.c:4598 [inline]
mark_usage kernel/locking/lockdep.c:4543 [inline]
__lock_acquire+0x847/0x56d0 kernel/locking/lockdep.c:5009
lock_acquire kernel/locking/lockdep.c:5668 [inline]
lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
lock_sock_nested+0x3a/0xf0 net/core/sock.c:3447
lock_sock include/net/sock.h:1721 [inline]
sock_map_close+0x75/0x7b0 net/core/sock_map.c:1610
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
sock_map_close+0x6dc/0x7b0 net/core/sock_map.c:1616
inet_release+0x132/0x270 net/ipv4/af_inet.c:428
inet6_release+0x50/0x70 net/ipv6/af_inet6.c:488
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x1c/0x20 net/socket.c:1365
__fput+0x27c/0xa90 fs/file_table.c:320
task_work_run+0x16f/0x270 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xb3d/0x2a30 kernel/exit.c:820
do_group_exit+0xd4/0x2a0 kernel/exit.c:950
get_signal+0x21b1/0x2440 kernel/signal.c:2858
arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f48595660b9
Code: Unable to access opcode bytes at 0x7f485956608f.
RSP: 002b:00007ffebff98f98 EFLAGS: 00000246 ORIG_RAX: 0000000000000120
RAX: 0000000000000007 RBX: 0000000000000000 RCX: 00007f48595660b9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000000 R08: 00007ffebff99138 R09: 00007ffebff99138
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4859529940
R13: 431bde82d7b634db R14: 0000000000000000 R15: 0000000000000000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:mark_lock.part.0+0x26/0x1910 kernel/locking/lockdep.c:4593
Code: 00 00 00 00 41 57 41 56 41 55 41 89 d5 48 ba 00 00 00 00 00 fc ff df 41 54 49 89 f4 55 53 48 81 ec 38 01 00 00 48 8d 5c 24 38 <48> 89 3c 24 48 c7 44 24 38 b3 8a b5 41 48 c1 eb 03 48 c7 44 24 40
RSP: 0018:ffffc90003cd7fb8 EFLAGS: 00010096
RAX: 0000000000000004 RBX: ffffc90003cd7ff0 RCX: ffffffff8162a7bf
RDX: dffffc0000000000 RSI: ffff88801f65e238 RDI: ffff88801f65d7c0
RBP: ffff88801f65e25a R08: 0000000000000000 R09: ffffffff910f4aff
R10: fffffbfff221e95f R11: 0000000000000000 R12: ffff88801f65e238
R13: 0000000000000002 R14: 0000000000000000 R15: 0000000000040000
FS: 0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffc90003cd7fa8 CR3: 000000000c28e000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 00 00 add %al,(%rax)
2: 00 00 add %al,(%rax)
4: 41 57 push %r15
6: 41 56 push %r14
8: 41 55 push %r13
a: 41 89 d5 mov %edx,%r13d
d: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
14: fc ff df
17: 41 54 push %r12
19: 49 89 f4 mov %rsi,%r12
1c: 55 push %rbp
1d: 53 push %rbx
1e: 48 81 ec 38 01 00 00 sub $0x138,%rsp
25: 48 8d 5c 24 38 lea 0x38(%rsp),%rbx
* 2a: 48 89 3c 24 mov %rdi,(%rsp) <-- trapping instruction
2e: 48 c7 44 24 38 b3 8a movq $0x41b58ab3,0x38(%rsp)
35: b5 41
37: 48 c1 eb 03 shr $0x3,%rbx
3b: 48 rex.W
3c: c7 .byte 0xc7
3d: 44 24 40 rex.R and $0x40,%al


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

John Fastabend

unread,
Dec 7, 2022, 1:38:25 AM12/7/22
to syzbot, b...@vger.kernel.org, da...@davemloft.net, edum...@google.com, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
I'll take a look likely something recent.

Eric Dumazet

unread,
Dec 7, 2022, 3:13:12 AM12/7/22
to John Fastabend, syzbot, b...@vger.kernel.org, da...@davemloft.net, ja...@cloudflare.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Fact that sock_map_close can call itself seems risky.
We might issue a one time warning and keep the host alive.

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 81beb16ab1ebfcb166f51f89a029fe1c28a629a4..a79771a6627b9b2f38ae6ce153ceff9e8c0be8d4
100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -1612,17 +1612,25 @@ void sock_map_close(struct sock *sk, long timeout)
psock = sk_psock_get(sk);
if (unlikely(!psock)) {
rcu_read_unlock();
+ saved_close = sk->sk_prot->close;
release_sock(sk);
- return sk->sk_prot->close(sk, timeout);
+ } else {
+ saved_close = psock->saved_close;
+ sock_map_remove_links(sk, psock);
+ rcu_read_unlock();
+ sk_psock_stop(psock);
+ release_sock(sk);
+ cancel_work_sync(&psock->work);
+ sk_psock_put(sk, psock);
+ }
+ /* Make sure we do not recurse to us.
+ * This is a bug, we can leak the socket instead
+ * of crashing on a stack overflow.
+ */
+ if (saved_close == sock_map_close) {
+ WARN_ON_ONCE(1);
+ return;
}
-
- saved_close = psock->saved_close;
- sock_map_remove_links(sk, psock);
- rcu_read_unlock();
- sk_psock_stop(psock);
- release_sock(sk);
- cancel_work_sync(&psock->work);
- sk_psock_put(sk, psock);
saved_close(sk, timeout);
}
EXPORT_SYMBOL_GPL(sock_map_close);

John Fastabend

unread,
Dec 8, 2022, 4:07:41 AM12/8/22
to Eric Dumazet, John Fastabend, syzbot, b...@vger.kernel.org, da...@davemloft.net, ja...@cloudflare.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Agree seems better to check the condition than loop on close.
I still need to figure out the bug that got into this state
though. Thanks.

Hillf Danton

unread,
Dec 11, 2022, 11:03:09 PM12/11/22
to John Fastabend, Eric Dumazet, syzbot, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
On 08 Dec 2022 01:07:36 -0800 John Fastabend <john.fa...@gmail.com>
Perhaps due to sock clone?
See another report [1] with the debug diff applied.

--- x/net/core/sock.c
+++ y/net/core/sock.c
@@ -2298,6 +2298,11 @@ struct sock *sk_clone_lock(const struct
newsk = NULL;
goto out;
}
+ if (sk_user_data_is_nocopy(newsk)) {
+ sk_free_unlock_clone(newsk);
+ newsk = NULL;
+ goto out;
+ }

/* Clear sk_user_data if parent had the pointer tagged
* as not suitable for copying when cloning.
--

[1] https://lore.kernel.org/lkml/00000000000049...@google.com/

Hillf Danton

unread,
Dec 23, 2022, 1:07:14 AM12/23/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On 06 Dec 2022 12:14:44 -0800
> syzbot found the following issue on:
>
> HEAD commit: 6a30d3e3491d selftests: net: Use "grep -E" instead of "egr..
> git tree: net
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1077da23880000

No clone for psock.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/include/net/sock.h
+++ y/include/net/sock.h
@@ -581,6 +581,11 @@ static inline bool sk_user_data_is_nocop
return ((uintptr_t)sk->sk_user_data & SK_USER_DATA_NOCOPY);
}

+static inline bool sk_user_data_is_psock(const struct sock *sk)
+{
+ return ((uintptr_t)sk->sk_user_data & SK_USER_DATA_PSOCK);
+}
+
#define __sk_user_data(sk) ((*((void __rcu **)&(sk)->sk_user_data)))

/**
--- x/net/core/sock.c
+++ y/net/core/sock.c
@@ -2316,6 +2316,7 @@ struct sock *sk_clone_lock(const struct
RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL);

if (bpf_sk_storage_clone(sk, newsk)) {
+err:
sk_free_unlock_clone(newsk);
newsk = NULL;
goto out;
@@ -2324,8 +2325,11 @@ struct sock *sk_clone_lock(const struct
/* Clear sk_user_data if parent had the pointer tagged
* as not suitable for copying when cloning.
*/
- if (sk_user_data_is_nocopy(newsk))
+ if (sk_user_data_is_nocopy(newsk)) {
+ if (sk_user_data_is_psock(newsk))
+ goto err;
newsk->sk_user_data = NULL;
+ }

newsk->sk_err = 0;
newsk->sk_err_soft = 0;
--

syzbot

unread,
Dec 23, 2022, 1:50:18 AM12/23/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+04c21e...@syzkaller.appspotmail.com

Tested on:

commit: 8395ae05 Merge tag 'scsi-misc' of git://git.kernel.org..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=1714802f880000
kernel config: https://syzkaller.appspot.com/x/.config?x=935a84bda2af0616
dashboard link: https://syzkaller.appspot.com/bug?extid=04c21ed96d861dccc5cd
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=1028681f880000

Note: testing is done by a robot and is best-effort only.

Jakub Sitnicki

unread,
Jan 5, 2023, 8:30:26 AM1/5/23
to John Fastabend, Eric Dumazet, syzbot, b...@vger.kernel.org, da...@davemloft.net, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
I know what is happening. We're not restoring sk_prot in the child
socket on clone.

tcp_bpf_clone() callback currently restores sk_prot only if the
listener->sk_prot is &tcp_bpf_prots[*][TCP_BASE]. It should also check
for TCP_BPF_RX/TXRX.

It's a regression that slipped through with c5d2177a72a1 ("bpf, sockmap:
Fix race in ingress receive verdict with redirect to self"). And we're
clearly missing selftest coverage for this scenario.

I can fix that.

syzbot

unread,
Jan 20, 2023, 9:06:28 PM1/20/23
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, err...@gmail.com, hda...@sina.com, ja...@cloudflare.com, john.fa...@gmail.com, ka...@fb.com, kerne...@cloudflare.com, kps...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, l...@intel.com, l...@cloudflare.com, net...@vger.kernel.org, oe-kbu...@lists.linux.dev, oe-k...@lists.linux.dev, pab...@redhat.com, songliu...@fb.com, syzkall...@googlegroups.com, y...@fb.com
syzbot has bisected this issue to:

commit 38207a5e81230d6ffbdd51e5fa5681be5116dcae
Author: John Fastabend <john.fa...@gmail.com>
Date: Fri Nov 19 18:14:17 2021 +0000

bpf, sockmap: Attach map progs to psock early for feature probes

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=106884b9480000
start commit: c8451c141e07 Merge tag 'acpi-6.2-rc2' of git://git.kernel...
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=126884b9480000
console output: https://syzkaller.appspot.com/x/log.txt?x=146884b9480000
kernel config: https://syzkaller.appspot.com/x/.config?x=2651619a26b4d687
dashboard link: https://syzkaller.appspot.com/bug?extid=04c21ed96d861dccc5cd
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14a1a692480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1575dc34480000

Reported-by: syzbot+04c21e...@syzkaller.appspotmail.com
Fixes: 38207a5e8123 ("bpf, sockmap: Attach map progs to psock early for feature probes")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages