All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
@ 2023-05-24 19:49 Thomas Bogendoerfer
  2023-05-25  8:42 ` Simon Horman
  2023-05-26  4:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2023-05-24 19:49 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Asmaa Mnebhi, Liming Sun, David Thompson, netdev, linux-kernel

Do skb_put() after a new skb has been successfully allocated otherwise
the reused skb leads to skb_panics or incorrect packet sizes.

Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
Changes in v2:
- moved skb_put() after dma_unmap_single()
- added Fixes tag
- fixed typos in commit log

 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
index afa3b92a6905..0d5a41a2ae01 100644
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
@@ -245,12 +245,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
 
 		skb = priv->rx_skb[rx_pi_rem];
 
-		skb_put(skb, datalen);
-
-		skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
-
-		skb->protocol = eth_type_trans(skb, netdev);
-
 		/* Alloc another RX SKB for this same index */
 		rx_skb = mlxbf_gige_alloc_skb(priv, MLXBF_GIGE_DEFAULT_BUF_SZ,
 					      &rx_buf_dma, DMA_FROM_DEVICE);
@@ -259,6 +253,13 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
 		priv->rx_skb[rx_pi_rem] = rx_skb;
 		dma_unmap_single(priv->dev, *rx_wqe_addr,
 				 MLXBF_GIGE_DEFAULT_BUF_SZ, DMA_FROM_DEVICE);
+
+		skb_put(skb, datalen);
+
+		skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
+
+		skb->protocol = eth_type_trans(skb, netdev);
+
 		*rx_wqe_addr = rx_buf_dma;
 	} else if (rx_cqe & MLXBF_GIGE_RX_CQE_PKT_STATUS_MAC_ERR) {
 		priv->stats.rx_mac_errors++;
-- 
2.35.3


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

* Re: [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
  2023-05-24 19:49 [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure Thomas Bogendoerfer
@ 2023-05-25  8:42 ` Simon Horman
  2023-05-26  4:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-05-25  8:42 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Asmaa Mnebhi, Liming Sun, David Thompson, netdev, linux-kernel

On Wed, May 24, 2023 at 09:49:08PM +0200, Thomas Bogendoerfer wrote:
> Do skb_put() after a new skb has been successfully allocated otherwise
> the reused skb leads to skb_panics or incorrect packet sizes.
> 
> Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


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

* Re: [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
  2023-05-24 19:49 [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure Thomas Bogendoerfer
  2023-05-25  8:42 ` Simon Horman
@ 2023-05-26  4:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-26  4:10 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: davem, edumazet, kuba, pabeni, asmaa, limings, davthompson,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 24 May 2023 21:49:08 +0200 you wrote:
> Do skb_put() after a new skb has been successfully allocated otherwise
> the reused skb leads to skb_panics or incorrect packet sizes.
> 
> Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
> Changes in v2:
> - moved skb_put() after dma_unmap_single()
> - added Fixes tag
> - fixed typos in commit log
> 
> [...]

Here is the summary with links:
  - [v2,net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
    https://git.kernel.org/netdev/net/c/d68cb7cf1fd0

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] 3+ messages in thread

end of thread, other threads:[~2023-05-26  4:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 19:49 [PATCH v2 net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure Thomas Bogendoerfer
2023-05-25  8:42 ` Simon Horman
2023-05-26  4:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.