Commit b4da6642 authored by Cong Wang's avatar Cong Wang Committed by Zheng Zengkai
Browse files

skmsg: Fix a memory leak in sk_psock_verdict_apply()

mainline inclusion
from mainline-v5.14-rc1
commit 0cf6672b
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I545NW

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cf6672b23c8aa9d9274798dd63cbf6ede77ef90



--------------------------------

If the dest psock does not set SK_PSOCK_TX_ENABLED,
the skb can't be queued anywhere so must be dropped.

This one is found during code review.

Fixes: 799aa7f9 ("skmsg: Avoid lock_sock() in sk_psock_backlog()")
Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20210615021342.7416-6-xiyou.wangcong@gmail.com


Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Reviewed-by: default avatarLiu Jian <liujian56@huawei.com>
Reviewed-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 50f9c2ee
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -877,8 +877,13 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
			if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) {
				skb_queue_tail(&psock->ingress_skb, skb);
				schedule_work(&psock->work);
				err = 0;
			}
			spin_unlock_bh(&psock->ingress_lock);
			if (err < 0) {
				tcp_skb_bpf_redirect_clear(skb);
				goto out_free;
			}
		}
		break;
	case __SK_REDIRECT: