diff mbox series

[bpf,v2,4/7] skmsg: fix a memory leak in sk_psock_verdict_apply()

Message ID 20210522191411.21446-5-xiyou.wangcong@gmail.com
State Superseded
Headers show
Series sock_map: some bug fixes and improvements | expand

Commit Message

Cong Wang May 22, 2021, 7:14 p.m. UTC
From: Cong Wang <cong.wang@bytedance.com>

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

This one is found during code review.

Fixes: 799aa7f98d53 ("skmsg: Avoid lock_sock() in sk_psock_backlog()")
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jakub Sitnicki <jakub@cloudflare.com>
Cc: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
 net/core/skmsg.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index f9a81b314e4c..de68a3cd33f1 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -922,8 +922,11 @@  static void sk_psock_verdict_apply(struct sk_psock *psock,
 			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)
+				goto out_free;
 		}
 		break;
 	case __SK_REDIRECT: