net/mlx5e: Fix eswitch mode block underflow on IPsec acquire SA
Subsystems (5)
PATCH 1/1 net/mlx5e: Fix eswitch mode block underflow on IPsec acquire SA
mlx5e_xfrm_add_state() handles acquire-flow temporary SAs by allocating software state and skipping hardware offload setup.
That path jumps to the common success label before taking the eswitch mode block. After tunnel-mode validation was moved earlier, the common success label unconditionally calls mlx5_eswitch_unblock_mode(). For acquire SAs, this decrements esw->offloads.num_block_mode without a matching increment.
Return directly after installing the acquire SA offload handle, so only the paths that successfully called mlx5_eswitch_block_mode() call the matching unblock.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +4 -3
@@ -792,8 +792,10 @@ static int mlx5e_xfrm_add_state(struct net_device *dev, sa_entry->dev = dev; sa_entry->ipsec = ipsec;/* Check if this SA is originated from acquire flow temporary SA */ -if (x->xso.flags &XFRM_DEV_OFFLOAD_FLAG_ACQ ) - goto out; +if (x->xso.flags &XFRM_DEV_OFFLOAD_FLAG_ACQ ) { + x->xso.offload_handle = (unsigned long )sa_entry; +return 0 ; + } err =mlx5e_xfrm_validate_state (priv->mdev, x, extack);if (err)
@@ -870,7 +872,6 @@ static int mlx5e_xfrm_add_state(struct net_device *dev,xa_unlock_bh (&ipsec->sadb); } -out: x->xso.offload_handle = (unsigned long )sa_entry;if (allow_tunnel_mode)mlx5_eswitch_unblock_encap (priv->mdev);
Signature · 1 line
2.43.0
Quoted 8 lines · Prathamesh Deshpande
mlx5e_xfrm_add_state()handles acquire-flow temporary SAs by allocating software state and skipping hardware offload setup.That path jumps to the common success label before taking the eswitch mode block. After tunnel-mode validation was moved earlier, the common success label unconditionally calls
mlx5_eswitch_unblock_mode(). For acquire SAs, this decrementsesw->offloads.num_block_modewithout a matching increment.
Quoted 6 lines
Return directly after installing the acquire SA offload handle, so only the paths that successfully called
mlx5_eswitch_block_mode()call the matching unblock.Fixes 22239eb258bc ("net/mlx5e: Prevent tunnel reformat when tunnel mode not allowed")Signed-off-by Prathamesh Deshpande <[email protected]>
Quoted 36 lines · Prathamesh Deshpande
mlx5e_xfrm_add_state()handles acquire-flow temporary SAs by allocating software state and skipping hardware offload setup.That path jumps to the common success label before taking the eswitch mode block. After tunnel-mode validation was moved earlier, the common success label unconditionally calls
mlx5_eswitch_unblock_mode(). For acquire SAs, this decrementsesw->offloads.num_block_modewithout a matching increment.Return directly after installing the acquire SA offload handle, so only the paths that successfully called
mlx5_eswitch_block_mode()call the matching unblock.Fixes 22239eb258bc ("net/mlx5e: Prevent tunnel reformat when tunnel mode not allowed")Signed-off-by Prathamesh Deshpande <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +4
-2@@ -792,8 +792,10 @@ static int mlx5e_xfrm_add_state(struct net_device *dev, sa_entry->dev = dev; sa_entry->ipsec = ipsec;/* Check if this SA is originated from acquire flow temporary SA */ -if (x->xso.flags &XFRM_DEV_OFFLOAD_FLAG_ACQ ) - goto out; +if (x->xso.flags &XFRM_DEV_OFFLOAD_FLAG_ACQ ) { + x->xso.offload_handle = (unsigned long )sa_entry; +return 0 ; + } err =mlx5e_xfrm_validate_state (priv->mdev, x, extack);if (err)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c static int mlx5e_xfrm_add_state(struct net_device *dev, · line 877
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +0
-1@@ -870,7 +872,6 @@ static int mlx5e_xfrm_add_state(struct net_device *dev,xa_unlock_bh (&ipsec->sadb); } -out: x->xso.offload_handle = (unsigned long )sa_entry;if (allow_tunnel_mode)mlx5_eswitch_unblock_encap (priv->mdev);
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sun, 10 May 2026 23:59:00 +0100 you wrote:
mlx5e_xfrm_add_state()handles acquire-flow temporary SAs by allocating software state and skipping hardware offload setup.That path jumps to the common success label before taking the eswitch mode block. After tunnel-mode validation was moved earlier, the common success label unconditionally calls
mlx5_eswitch_unblock_mode(). For acquire SAs, this decrementsesw->offloads.num_block_modewithout a matching increment.[...]
Here is the summary with links:
- [net,v1] net/mlx5e: Fix eswitch mode block underflow on IPsec acquire SA
https://git.kernel.org/netdev/net/c/abe003b33223
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html