netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf)
@ 2023-12-26 17:41 Tony Nguyen
  2023-12-26 17:41 ` [PATCH net 1/2] idpf: fix corrupted frames and skb leaks in singleq mode Tony Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tony Nguyen @ 2023-12-26 17:41 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev; +Cc: Tony Nguyen

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(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] idpf: fix corrupted frames and skb leaks in singleq mode
  2023-12-26 17:41 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) Tony Nguyen
@ 2023-12-26 17:41 ` Tony Nguyen
  2023-12-26 17:41 ` [PATCH net 2/2] idpf: avoid compiler introduced padding in virtchnl2_rss_key struct Tony Nguyen
  2024-01-04  1:00 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Nguyen @ 2023-12-26 17:41 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Alexander Lobakin, anthony.l.nguyen, willemb, Przemek Kitszel,
	Michal Kubiak, Simon Horman, Scott Register

From: Alexander Lobakin <aleksander.lobakin@intel.com>

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.

Fixes: a5ab9ee0df0b ("idpf: add singleq start_xmit and napi poll")
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Tested-by: Scott Register <scott.register@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 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(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
index 81288a17da2a..20c4b3a64710 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
@@ -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
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index 1f728a9004d9..9e942e5baf39 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -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;
 	}
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] idpf: avoid compiler introduced padding in virtchnl2_rss_key struct
  2023-12-26 17:41 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) Tony Nguyen
  2023-12-26 17:41 ` [PATCH net 1/2] idpf: fix corrupted frames and skb leaks in singleq mode Tony Nguyen
@ 2023-12-26 17:41 ` Tony Nguyen
  2024-01-04  1:00 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Nguyen @ 2023-12-26 17:41 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Pavan Kumar Linga, anthony.l.nguyen, willemb, Larysa Zaremba,
	Simon Horman, Scott Register

From: Pavan Kumar Linga <pavan.kumar.linga@intel.com>

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")
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Scott Register <scott.register@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/idpf/virtchnl2.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/virtchnl2.h b/drivers/net/ethernet/intel/idpf/virtchnl2.h
index 07e72c72d156..8dc837889723 100644
--- a/drivers/net/ethernet/intel/idpf/virtchnl2.h
+++ b/drivers/net/ethernet/intel/idpf/virtchnl2.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf)
  2023-12-26 17:41 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) Tony Nguyen
  2023-12-26 17:41 ` [PATCH net 1/2] idpf: fix corrupted frames and skb leaks in singleq mode Tony Nguyen
  2023-12-26 17:41 ` [PATCH net 2/2] idpf: avoid compiler introduced padding in virtchnl2_rss_key struct Tony Nguyen
@ 2024-01-04  1:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-04  1:00 UTC (permalink / raw)
  To: Tony Nguyen; +Cc: davem, kuba, pabeni, edumazet, netdev

Hello:

This series was applied to netdev/net.git (main)
by Tony Nguyen <anthony.l.nguyen@intel.com>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-04  1:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-26 17:41 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) Tony Nguyen
2023-12-26 17:41 ` [PATCH net 1/2] idpf: fix corrupted frames and skb leaks in singleq mode Tony Nguyen
2023-12-26 17:41 ` [PATCH net 2/2] idpf: avoid compiler introduced padding in virtchnl2_rss_key struct Tony Nguyen
2024-01-04  1:00 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2023-12-26 (idpf) patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).