From: Dave Jones <davej@codemonkey.org.uk>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: suspicious rcu_dereference_check in sctp_v6_get_dst
Date: Sat, 5 Dec 2015 20:37:08 -0500 [thread overview]
Message-ID: <20151206013708.GA19228@codemonkey.org.uk> (raw)
In-Reply-To: <1449364386.25029.38.camel@edumazet-glaptop2.roam.corp.google.com>
On Sat, Dec 05, 2015 at 05:13:06PM -0800, Eric Dumazet wrote:
> > diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
> > index acb45b8c2a9d..7081183f4d9f 100644
> > --- a/net/sctp/ipv6.c
> > +++ b/net/sctp/ipv6.c
> > @@ -328,7 +328,9 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
> > if (baddr) {
> > fl6->saddr = baddr->v6.sin6_addr;
> > fl6->fl6_sport = baddr->v6.sin6_port;
> > + rcu_read_lock();
> > final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final);
> > + rcu_read_unlock();
> > dst = ip6_dst_lookup_flow(sk, fl6, final_p);
> > }
> >
>
> Hmm, better use :
>
> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
> index acb45b8c2a9d..d28c0b4c9128 100644
> --- a/net/sctp/ipv6.c
> +++ b/net/sctp/ipv6.c
> @@ -323,14 +323,13 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
> }
> }
> }
> - rcu_read_unlock();
> -
> if (baddr) {
> fl6->saddr = baddr->v6.sin6_addr;
> fl6->fl6_sport = baddr->v6.sin6_port;
> final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final);
> dst = ip6_dst_lookup_flow(sk, fl6, final_p);
> }
> + rcu_read_unlock();
>
> out:
> if (!IS_ERR_OR_NULL(dst)) {
I looked at that option first, but decided to mirror the other use of fl6_update_dst.
It looks like your solution would work too, so I'm not against it, but..
For my own understanding, why is this better? Just to cut down on the
number of repeated lock/unlocks in the same function? Or is there some
semantic I'm missing in the earlier lock/unlock section that's somehow
related to the np->opt ?
thanks,
Dave
next prev parent reply other threads:[~2015-12-06 1:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-06 0:25 suspicious rcu_dereference_check in sctp_v6_get_dst Dave Jones
2015-12-06 1:13 ` Eric Dumazet
2015-12-06 1:37 ` Dave Jones [this message]
2015-12-06 1:56 ` Eric Dumazet
2015-12-07 16:25 ` [PATCH net] ipv6: sctp: fix lockdep splat in sctp_v6_get_dst() Eric Dumazet
2015-12-07 22:07 ` David Miller
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=20151206013708.GA19228@codemonkey.org.uk \
--to=davej@codemonkey.org.uk \
--cc=eric.dumazet@gmail.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).