netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv4: fix lock leaks
@ 2022-01-21  3:11 ycaibb
  2022-01-21  3:46 ` Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ycaibb @ 2022-01-21  3:11 UTC (permalink / raw)
  To: edumazet, davem, yoshfuji, dsahern, kuba, ast, daniel, andrii,
	kafai, songliubraving, yhs, john.fastabend, kpsingh
  Cc: netdev, linux-kernel, bpf, ycaibb

From: Ryan Cai <ycaibb@gmail.com>

In methods listening_get_first and listening_get_first in tcp_ipv4.c, there are lock leaks when seq_sk_match returns true.

Signed-off-by: Ryan Cai <ycaibb@gmail.com>
---
 net/ipv4/tcp_ipv4.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 13d868c43284..714107766035 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2329,6 +2329,7 @@ static void *listening_get_first(struct seq_file *seq)
 		inet_lhash2_for_each_icsk(icsk, &ilb2->head) {
 			sk = (struct sock *)icsk;
 			if (seq_sk_match(seq, sk))
+				spin_unlock(&ilb2->lock);
 				return sk;
 		}
 		spin_unlock(&ilb2->lock);
@@ -2407,6 +2408,7 @@ static void *established_get_first(struct seq_file *seq)
 		spin_lock_bh(lock);
 		sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
 			if (seq_sk_match(seq, sk))
+				spin_unlock_bh(lock);
 				return sk;
 		}
 		spin_unlock_bh(lock);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-23  6:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21  3:11 [PATCH] ipv4: fix lock leaks ycaibb
2022-01-21  3:46 ` Jakub Kicinski
2022-01-21  3:47 ` Jakub Kicinski
2022-01-21  4:06   ` Ryan Cai
2022-01-21  4:11     ` Alexei Starovoitov
2022-01-23  6:17 ` [ipv4] 604258c8f5: BUG:sleeping_function_called_from_invalid_context_at_lib/iov_iter.c kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).