]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
mlxsw: spectrum_acl_tcam: Fix race in region ID allocation
authorIdo Schimmel <idosch@nvidia.com>
Mon, 22 Apr 2024 15:25:54 +0000 (17:25 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Apr 2024 02:32:59 +0000 (19:32 -0700)
commit627f9c1bb882765a84aa78015abbacd783d429be
tree7a9997f9954fe8cc03fc1def33ad7339699db305
parent5ea7b72d4fac2fdbc0425cd8f2ea33abe95235b2
mlxsw: spectrum_acl_tcam: Fix race in region ID allocation

Region identifiers can be allocated both when user space tries to insert
a new tc filter and when filters are migrated from one region to another
as part of the rehash delayed work.

There is no lock protecting the bitmap from which these identifiers are
allocated from, which is racy and leads to bad parameter errors from the
device's firmware.

Fix by converting the bitmap to IDA which handles its own locking. For
consistency, do the same for the group identifiers that are part of the
same structure.

Fixes: 2bffc5322fd8 ("mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()")
Reported-by: Amit Cohen <amcohen@nvidia.com>
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>
Link: https://lore.kernel.org/r/ce494b7940cadfe84f3e18da7785b51ef5f776e3.1713797103.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h