Skip to contentSkip to conversation

idpf: fix potential use-after-free in idpf_tso()

PATCH Applied Eric Dumazet 3 participants 3 messages Nov 3, 2023 – Nov 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 idpf: fix potential use-after-free in idpf_tso()

skb_cow_head() can change skb->head (and thus skb_shinfo(skb))

We must not cache skb_shinfo(skb) before skb_cow_head().

Fixes 6818c4d5b3c2 ("idpf: add splitq start_xmit")
Cc Joshua Hay <[email protected]>
Cc Alan Brady <[email protected]>
Cc Madhu Chittim <[email protected]>
Cc Phani Burra <[email protected]>
Cc Sridhar Samudrala <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Pavan Kumar Linga <[email protected]>
Cc Tony Nguyen <[email protected]>
Cc Bailey Forrest <[email protected]>
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +4 -2
index 5e1ef70d54fe4147a42e5a3263b73cd3e6316679..1f728a9004d9e40d4434534422a42c8c537f5eae 100644
@@ -2365,7 +2365,7 @@ static void idpf_tx_splitq_map(struct idpf_queue *tx_q,
  */
 int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off)
 {
-	const struct skb_shared_info *shinfo = skb_shinfo(skb);
+	const struct skb_shared_info *shinfo;
 	union {
 		struct iphdr *v4;
 		struct ipv6hdr *v6;
@@ -2379,13 +2379,15 @@ int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off)
 	u32 paylen, l4_start;
 	int err;
 
-	if (!shinfo->gso_size)
+	if (!skb_is_gso(skb))
 		return 0;
 
 	err = skb_cow_head(skb, 0);
 	if (err < 0)
 		return err;
 
+	shinfo = skb_shinfo(skb);
+
 	ip.hdr = skb_network_header(skb);
 	l4.hdr = skb_transport_header(skb);
 
Signature · 1 line
2.42.0.869.gea05f2083d-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Eric Dumazet

skb_cow_head() can change skb->head (and thus skb_shinfo(skb))

We must not cache skb_shinfo(skb) before skb_cow_head().

Fixes 6818c4d5b3c2 ("idpf: add splitq start_xmit")
Cc Joshua Hay <[email protected]>
Cc Alan Brady <[email protected]>
Cc Madhu Chittim <[email protected]>
Cc Phani Burra <[email protected]>
Cc Sridhar Samudrala <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Pavan Kumar Linga <[email protected]>
Cc Tony Nguyen <[email protected]>
Cc Bailey Forrest <[email protected]>
Quoted 1 line

---

Quoted 33 lines
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +4 -2
index 5e1ef70d54fe4147a42e5a3263b73cd3e6316679..1f728a9004d9e40d4434534422a42c8c537f5eae 100644
@@ -2365,7 +2365,7 @@ static void idpf_tx_splitq_map(struct idpf_queue *tx_q,
  */
 int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off)
 {
-	const struct skb_shared_info *shinfo = skb_shinfo(skb);
+	const struct skb_shared_info *shinfo;
 	union {
 		struct iphdr *v4;
 		struct ipv6hdr *v6;
@@ -2379,13 +2379,15 @@ int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off)
 	u32 paylen, l4_start;
 	int err;
 
-	if (!shinfo->gso_size)
+	if (!skb_is_gso(skb))
 		return 0;
 
 	err = skb_cow_head(skb, 0);
 	if (err < 0)
 		return err;
 
+	shinfo = skb_shinfo(skb);
+
 	ip.hdr = skb_network_header(skb);
 	l4.hdr = skb_transport_header(skb);
 
#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 16 lines · On Fri, 3 Nov 2023 20:04:51 +0000 you wrote:

skb_cow_head() can change skb->head (and thus skb_shinfo(skb))

We must not cache skb_shinfo(skb) before skb_cow_head().

Fixes 6818c4d5b3c2 ("idpf: add splitq start_xmit")
Cc Joshua Hay <[email protected]>
Cc Alan Brady <[email protected]>
Cc Madhu Chittim <[email protected]>
Cc Phani Burra <[email protected]>
Cc Sridhar Samudrala <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Pavan Kumar Linga <[email protected]>
Cc Tony Nguyen <[email protected]>
Cc Bailey Forrest <[email protected]>
Quoted 1 line

[...]

Here is the summary with links:
- [net] idpf: fix potential use-after-free in idpf_tso()

    https://git.kernel.org/netdev/net/c/115c0f4d5857

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html