提交 30b9c54a 编写于 作者: C Cong Wang 提交者: Daniel Borkmann

skmsg: Clear skb redirect pointer before dropping it

When we drop skb inside sk_psock_skb_redirect(), we have to clear
its skb->_sk_redir pointer too, otherwise kfree_skb() would
misinterpret it as a valid skb->_skb_refdst and dst_release()
would eventually complain.

Fixes: e3526bb9 ("skmsg: Move sk_redir from TCP_SKB_CB to skb")
Reported-by: NJiang Wang <jiang.wang@bytedance.com>
Signed-off-by: NCong Wang <cong.wang@bytedance.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
Acked-by: NJakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20210615021342.7416-5-xiyou.wangcong@gmail.com
上级 e00a5c33
...@@ -843,12 +843,14 @@ static void sk_psock_skb_redirect(struct sk_buff *skb) ...@@ -843,12 +843,14 @@ static void sk_psock_skb_redirect(struct sk_buff *skb)
* a socket that is in this state so we drop the skb. * a socket that is in this state so we drop the skb.
*/ */
if (!psock_other || sock_flag(sk_other, SOCK_DEAD)) { if (!psock_other || sock_flag(sk_other, SOCK_DEAD)) {
skb_bpf_redirect_clear(skb);
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
spin_lock_bh(&psock_other->ingress_lock); spin_lock_bh(&psock_other->ingress_lock);
if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) { if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) {
spin_unlock_bh(&psock_other->ingress_lock); spin_unlock_bh(&psock_other->ingress_lock);
skb_bpf_redirect_clear(skb);
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册