All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: dvyukov@google.com, vyasevich@gmail.com, yoshfuji@linux-ipv6.org,
	netdev@vger.kernel.org, edumazet@google.com
Subject: Re: [PATCH v2 net] ipv6: kill sk_dst_lock
Date: Thu, 03 Dec 2015 11:32:43 -0500 (EST)	[thread overview]
Message-ID: <20151203.113243.972969856777923620.davem@davemloft.net> (raw)
In-Reply-To: <1449122037.6379.18.camel@edumazet-glaptop2.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 02 Dec 2015 21:53:57 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> While testing the np->opt RCU conversion, I found that UDP/IPv6 was
> using a mixture of xchg() and sk_dst_lock to protect concurrent changes
> to sk->sk_dst_cache, leading to possible corruptions and crashes.
> 
> ip6_sk_dst_lookup_flow() uses sk_dst_check() anyway, so the simplest
> way to fix the mess is to remove sk_dst_lock completely, as we did for
> IPv4.
> 
> __ip6_dst_store() and ip6_dst_store() share same implementation.
> 
> sk_setup_caps() being called with socket lock being held or not,
> we have to use sk_dst_set() instead of __sk_dst_set()
> 
> Note that I had to move the "np->dst_cookie = rt6_get_cookie(rt);"
> in ip6_dst_store() before the sk_setup_caps(sk, dst) call.
> 
> This is because ip6_dst_store() can be called from process context,
> without any lock held.
> 
> As soon as the dst is installed in sk->sk_dst_cache, dst can be freed
> from another cpu doing a concurrent ip6_dst_store()
> 
> Doing the dst dereference before doing the install is needed to make
> sure no use after free would trigger.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> ---
> v2: added the explanation about rt6_get_cookie(rt) called
> before sk_setup_caps()

Applied to 'net', with some fuzz... did you happen to generate this
against net-next by chance?

  reply	other threads:[~2015-12-03 16:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-28 11:00 use-after-free in ip6_setup_cork Dmitry Vyukov
2015-11-28 17:11 ` Eric Dumazet
2015-11-28 17:23   ` Eric Dumazet
2015-11-30  3:29     ` Eric Dumazet
2015-11-30 16:35       ` [PATCH net] ipv6: kill sk_dst_lock Eric Dumazet
2015-11-30 18:13         ` Paolo Abeni
2015-11-30 18:27           ` Eric Dumazet
2015-12-01  1:44         ` YOSHIFUJI Hideaki
2015-12-01  2:01           ` Eric Dumazet
2015-12-03  4:42         ` David Miller
2015-12-03  5:53           ` [PATCH v2 " Eric Dumazet
2015-12-03 16:32             ` David Miller [this message]
2015-12-03 16:49               ` Eric Dumazet
2015-12-03 16:49                 ` Eric Dumazet
2015-12-03  5:57           ` [PATCH " Eric Dumazet
2015-11-30  3:37     ` [PATCH net] ipv6: add complete rcu protection around np->opt Eric Dumazet
2015-12-01 11:11       ` Hannes Frederic Sowa
2015-12-01 13:05         ` Eric Dumazet
2015-12-01 13:13           ` Hannes Frederic Sowa
2015-12-03  4:38       ` David Miller
2015-12-03  5:35         ` Eric Dumazet
2015-12-03  5:48           ` [PATCH net] ipv6: sctp: add " Eric Dumazet
2015-12-03 16:32             ` 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=20151203.113243.972969856777923620.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vyasevich@gmail.com \
    --cc=yoshfuji@linux-ipv6.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.