Skip to content

Commit c0309de

Browse files
author
Sabrina Dubroca
committed
espintcp: fix skb leaks
JIRA: https://issues.redhat.com/browse/RHEL-115629 Conflicts: netdev_max_backlog is not in hotdata (missing commit edbc666 ("net: move netdev_max_backlog to net_hotdata")) commit 63c1f19 Author: Sabrina Dubroca <sd@queasysnail.net> Date: Wed Apr 9 15:59:56 2025 +0200 espintcp: fix skb leaks A few error paths are missing a kfree_skb. Fixes: e27cca9 ("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: Sabrina Dubroca <sdubroca@redhat.com>
1 parent 1295404 commit c0309de

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

net/ipv4/esp4.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ static int esp_output_tcp_finish(struct xfrm_state *x, struct sk_buff *skb)
199199

200200
sk = esp_find_tcp_sk(x);
201201
err = PTR_ERR_OR_ZERO(sk);
202-
if (err)
202+
if (err) {
203+
kfree_skb(skb);
203204
goto out;
205+
}
204206

205207
bh_lock_sock(sk);
206208
if (sock_owned_by_user(sk))

net/ipv6/esp6.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ static int esp_output_tcp_finish(struct xfrm_state *x, struct sk_buff *skb)
215215

216216
sk = esp6_find_tcp_sk(x);
217217
err = PTR_ERR_OR_ZERO(sk);
218-
if (err)
218+
if (err) {
219+
kfree_skb(skb);
219220
goto out;
221+
}
220222

221223
bh_lock_sock(sk);
222224
if (sock_owned_by_user(sk))

net/xfrm/espintcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ int espintcp_queue_out(struct sock *sk, struct sk_buff *skb)
171171
{
172172
struct espintcp_ctx *ctx = espintcp_getctx(sk);
173173

174-
if (skb_queue_len(&ctx->out_queue) >= READ_ONCE(netdev_max_backlog))
174+
if (skb_queue_len(&ctx->out_queue) >= READ_ONCE(netdev_max_backlog)) {
175+
kfree_skb(skb);
175176
return -ENOBUFS;
177+
}
176178

177179
__skb_queue_tail(&ctx->out_queue, skb);
178180

0 commit comments

Comments
 (0)