netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	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 17:16:27 +0100	[thread overview]
Message-ID: <20110321161627.GB28580@elte.hu> (raw)
In-Reply-To: <201103211622.40851.arnd@arndb.de>


* Arnd Bergmann <arnd@arndb.de> wrote:

> On Monday 21 March 2011, Eric Dumazet wrote:
> > > 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;
> > >  }
> > >  
> > 
> > Hmm, x25_release() looks fine, I believe no fix is needed.
> > 
> 
> D'oh. You're right of course. My patch would introduce the bug,
> not fix it. Updated patch below.
> 
> 	Arnd
> 8<-------------------------
> net/appletalk: fix atalk_release use after free
> 
> The BKL removal in appletalk introduced a use-after-free problem,
> where atalk_destroy_socket frees a sock, but we still release
> the socket lock on it.
> 
> An easy fix is to take an extra reference on the sock and sock_put
> it when returning from atalk_release.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> 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;
>  }

I have not triggered the lockdep warning in this code yet - but i've ran the 
patch and have seen no ill effects from it so far.

Thanks,

	Ingo

  reply	other threads:[~2011-03-21 16:16 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
2011-03-21 14:55       ` Eric Dumazet
2011-03-21 15:22         ` Arnd Bergmann
2011-03-21 16:16           ` Ingo Molnar [this message]
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=20110321161627.GB28580@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 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).