All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, David Miller <davem@davemloft.net>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [held lock freed] Re: [GIT] Networking
Date: Mon, 21 Mar 2011 15:50:10 +0100	[thread overview]
Message-ID: <201103211550.10694.arnd@arndb.de> (raw)
In-Reply-To: <1300714346.2884.284.camel@edumazet-laptop>

On Monday 21 March 2011, Eric Dumazet wrote:
> [PATCH] ipx: fix ipx_release()
> 
> Commit b0d0d915d1d1a0 (remove the BKL) added a regression, because
> sock_put() can free memory while we are going to use it later.
> 
> Fix is to delay sock_put() after release_sock().
> 
> Reported-by: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>

Your fix looks good, thanks Eric!

Acked-by: Arnd Bergmann <arnd@arndb.de>

I believe I made the same mistake in atalk_release and x25_release:

8<------------
net: fix atalk_release and x25_release

The recent BKL removal has introduced a use-after-free problem
in multiple network protocols. This fixes the problem in appletalk
and x25 by ensuring that we call the final sock_put() after
releasing the socket lock.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 3d4f4b0..206e771 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1051,6 +1051,7 @@ static int atalk_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
+	sock_hold(sk);
 	lock_sock(sk);
 	if (sk) {
 		sock_orphan(sk);
@@ -1058,6 +1059,8 @@ static int atalk_release(struct socket *sock)
 		atalk_destroy_socket(sk);
 	}
 	release_sock(sk);
+	sock_put(sk);
+
 	return 0;
 }
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 4680b1e..b2cf1db 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -669,8 +669,8 @@ static int x25_release(struct socket *sock)
 
 	sock_orphan(sk);
 out:
-	release_sock(sk);
 	sock_put(sk);
+	release_sock(sk);
 	return 0;
 }
 

  reply	other threads:[~2011-03-21 14:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21  2:51 [GIT] Networking David Miller
2011-03-21 12:53 ` [held lock freed] " Ingo Molnar
2011-03-21 13:32   ` Eric Dumazet
2011-03-21 14:50     ` Arnd Bergmann [this message]
2011-03-21 14:55       ` Eric Dumazet
2011-03-21 15:22         ` Arnd Bergmann
2011-03-21 16:16           ` Ingo Molnar
2011-03-22  1:18           ` David Miller
2011-03-21 16:15     ` Ingo Molnar
2011-03-21 16:42       ` [slab poison overwritten] " Ingo Molnar
2011-03-21 17:37         ` Ingo Molnar
2011-03-21 17:39         ` Ingo Molnar
2011-03-21 18:07           ` Eric Dumazet
2011-03-21 20:15             ` Eric Dumazet
2011-03-21 22:13               ` Simon Horman
2011-03-21 23:29                 ` Simon Horman
2011-03-22  0:01                   ` Simon Horman
2011-03-22  0:17                     ` Simon Horman
2011-03-22  1:18                       ` Simon Horman
2011-03-22  3:40                         ` David Miller
2011-03-22  3:39                 ` David Miller
2011-03-22  9:56               ` Ingo Molnar
2011-03-22 10:00                 ` Eric Dumazet
2011-03-22 21:52                   ` Simon Horman
2011-03-22  9:07           ` Ingo Molnar
2011-03-22  1:16       ` [held lock freed] " David Miller
2011-03-21 19:24 ` Linus Torvalds
2011-03-21 20:10   ` Eric Dumazet
2011-03-22  4:09   ` David Miller
2011-03-22 10:00   ` Ingo Molnar

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=201103211550.10694.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.