Skip to content

Commit 0c0eef8

Browse files
qsnklassert
authored andcommitted
esp: fix skb leak with espintcp and async crypto
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: e27cca9 ("xfrm: add espintcp (RFC 8229)") Signed-off-by: Sabrina Dubroca <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 7d2fc41 commit 0c0eef8

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

net/ipv4/esp4.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,13 @@ static void esp_output_done(void *data, int err)
235235
xfrm_dev_resume(skb);
236236
} else {
237237
if (!err &&
238-
x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)
239-
esp_output_tail_tcp(x, skb);
240-
else
238+
x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
239+
err = esp_output_tail_tcp(x, skb);
240+
if (err != -EINPROGRESS)
241+
kfree_skb(skb);
242+
} else {
241243
xfrm_output_resume(skb_to_full_sk(skb), skb, err);
244+
}
242245
}
243246
}
244247

net/ipv6/esp6.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,13 @@ static void esp_output_done(void *data, int err)
271271
xfrm_dev_resume(skb);
272272
} else {
273273
if (!err &&
274-
x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)
275-
esp_output_tail_tcp(x, skb);
276-
else
274+
x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
275+
err = esp_output_tail_tcp(x, skb);
276+
if (err != -EINPROGRESS)
277+
kfree_skb(skb);
278+
} else {
277279
xfrm_output_resume(skb_to_full_sk(skb), skb, err);
280+
}
278281
}
279282
}
280283

0 commit comments

Comments
 (0)