Commit 5869b8fa authored by Xin Long's avatar Xin Long Committed by David S. Miller

net: use rcu_dereference_protected to fetch sk_dst_cache in sk_destruct

As Eric noticed, in .sk_destruct, sk->sk_dst_cache update is prevented, and
no barrier is needed for this. So change to use rcu_dereference_protected()
instead of rcu_dereference_check() to fetch sk_dst_cache in there.

v1->v2:
  - no change, repost after net-next is open.
Reported-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b6163f19
...@@ -444,7 +444,7 @@ static void dn_destruct(struct sock *sk) ...@@ -444,7 +444,7 @@ static void dn_destruct(struct sock *sk)
skb_queue_purge(&scp->other_xmit_queue); skb_queue_purge(&scp->other_xmit_queue);
skb_queue_purge(&scp->other_receive_queue); skb_queue_purge(&scp->other_receive_queue);
dst_release(rcu_dereference_check(sk->sk_dst_cache, 1)); dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1));
} }
static unsigned long dn_memory_pressure; static unsigned long dn_memory_pressure;
......
...@@ -160,7 +160,7 @@ void inet_sock_destruct(struct sock *sk) ...@@ -160,7 +160,7 @@ void inet_sock_destruct(struct sock *sk)
WARN_ON(sk->sk_forward_alloc); WARN_ON(sk->sk_forward_alloc);
kfree(rcu_dereference_protected(inet->inet_opt, 1)); kfree(rcu_dereference_protected(inet->inet_opt, 1));
dst_release(rcu_dereference_check(sk->sk_dst_cache, 1)); dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1));
dst_release(sk->sk_rx_dst); dst_release(sk->sk_rx_dst);
sk_refcnt_debug_dec(sk); sk_refcnt_debug_dec(sk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment