public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: herbert@gondor.apana.org.au, netdev@vger.kernel.org
Subject: Re: [PATCH] inet: add RCU protection to inet->opt
Date: Thu, 28 Apr 2011 22:55:36 +0200	[thread overview]
Message-ID: <1304024136.2954.9.camel@edumazet-laptop> (raw)
In-Reply-To: <20110428.135226.242113407.davem@davemloft.net>

Le jeudi 28 avril 2011 à 13:52 -0700, David Miller a écrit :
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Thu, 28 Apr 2011 22:49:19 +0200
> 
> > Are you sure socket is locked at this point ? ( by a priori call to
> > lock_sock())
> 
> Ugh, it's not, I'll commit this fix which is safe because we're only
> peeking at inet_opt to fetch the faddr value then we never reference
> it again:
> 
> diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
> index 962a607..e13c166 100644
> --- a/net/l2tp/l2tp_ip.c
> +++ b/net/l2tp/l2tp_ip.c
> @@ -472,13 +472,15 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
>  	if (rt == NULL) {
>  		struct ip_options_rcu *inet_opt;
>  
> -		inet_opt = rcu_dereference_protected(inet->inet_opt,
> -						     sock_owned_by_user(sk));
> +		rcu_read_lock();
> +		inet_opt = rcu_dereference(inet->inet_opt);
>  
>  		/* Use correct destination address if we have options. */
>  		if (inet_opt && inet_opt->opt.srr)
>  			daddr = inet_opt->opt.faddr;
>  
> +		rcu_read_unlock();
> +
>  		/* If this fails, retransmit mechanism of transport layer will
>  		 * keep trying until route appears or the connection times
>  		 * itself out.


Thats perfect, thanks !



      reply	other threads:[~2011-04-28 20:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 15:39 [RFC] possible bug in inet->opt handling Eric Dumazet
2011-04-15 17:17 ` Herbert Xu
2011-04-15 17:24   ` Herbert Xu
2011-04-21 19:45 ` [PATCH] inet: add RCU protection to inet->opt Eric Dumazet
2011-04-28 20:20   ` David Miller
2011-04-28 20:49     ` Eric Dumazet
2011-04-28 20:52       ` David Miller
2011-04-28 20:55         ` Eric Dumazet [this message]

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=1304024136.2954.9.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --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