WARNING: bad unlock balance in mptcp_shutdown

4 views
Skip to first unread message

syzbot

unread,
Apr 11, 2020, 5:38:13 PM4/11/20
to da...@davemloft.net, ku...@kernel.org, linux-...@vger.kernel.org, mathew.j....@linux.intel.com, matthie...@tessares.net, mp...@lists.01.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: f5e94d10 Merge tag 'drm-next-2020-04-08' of git://anongit...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17a5dbfbe00000
kernel config: https://syzkaller.appspot.com/x/.config?x=ca75979eeebf06c2
dashboard link: https://syzkaller.appspot.com/bug?extid=6ebb6d4830e8f8815623
compiler: gcc (GCC) 9.0.0 20181231 (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+6ebb6d...@syzkaller.appspotmail.com

=====================================
WARNING: bad unlock balance detected!
5.6.0-syzkaller #0 Not tainted
-------------------------------------
syz-executor.5/2215 is trying to release lock (sk_lock-AF_INET6) at:
[<ffffffff87c5203b>] mptcp_shutdown+0x38b/0x550 net/mptcp/protocol.c:1889
but there are no more locks to release!

other info that might help us debug this:
1 lock held by syz-executor.5/2215:
#0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:358 [inline]
#0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: release_sock+0x1b/0x1b0 net/core/sock.c:2974

stack backtrace:
CPU: 0 PID: 2215 Comm: syz-executor.5 Not tainted 5.6.0-syzkaller #0
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+0x188/0x20d lib/dump_stack.c:118
__lock_release kernel/locking/lockdep.c:4633 [inline]
lock_release+0x586/0x800 kernel/locking/lockdep.c:4941
sock_release_ownership include/net/sock.h:1539 [inline]
release_sock+0x177/0x1b0 net/core/sock.c:2984
mptcp_shutdown+0x38b/0x550 net/mptcp/protocol.c:1889
__sys_shutdown+0xf3/0x1a0 net/socket.c:2208
__do_sys_shutdown net/socket.c:2216 [inline]
__se_sys_shutdown net/socket.c:2214 [inline]
__x64_sys_shutdown+0x50/0x70 net/socket.c:2214
do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45c889
Code: ad b6 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 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fa67df32c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000030
RAX: ffffffffffffffda RBX: 00007fa67df336d4 RCX: 000000000045c889
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 000000000076bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000b5e R14: 00000000004cd960 R15: 000000000076bfac


---
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.

Florian Westphal

unread,
Apr 11, 2020, 6:44:02 PM4/11/20
to syzbot, da...@davemloft.net, ku...@kernel.org, linux-...@vger.kernel.org, mathew.j....@linux.intel.com, matthie...@tessares.net, mp...@lists.01.org, net...@vger.kernel.org, syzkall...@googlegroups.com
> console output: https://syzkaller.appspot.com/x/log.txt?x=17a5dbfbe00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=ca75979eeebf06c2
> dashboard link: https://syzkaller.appspot.com/bug?extid=6ebb6d4830e8f8815623
> compiler: gcc (GCC) 9.0.0 20181231 (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+6ebb6d...@syzkaller.appspotmail.com
>
> =====================================
> WARNING: bad unlock balance detected!
> 5.6.0-syzkaller #0 Not tainted
> -------------------------------------
> syz-executor.5/2215 is trying to release lock (sk_lock-AF_INET6) at:
> [<ffffffff87c5203b>] mptcp_shutdown+0x38b/0x550 net/mptcp/protocol.c:1889
> but there are no more locks to release!
>
> other info that might help us debug this:
> 1 lock held by syz-executor.5/2215:
> #0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:358 [inline]
> #0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: release_sock+0x1b/0x1b0 net/core/sock.c:2974

I think this is same issue as the other report, so:

#syz dup: WARNING: bad unlock balance in mptcp_poll

Hillf Danton

unread,
Apr 11, 2020, 11:30:04 PM4/11/20
to Florian Westphal, syzbot, da...@davemloft.net, ku...@kernel.org, linux-...@vger.kernel.org, mathew.j....@linux.intel.com, matthie...@tessares.net, mp...@lists.01.org, net...@vger.kernel.org, syzkall...@googlegroups.com

On Sun, 12 Apr 2020 00:43:37 +0200 Florian Westphal wrote:
>
> > console output: https://syzkaller.appspot.com/x/log.txt?x=17a5dbfbe00000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=ca75979eeebf06c2
> > dashboard link: https://syzkaller.appspot.com/bug?extid=6ebb6d4830e8f8815623
> > compiler: gcc (GCC) 9.0.0 20181231 (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+6ebb6d...@syzkaller.appspotmail.com
> >
> > =====================================
> > WARNING: bad unlock balance detected!
> > 5.6.0-syzkaller #0 Not tainted
> > -------------------------------------
> > syz-executor.5/2215 is trying to release lock (sk_lock-AF_INET6) at:
> > [<ffffffff87c5203b>] mptcp_shutdown+0x38b/0x550 net/mptcp/protocol.c:1889
> > but there are no more locks to release!
> >
> > other info that might help us debug this:
> > 1 lock held by syz-executor.5/2215:
> > #0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:358 [inline]
> > #0: ffff88804a22eda0 (slock-AF_INET6){+.-.}-{2:2}, at: release_sock+0x1b/0x1b0 net/core/sock.c:2974
>
> I think this is same issue as the other report, so:
>
> #syz dup: WARNING: bad unlock balance in mptcp_poll

Add a couple of lines to check if sk lock is released behind eye balls
in the path of mptcp poll, and shutdown as well, assuming it's not
going to make the current sk locking acheme worse.

--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -98,8 +98,9 @@ static struct socket *__mptcp_tcp_fallba
return NULL;

if (msk->subflow) {
+ sock = msk->subflow;
release_sock((struct sock *)msk);
- return msk->subflow;
+ return sock;
}

return NULL;
@@ -1843,17 +1844,19 @@ static __poll_t mptcp_poll(struct file *
{
struct sock *sk = sock->sk;
struct mptcp_sock *msk;
- struct socket *ssock;
+ struct socket *ssock, *subflow;
__poll_t mask = 0;

msk = mptcp_sk(sk);
lock_sock(sk);
+ subflow = msk->subflow;
ssock = __mptcp_tcp_fallback(msk);
if (!ssock)
ssock = __mptcp_nmpc_socket(msk);
if (ssock) {
mask = ssock->ops->poll(file, ssock, wait);
- release_sock(sk);
+ if (ssock != subflow)
+ release_sock(sk);
return mask;
}

@@ -1878,15 +1881,17 @@ static int mptcp_shutdown(struct socket
{
struct mptcp_sock *msk = mptcp_sk(sock->sk);
struct mptcp_subflow_context *subflow;
- struct socket *ssock;
+ struct socket *ssock, *subf_sock;
int ret = 0;

pr_debug("sk=%p, how=%d", msk, how);

lock_sock(sock->sk);
+ subf_sock = msk->subflow;
ssock = __mptcp_tcp_fallback(msk);
if (ssock) {
- release_sock(sock->sk);
+ if (ssock != subf_sock)
+ release_sock(sock->sk);
return inet_shutdown(ssock, how);
}


Reply all
Reply to author
Forward
0 new messages