Message ID | 1fcce0a60b231ebeb2515d91022284ba7b4ffe7a.1713797103.git.petrm@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 79b5b4b18bc85b19d3a518483f9abbbe6d7b3ba4 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | mlxsw: Various ACL fixes | expand |
On Mon, Apr 22, 2024 at 05:25:56PM +0200, Petr Machata wrote: > From: Ido Schimmel <idosch@nvidia.com> > > The rule activity update delayed work periodically traverses the list of > configured rules and queries their activity from the device. > > As part of this task it accesses the entry pointed by 'ventry->entry', > but this entry can be changed concurrently by the rehash delayed work, > leading to a use-after-free [1]. > > Fix by closing the race and perform the activity query under the > 'vregion->lock' mutex. > > [1] > BUG: KASAN: slab-use-after-free in mlxsw_sp_acl_tcam_flower_rule_activity_get+0x121/0x140 ... > Fixes: 2bffc5322fd8 ("mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()") > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > Tested-by: Alexander Zubkov <green@qrator.net> > Reviewed-by: Petr Machata <petrm@nvidia.com> > Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> ...
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index 9c0c728bb42d..7e69225c057d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -1159,8 +1159,14 @@ mlxsw_sp_acl_tcam_ventry_activity_get(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_ventry *ventry, bool *activity) { - return mlxsw_sp_acl_tcam_entry_activity_get(mlxsw_sp, - ventry->entry, activity); + struct mlxsw_sp_acl_tcam_vregion *vregion = ventry->vchunk->vregion; + int err; + + mutex_lock(&vregion->lock); + err = mlxsw_sp_acl_tcam_entry_activity_get(mlxsw_sp, ventry->entry, + activity); + mutex_unlock(&vregion->lock); + return err; } static int