From: Eric Dumazet Date: Tue, 10 Nov 2015 01:51:23 +0000 (-0800) Subject: net: fix a race in dst_release() X-Git-Tag: v4.1.12-92~201^2~54 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ae406e508beb6067a39aabad2a6344a44368f18d;p=users%2Fjedix%2Flinux-maple.git net: fix a race in dst_release() Orabug: 22623844 [ Upstream commit d69bbf88c8d0b367cf3e3a052f6daadf630ee566 ] Only cpu seeing dst refcount going to 0 can safely dereference dst->flags. Otherwise an other cpu might already have freed the dst. Fixes: 27b75c95f10d ("net: avoid RCU for NOCACHE dst") Reported-by: Greg Thelen Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman (cherry picked from commit e6fac8c7fff3d816729ad16327837ba3216d48c9) Signed-off-by: Dan Duval --- diff --git a/net/core/dst.c b/net/core/dst.c index e956ce6d13782..f8db4032d45a4 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -285,7 +285,7 @@ void dst_release(struct dst_entry *dst) newrefcnt = atomic_dec_return(&dst->__refcnt); WARN_ON(newrefcnt < 0); - if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt) + if (!newrefcnt && unlikely(dst->flags & DST_NOCACHE)) call_rcu(&dst->rcu_head, dst_destroy_rcu); } }