Skip to content

Commit 2c1931a

Browse files
edumazetPaolo Abeni
authored andcommitted
tcp: fix TIME_WAIT socket reference leak on PSP policy failure
Release the TIME_WAIT socket reference and jump to discard_it upon PSP policy failure in both IPv4 and IPv6 receive paths. This prevents a memory leak of tcp_tw_bucket structures. Fixes: 659a289 ("tcp: add datapath logic for PSP with inline key exchange") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Daniel Zahka <daniel.zahka@gmail.com> Link: https://patch.msgid.link/20260710181317.4060230-1-edumazet@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent df6134b commit 2c1931a

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

net/ipv4/tcp_ipv4.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,8 +2318,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
23182318
}
23192319

23202320
drop_reason = psp_twsk_rx_policy_check(inet_twsk(sk), skb);
2321-
if (drop_reason)
2322-
break;
2321+
if (drop_reason) {
2322+
inet_twsk_put(inet_twsk(sk));
2323+
goto discard_it;
2324+
}
23232325
}
23242326
/* to ACK */
23252327
fallthrough;

net/ipv6/tcp_ipv6.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,8 +1977,10 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
19771977
}
19781978

19791979
drop_reason = psp_twsk_rx_policy_check(inet_twsk(sk), skb);
1980-
if (drop_reason)
1981-
break;
1980+
if (drop_reason) {
1981+
inet_twsk_put(inet_twsk(sk));
1982+
goto discard_it;
1983+
}
19821984
}
19831985
/* to ACK */
19841986
fallthrough;

0 commit comments

Comments
 (0)