public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference
@ 2025-10-15  7:05 Tariq Toukan
  2025-10-15  7:34 ` Michal Swiatkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tariq Toukan @ 2025-10-15  7:05 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
	David S. Miller
  Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
	linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
	Dragos Tatulea, Cosmin Ratiu

From: Cosmin Ratiu <cratiu@nvidia.com>

The 'accel' parameter of mlx5e_txwqe_build_eseg_csum() and the similar
'state' parameter of mlx5e_accel_tx_ids_len() were NULL when called
from mlx5i_sq_xmit() and were causing kernel panics from that context.

Fix that by passing in a local empty mlx5e_accel_tx_state variable, thus
guaranteeing that 'accel' is never NULL. Also remove an unnecessary
check from mlx5e_tx_wqe_inline_mode().

Fixes: e5a1861a298e ("net/mlx5e: Implement PSP Tx data path")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index b7227afcb51d..2702b3885f06 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -256,7 +256,7 @@ mlx5e_tx_wqe_inline_mode(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 	u8 mode;
 
 #ifdef CONFIG_MLX5_EN_TLS
-	if (accel && accel->tls.tls_tisn)
+	if (accel->tls.tls_tisn)
 		return MLX5_INLINE_MODE_TCP_UDP;
 #endif
 
@@ -982,6 +982,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 	struct mlx5e_tx_attr attr;
 	struct mlx5i_tx_wqe *wqe;
 
+	struct mlx5e_accel_tx_state accel = {};
 	struct mlx5_wqe_datagram_seg *datagram;
 	struct mlx5_wqe_ctrl_seg *cseg;
 	struct mlx5_wqe_eth_seg  *eseg;
@@ -992,7 +993,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 	int num_dma;
 	u16 pi;
 
-	mlx5e_sq_xmit_prepare(sq, skb, NULL, &attr);
+	mlx5e_sq_xmit_prepare(sq, skb, &accel, &attr);
 	mlx5i_sq_calc_wqe_attr(skb, &attr, &wqe_attr);
 
 	pi = mlx5e_txqsq_get_next_pi(sq, wqe_attr.num_wqebbs);
@@ -1009,7 +1010,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 
 	mlx5i_txwqe_build_datagram(av, dqpn, dqkey, datagram);
 
-	mlx5e_txwqe_build_eseg_csum(sq, skb, NULL, eseg);
+	mlx5e_txwqe_build_eseg_csum(sq, skb, &accel, eseg);
 
 	eseg->mss = attr.mss;
 

base-commit: 7f0fddd817ba6daebea1445ae9fab4b6d2294fa8
-- 
2.31.1


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

* Re: [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference
  2025-10-15  7:05 [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference Tariq Toukan
@ 2025-10-15  7:34 ` Michal Swiatkowski
  2025-10-15 11:44 ` Markus Elfring
  2025-10-16 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Swiatkowski @ 2025-10-15  7:34 UTC (permalink / raw)
  To: Tariq Toukan
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
	David S. Miller, Saeed Mahameed, Mark Bloch, Leon Romanovsky,
	netdev, linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
	Dragos Tatulea, Cosmin Ratiu

On Wed, Oct 15, 2025 at 10:05:23AM +0300, Tariq Toukan wrote:
> From: Cosmin Ratiu <cratiu@nvidia.com>
> 
> The 'accel' parameter of mlx5e_txwqe_build_eseg_csum() and the similar
> 'state' parameter of mlx5e_accel_tx_ids_len() were NULL when called
> from mlx5i_sq_xmit() and were causing kernel panics from that context.
> 
> Fix that by passing in a local empty mlx5e_accel_tx_state variable, thus
> guaranteeing that 'accel' is never NULL. Also remove an unnecessary
> check from mlx5e_tx_wqe_inline_mode().
> 
> Fixes: e5a1861a298e ("net/mlx5e: Implement PSP Tx data path")
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> index b7227afcb51d..2702b3885f06 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> @@ -256,7 +256,7 @@ mlx5e_tx_wqe_inline_mode(struct mlx5e_txqsq *sq, struct sk_buff *skb,
>  	u8 mode;
>  
>  #ifdef CONFIG_MLX5_EN_TLS
> -	if (accel && accel->tls.tls_tisn)
> +	if (accel->tls.tls_tisn)
>  		return MLX5_INLINE_MODE_TCP_UDP;
>  #endif
>  
> @@ -982,6 +982,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
>  	struct mlx5e_tx_attr attr;
>  	struct mlx5i_tx_wqe *wqe;
>  
> +	struct mlx5e_accel_tx_state accel = {};
>  	struct mlx5_wqe_datagram_seg *datagram;
>  	struct mlx5_wqe_ctrl_seg *cseg;
>  	struct mlx5_wqe_eth_seg  *eseg;
> @@ -992,7 +993,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
>  	int num_dma;
>  	u16 pi;
>  
> -	mlx5e_sq_xmit_prepare(sq, skb, NULL, &attr);
> +	mlx5e_sq_xmit_prepare(sq, skb, &accel, &attr);
>  	mlx5i_sq_calc_wqe_attr(skb, &attr, &wqe_attr);
>  
>  	pi = mlx5e_txqsq_get_next_pi(sq, wqe_attr.num_wqebbs);
> @@ -1009,7 +1010,7 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
>  
>  	mlx5i_txwqe_build_datagram(av, dqpn, dqkey, datagram);
>  
> -	mlx5e_txwqe_build_eseg_csum(sq, skb, NULL, eseg);
> +	mlx5e_txwqe_build_eseg_csum(sq, skb, &accel, eseg);
>  
>  	eseg->mss = attr.mss;

Looks good
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

>  
> 
> base-commit: 7f0fddd817ba6daebea1445ae9fab4b6d2294fa8
> -- 
> 2.31.1

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

* Re: [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference
  2025-10-15  7:05 [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference Tariq Toukan
  2025-10-15  7:34 ` Michal Swiatkowski
@ 2025-10-15 11:44 ` Markus Elfring
  2025-10-16 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-10-15 11:44 UTC (permalink / raw)
  To: Cosmin Ratiu, Dragos Tatulea, Tariq Toukan, netdev, linux-rdma
  Cc: LKML, Andrew Lunn, David S. Miller, Eric Dumazet, Gal Pressman,
	Jakub Kicinski, Leon Romanovsky, Mark Bloch, Moshe Shemesh,
	Paolo Abeni, Saeed Mahameed

…
> guaranteeing that 'accel' is never NULL. Also remove an unnecessary
> check from mlx5e_tx_wqe_inline_mode().

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17#n81

Regards,
Markus

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

* Re: [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference
  2025-10-15  7:05 [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference Tariq Toukan
  2025-10-15  7:34 ` Michal Swiatkowski
  2025-10-15 11:44 ` Markus Elfring
@ 2025-10-16 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-16 22:50 UTC (permalink / raw)
  To: Tariq Toukan
  Cc: edumazet, kuba, pabeni, andrew+netdev, davem, saeedm, mbloch,
	leon, netdev, linux-rdma, linux-kernel, gal, moshe, dtatulea,
	cratiu

Hello:

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

On Wed, 15 Oct 2025 10:05:23 +0300 you wrote:
> From: Cosmin Ratiu <cratiu@nvidia.com>
> 
> The 'accel' parameter of mlx5e_txwqe_build_eseg_csum() and the similar
> 'state' parameter of mlx5e_accel_tx_ids_len() were NULL when called
> from mlx5i_sq_xmit() and were causing kernel panics from that context.
> 
> Fix that by passing in a local empty mlx5e_accel_tx_state variable, thus
> guaranteeing that 'accel' is never NULL. Also remove an unnecessary
> check from mlx5e_tx_wqe_inline_mode().
> 
> [...]

Here is the summary with links:
  - [net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference
    https://git.kernel.org/netdev/net/c/5348d6312446

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:[~2025-10-16 22:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15  7:05 [PATCH net] net/mlx5e: psp, avoid 'accel' NULL pointer dereference Tariq Toukan
2025-10-15  7:34 ` Michal Swiatkowski
2025-10-15 11:44 ` Markus Elfring
2025-10-16 22:50 ` 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