Skip to contentSkip to conversation

idpf: fix kernel panic on unknown packet types

PATCH In review Pavan Kumar Linga 2 participants 2 messages Mar 21, 2024 – Apr 3, 2024

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

PATCH 1/1 idpf: fix kernel panic on unknown packet types

From: Joshua Hay <[email protected]>

In the very rare case where a packet type is unknown to the driver, idpf_rx_process_skb_fields would return early without calling eth_type_trans to set the skb protocol / the network layer handler. This is especially problematic if tcpdump is running when such a packet is received, i.e. it would cause a kernel panic.

Instead, call eth_type_trans for every single packet, even when the packet type is unknown.

---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +2 -2
index 2f8ad79ae3f0..017a081d8580 100644
@@ -2940,6 +2940,8 @@ static int idpf_rx_process_skb_fields(struct idpf_queue *rxq,
 	rx_ptype = le16_get_bits(rx_desc->ptype_err_fflags0,
 				 VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M);
 
+	skb->protocol = eth_type_trans(skb, rxq->vport->netdev);
+
 	decoded = rxq->vport->rx_ptype_lkup[rx_ptype];
 	/* If we don't know the ptype we can't do anything else with it. Just
 	 * pass it up the stack as-is.
@@ -2950,8 +2952,6 @@ static int idpf_rx_process_skb_fields(struct idpf_queue *rxq,
 	/* process RSS/hash */
 	idpf_rx_hash(rxq, skb, rx_desc, &decoded);
 
-	skb->protocol = eth_type_trans(skb, rxq->vport->netdev);
-
 	if (le16_get_bits(rx_desc->hdrlen_flags,
 			  VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M))
 		return idpf_rx_rsc(rxq, skb, rx_desc, &decoded);
Signature · 1 line
2.43.0
Tested-by on v1 1/1
#1 lore raw

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Quoted 40 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Pavan Kumar Linga
Sent: Wednesday, March 20, 2024 5:09 PM
To: [email protected]
Cc: Tantilov, Emil S <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Hay, Joshua A <[email protected]>; Daniele, Salvatore <[email protected]>; Nemeth, Balazs <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net] idpf: fix kernel panic on unknown packet types

From: Joshua Hay <[email protected]>

In the very rare case where a packet type is unknown to the driver, idpf_rx_process_skb_fields would return early without calling eth_type_trans to set the skb protocol / the network layer handler. This is especially problematic if tcpdump is running when such a packet is received, i.e. it would cause a kernel panic.

Instead, call eth_type_trans for every single packet, even when the packet type is unknown.

---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
index 2f8ad79ae3f0..017a081d8580 100644