| From 63c35b627fe18189d7281a925fb96d4b0b89827c Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Tue, 24 Feb 2026 00:05:14 +0100 |
| Subject: esp: fix skb leak with espintcp and async crypto |
| |
| From: Sabrina Dubroca <sd@queasysnail.net> |
| |
| [ Upstream commit 0c0eef8ccd2413b0a10eb6bbd3442333b1e64dd2 ] |
| |
| When the TX queue for espintcp is full, esp_output_tail_tcp will |
| return an error and not free the skb, because with synchronous crypto, |
| the common xfrm output code will drop the packet for us. |
| |
| With async crypto (esp_output_done), we need to drop the skb when |
| esp_output_tail_tcp returns an error. |
| |
| Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)") |
| Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> |
| Reviewed-by: Simon Horman <horms@kernel.org> |
| Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| net/ipv4/esp4.c | 9 ++++++--- |
| net/ipv6/esp6.c | 9 ++++++--- |
| 2 files changed, 12 insertions(+), 6 deletions(-) |
| |
| diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c |
| index 85e24dc42f2f3..4256c7ee59397 100644 |
| --- a/net/ipv4/esp4.c |
| +++ b/net/ipv4/esp4.c |
| @@ -233,10 +233,13 @@ static void esp_output_done(void *data, int err) |
| xfrm_dev_resume(skb); |
| } else { |
| if (!err && |
| - x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) |
| - esp_output_tail_tcp(x, skb); |
| - else |
| + x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) { |
| + err = esp_output_tail_tcp(x, skb); |
| + if (err != -EINPROGRESS) |
| + kfree_skb(skb); |
| + } else { |
| xfrm_output_resume(skb_to_full_sk(skb), skb, err); |
| + } |
| } |
| } |
| |
| diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c |
| index be8e2e5b439ed..f3305154745ec 100644 |
| --- a/net/ipv6/esp6.c |
| +++ b/net/ipv6/esp6.c |
| @@ -269,10 +269,13 @@ static void esp_output_done(void *data, int err) |
| xfrm_dev_resume(skb); |
| } else { |
| if (!err && |
| - x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) |
| - esp_output_tail_tcp(x, skb); |
| - else |
| + x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) { |
| + err = esp_output_tail_tcp(x, skb); |
| + if (err != -EINPROGRESS) |
| + kfree_skb(skb); |
| + } else { |
| xfrm_output_resume(skb_to_full_sk(skb), skb, err); |
| + } |
| } |
| } |
| |
| -- |
| 2.51.0 |
| |