Netdev List
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Alexander Popov <alex.popov@linux.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	syzkaller <syzkaller@googlegroups.com>
Subject: Re: BUG at net/sctp/socket.c:7425
Date: Sun, 29 Jan 2017 08:40:02 -0200	[thread overview]
Message-ID: <20170129104002.GJ3781@localhost.localdomain> (raw)
In-Reply-To: <48766e1c-99c9-3a88-0fec-998bf4db9a3a@linux.com>

On Sun, Jan 29, 2017 at 03:35:31AM +0300, Alexander Popov wrote:
> Hello,
> 
> I'm running the syzkaller fuzzer for v4.10-rc4 (0aa0313f9d576affd7747cc3f179feb097d28990)
> and have such a crash in sctp code:
> 
...
> 
> Unfortunately, I didn't manage to get a C program reproducing the crash (looks like race).
> However, I stably hit it on my setup - so I can help fixing the issue.
> 
> The crash happens here:
> 	/* Let another process have a go.  Since we are going
> 	 * to sleep anyway.
> 	 */
> 	release_sock(sk);
> 	current_timeo = schedule_timeout(current_timeo);
> >	BUG_ON(sk != asoc->base.sk);
> 	lock_sock(sk);
> 
> I've added some debugging output and see, that the original value of asoc->base.sk is
> changed to the address of another struct sock, which appeared in sctp_endpoint_init()
> shortly before the crash.

You need some threading for this to happen.  asoc->base.sk will change
if you peeloff the association.
It seems you had one thread waiting for some sndbuf to be available on a
sendmsg() call and another thread did a peeloff on the association that
the first thread was using.
Yeah I think this will reproduce it.
And in this case, it's probably better if we just return -EPIPE as the
association doesn't exist in that socket anymore instead of the BUG_ON.

  Marcelo

---8<---

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 26a514269b92..e9870aead88b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6838,7 +6838,8 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
 		 */
 		sctp_release_sock(sk);
 		current_timeo = schedule_timeout(current_timeo);
-		BUG_ON(sk != asoc->base.sk);
+		if (sk != asoc->base.sk)
+			goto do_error;
 		sctp_lock_sock(sk);
 
 		*timeo_p = current_timeo;

  reply	other threads:[~2017-01-29 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-29  0:35 BUG at net/sctp/socket.c:7425 Alexander Popov
2017-01-29 10:40 ` Marcelo Ricardo Leitner [this message]
2017-01-30 11:19   ` Alexander Popov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170129104002.GJ3781@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=alex.popov@linux.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=syzkaller@googlegroups.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox