]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipv4: fix dst race in sk_dst_get()
authorEric Dumazet <edumazet@google.com>
Tue, 24 Jun 2014 17:05:11 +0000 (10:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Jul 2014 15:08:23 +0000 (08:08 -0700)
commit9a4fe697023dbe6c25caa1f8b2153af869a29bd2
tree016e8816153beb4fb78621bebaf8d2a6c5ecd645
parentd5edc54bdcd1996389182a3a6654cf87b4ce23cb
ipv4: fix dst race in sk_dst_get()

[ Upstream commit f88649721268999bdff09777847080a52004f691 ]

When IP route cache had been removed in linux-3.6, we broke assumption
that dst entries were all freed after rcu grace period. DST_NOCACHE
dst were supposed to be freed from dst_release(). But it appears
we want to keep such dst around, either in UDP sockets or tunnels.

In sk_dst_get() we need to make sure dst refcount is not 0
before incrementing it, or else we might end up freeing a dst
twice.

DST_NOCACHE set on a dst does not mean this dst can not be attached
to a socket or a tunnel.

Then, before actual freeing, we need to observe a rcu grace period
to make sure all other cpus can catch the fact the dst is no longer
usable.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dormando <dormando@rydia.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/sock.h
net/core/dst.c
net/ipv4/ip_tunnel.c