Skip to contentSkip to conversation

Intel Wired LAN Driver Updates 2023-12-26 (idpf)

GIT PULL New Tony Nguyen 2 participants 4 messages Dec 26, 2023 – Jan 4, 2024

Subsystems (3)
lore
Share & tools
lore

Tony Nguyen

author maintainer
#0 lore raw

This series contains updates to idpf driver only.

Alexander resolves issues in singleq mode to prevent corrupted frames and leaking skbs.

Pavan prevents extra padding on RSS struct causing load failure due to unexpected size.

The following are changes since commit dff90e4a092b771354287fbe55e557467c9da620:
Merge branch 'nfc-refcounting'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 200GbE

Alexander Lobakin (1):
idpf: fix corrupted frames and skb leaks in singleq mode

Pavan Kumar Linga (1):
idpf: avoid compiler introduced padding in virtchnl2_rss_key struct

 drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c | 1 -
 drivers/net/ethernet/intel/idpf/idpf_txrx.c         | 2 +-
 drivers/net/ethernet/intel/idpf/virtchnl2.h         | 6 +++---
 3 files changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 1/2 idpf: fix corrupted frames and skb leaks in singleq mode

From: Alexander Lobakin <[email protected]>

idpf_ring::skb serves only for keeping an incomplete frame between several NAPI Rx polling cycles, as one cycle may end up before processing the end of packet descriptor. The pointer is taken from the ring onto the stack before entering the loop and gets written there after the loop exits. When inside the loop, only the onstack pointer is used.
For some reason, the logics is broken in the singleq mode, where the pointer is taken from the ring each iteration. This means that if a frame got fragmented into several descriptors, each fragment will have its own skb, but only the last one will be passed up the stack (containing garbage), leaving the rest leaked.
Then, on ifdown, rxq::skb is being freed only in the splitq mode, while it can point to a valid skb in singleq as well. This can lead to a yet another skb leak.
Just don't touch the ring skb field inside the polling loop, letting the onstack skb pointer work as expected: build a new skb if it's the first frame descriptor and attach a frag otherwise. On ifdown, free rxq::skb unconditionally if the pointer is non-NULL.

---
 drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c | 1 -
 drivers/net/ethernet/intel/idpf/idpf_txrx.c         | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +0 -1
index 81288a17da2a..20c4b3a64710 100644
@@ -1044,7 +1044,6 @@ static int idpf_rx_singleq_clean(struct idpf_queue *rx_q, int budget)
 		}
 
 		idpf_rx_sync_for_cpu(rx_buf, fields.size);
-		skb = rx_q->skb;
 		if (skb)
 			idpf_rx_add_frag(rx_buf, skb, fields.size);
 		else
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -1
index 1f728a9004d9..9e942e5baf39 100644
@@ -396,7 +396,7 @@ static void idpf_rx_desc_rel(struct idpf_queue *rxq, bool bufq, s32 q_model)
 	if (!rxq)
 		return;
 
-	if (!bufq && idpf_is_queue_model_split(q_model) && rxq->skb) {
+	if (rxq->skb) {
 		dev_kfree_skb_any(rxq->skb);
 		rxq->skb = NULL;
 	}
Signature · 1 line
2.41.0
author maintainer
#2 lore raw

PATCH 2/2 idpf: avoid compiler introduced padding in virtchnl2_rss_key struct

In reply to Tony Nguyen

From: Pavan Kumar Linga <[email protected]>

Size of the virtchnl2_rss_key struct should be 7 bytes but the compiler introduces a padding byte for the structure alignment. This results in idpf sending an additional byte of memory to the device control plane than the expected buffer size. As the control plane enforces virtchnl message size checks to validate the message, set RSS key message fails resulting in the driver load failure.

Remove implicit compiler padding by using "__packed" structure attribute for the virtchnl2_rss_key struct.

Also there is no need to use __DECLARE_FLEX_ARRAY macro for the 'key_flex' struct field. So drop it.

Fixes 0d7502a9b4a7 ("virtchnl: add virtchnl version 2 ops")
---
 drivers/net/ethernet/intel/idpf/virtchnl2.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/idpf/virtchnl2.h +3 -3
index 07e72c72d156..8dc837889723 100644
@@ -1104,9 +1104,9 @@ struct virtchnl2_rss_key {
 	__le32 vport_id;
 	__le16 key_len;
 	u8 pad;
-	__DECLARE_FLEX_ARRAY(u8, key_flex);
-};
-VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_rss_key);
+	u8 key_flex[];
+} __packed;
+VIRTCHNL2_CHECK_STRUCT_LEN(7, virtchnl2_rss_key);
 
 /**
  * struct virtchnl2_queue_chunk - chunk of contiguous queues
Signature · 1 line
2.41.0
#3 lore raw
In reply to Tony Nguyen
This series was applied to netdev/net.git (main) by Tony Nguyen <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Tony Nguyen <[email protected]>:

Quoted 9 lines · On Tue, 26 Dec 2023 09:41:22 -0800 you wrote:

This series contains updates to idpf driver only.

Alexander resolves issues in singleq mode to prevent corrupted frames and leaking skbs.

Pavan prevents extra padding on RSS struct causing load failure due to unexpected size.

[...]

Here is the summary with links:
- [net,1/2] idpf: fix corrupted frames and skb leaks in singleq mode

    https://git.kernel.org/netdev/net/c/fea7b71b8751
  - [net,2/2] idpf: avoid compiler introduced padding in virtchnl2_rss_key struct
    https://git.kernel.org/netdev/net/c/a613fb464dc4

You are awesome, thank you!

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