mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
net/mlx5e: Fix use-after-free race in sample_restore_put()
Concurrent teardown of TC sample rules sharing the same restore
context may re-read restore->count after dropping restore_lock.
At that point another thread may already have completed cleanup and
freed the restore object.
Use the result of the refcount decrement while holding restore_lock to
determine whether cleanup is needed.
Fixes: 36a3196256 ("net/mlx5e: TC, Add sampler restore handle API")
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Shahar Shitrit <shshitrit@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260902193341.3668809-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
e7ee897408
commit
af3aef0245
|
|
@ -311,12 +311,15 @@ sample_restore_get(struct mlx5e_tc_psample *tc_psample, u32 obj_id,
|
|||
static void
|
||||
sample_restore_put(struct mlx5e_tc_psample *tc_psample, struct mlx5e_sample_restore *restore)
|
||||
{
|
||||
bool last;
|
||||
|
||||
mutex_lock(&tc_psample->restore_lock);
|
||||
if (--restore->count == 0)
|
||||
last = --restore->count == 0;
|
||||
if (last)
|
||||
hash_del(&restore->hlist);
|
||||
mutex_unlock(&tc_psample->restore_lock);
|
||||
|
||||
if (!restore->count) {
|
||||
if (last) {
|
||||
mlx5_del_flow_rules(restore->rule);
|
||||
mlx5_modify_header_dealloc(tc_psample->esw->dev, restore->modify_hdr);
|
||||
kfree(restore);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user