netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: lars.persson@axis.com, netdev@vger.kernel.org
Subject: Re: [PATCH] tcp: tcp_release_cb() should release socket ownership
Date: Wed, 05 Mar 2014 20:59:38 -0500 (EST)	[thread overview]
Message-ID: <20140305.205938.287751582220842351.davem@davemloft.net> (raw)
In-Reply-To: <1393972752.26794.145.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 04 Mar 2014 14:39:12 -0800

> @@ -767,6 +767,17 @@ void tcp_release_cb(struct sock *sk)
>  	if (flags & (1UL << TCP_TSQ_DEFERRED))
>  		tcp_tsq_handler(sk);
>  
> +	/* Here begins the tricky part :
> +	 * We are called from release_sock() with :
> +	 * 1) BH disabled
> +	 * 2) sk_lock.slock spinlock held
> +	 * 3) socket owned by us (sk->sk_lock.owned == 1)
> +	 *
> +	 * But following code is meant to be called from BH handlers,
> +	 * so we should keep BH disabled, but early release socket ownership
> +	 */
> +	sock_release_ownership(sk);
> +

It really means that sk_lock.owned cannot ever be accessed without the
sk_lock spinlock held.

Most of this is easy to hand audit, except sock_owned_by_user() which
has call sites everywhere.

Consider adding a locking assertion to it.

  reply	other threads:[~2014-03-06  1:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04  8:59 [BUG] Deadlock on sk->sk_lock.slock Lars Persson
2014-03-04 14:16 ` Eric Dumazet
2014-03-04 18:48   ` David Miller
2014-03-04 22:39     ` [PATCH] tcp: tcp_release_cb() should release socket ownership Eric Dumazet
2014-03-06  1:59       ` David Miller [this message]
2014-03-06  2:06         ` Eric Dumazet
2014-03-06  2:15           ` David Miller
2014-03-06  2:20             ` Eric Dumazet
2014-03-07 15:45               ` Lars Persson
2014-03-07 16:01                 ` Eric Dumazet
2014-03-10 16:43                   ` Eric Dumazet
2014-03-10 20:40                     ` David Miller
2014-03-10 16:50       ` [PATCH resend] " Eric Dumazet
2014-03-11 20:46         ` David Miller
2014-03-05 15:01   ` [BUG] Deadlock on sk->sk_lock.slock Lars Persson
2014-03-05 17:34     ` Eric Dumazet

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=20140305.205938.287751582220842351.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=lars.persson@axis.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).