diff options
author | Eric Dumazet <edumazet@google.com> | 2015-11-10 04:51:23 +0300 |
---|---|---|
committer | Zefan Li <lizefan@huawei.com> | 2016-10-26 18:15:24 +0300 |
commit | 74c1a5ecfcf8cd6a6238578add2ce0aefd5e44ed (patch) | |
tree | 6ea2608d0d8b5944499ba205b7cbc378b698a4e9 /net | |
parent | abc5526f35b4d1095db64b4dbc0671543fcad5f4 (diff) | |
download | linux-74c1a5ecfcf8cd6a6238578add2ce0aefd5e44ed.tar.xz |
net: fix a race in dst_release()
commit d69bbf88c8d0b367cf3e3a052f6daadf630ee566 upstream.
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 <gthelen@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dst.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/dst.c b/net/core/dst.c index 43d94cedbf7c..54ba1ebba30e 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -272,7 +272,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)) { dst = dst_destroy(dst); if (dst) __dst_free(dst); |