Message ID | 20231205061327.44638-9-saeed@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,V2,01/14] net/mlx5e: Honor user choice of IPsec replay window size | expand |
Saeed Mahameed <saeed@kernel.org> wrote: > From: Jianbo Liu <jianbol@nvidia.com> > > After IPSec TX tables are destroyed, the flow rules in TC rhashtable, > which have the destination to IPSec, are restored to the original > one, the uplink. > > However, when the device is in switchdev mode and unload driver with > IPSec rules configured, TC rhashtable cleanup is done before IPSec > cleanup, which means tc_ht->tbl is already freed when walking TC > rhashtable, in order to restore the destination. So add the checking > before walking to avoid unexpected behavior. I'm confused. If the rhashtable has already been freed, then surely you can't even read nelems? Cheers,
On Fri, 2023-12-08 at 12:47 +0800, Herbert Xu wrote: > Saeed Mahameed <saeed@kernel.org> wrote: > > From: Jianbo Liu <jianbol@nvidia.com> > > > > After IPSec TX tables are destroyed, the flow rules in TC > > rhashtable, > > which have the destination to IPSec, are restored to the original > > one, the uplink. > > > > However, when the device is in switchdev mode and unload driver > > with > > IPSec rules configured, TC rhashtable cleanup is done before IPSec > > cleanup, which means tc_ht->tbl is already freed when walking TC > > rhashtable, in order to restore the destination. So add the > > checking > > before walking to avoid unexpected behavior. > > I'm confused. If the rhashtable has already been freed, then > surely you can't even read nelems? > I think we can as rhashtable struct, not its pointer is declared in rpriv, and rpriv is not freed. Anyway, this patch was dropped in V3. Thanks! Jianbo > > Cheers,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c index 5a0047bdcb51..190f10aba170 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c @@ -152,7 +152,7 @@ void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev) xa_for_each(&esw->offloads.vport_reps, i, rep) { rpriv = rep->rep_data[REP_ETH].priv; - if (!rpriv || !rpriv->netdev) + if (!rpriv || !rpriv->netdev || !atomic_read(&rpriv->tc_ht.nelems)) continue; rhashtable_walk_enter(&rpriv->tc_ht, &iter);