]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tcp: fix TIME_WAIT socket reference leak on PSP policy failure
authorEric Dumazet <edumazet@google.com>
Fri, 10 Jul 2026 18:13:17 +0000 (18:13 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Fri, 17 Jul 2026 09:53:55 +0000 (11:53 +0200)
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: 659a2899a57d ("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>
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c

index 209ef7522508fcc3974ae71d35dd66cba96b73d0..4a46da375043be26bcbb282a0b0c3ba85bfc5186 100644 (file)
@@ -2318,8 +2318,10 @@ do_time_wait:
                }
 
                drop_reason = psp_twsk_rx_policy_check(inet_twsk(sk), skb);
-               if (drop_reason)
-                       break;
+               if (drop_reason) {
+                       inet_twsk_put(inet_twsk(sk));
+                       goto discard_it;
+               }
        }
                /* to ACK */
                fallthrough;
index ebe161d72fbd07a13d92812b45b5a3ce2464a015..522ba45ce9b759a6a76fd8603400097bc99c60c6 100644 (file)
@@ -1977,8 +1977,10 @@ do_time_wait:
                }
 
                drop_reason = psp_twsk_rx_policy_check(inet_twsk(sk), skb);
-               if (drop_reason)
-                       break;
+               if (drop_reason) {
+                       inet_twsk_put(inet_twsk(sk));
+                       goto discard_it;
+               }
        }
                /* to ACK */
                fallthrough;