Skip to content

Commit

Permalink
mlx5_core: fix deadlock when using RXTLS
Browse files Browse the repository at this point in the history
If removing a node of type FS_TYPE_FLOW_DEST we lock the flow group too
late. This can lead to a deadlock with fs_add_dst_fg().

PR:		274715
MFC after:	1 week
Reviewed by:	kib
Tested by:	mm
Differential Revision: https://reviews.freebsd.org/D42368
  • Loading branch information
mmatuska committed Nov 16, 2023
1 parent a6ed8c9 commit a592812
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,19 @@ static void __fs_remove_node(struct kref *kref)
{
struct fs_base *node = container_of(kref, struct fs_base, refcount);

if (node->parent)
if (node->parent) {
if (node->type == FS_TYPE_FLOW_DEST)
mutex_lock(&node->parent->parent->lock);
mutex_lock(&node->parent->lock);
}
mutex_lock(&node->lock);
cmd_remove_node(node);
mutex_unlock(&node->lock);
complete(&node->complete);
if (node->parent) {
mutex_unlock(&node->parent->lock);
if (node->type == FS_TYPE_FLOW_DEST)
mutex_unlock(&node->parent->parent->lock);
_fs_put(node->parent, _fs_remove_node, false);
}
}
Expand Down Expand Up @@ -1719,7 +1724,7 @@ static void fs_del_dst(struct mlx5_flow_rule *dst)

fs_get_parent(fte, dst);
fs_get_parent(fg, fte);
mutex_lock(&fg->base.lock);
sx_assert(&fg->base.lock.sx, SX_XLOCKED);
memcpy(match_value, fte->val, sizeof(fte->val));
/* ft can't be changed as fg is locked */
fs_get_parent(ft, fg);
Expand All @@ -1739,7 +1744,6 @@ static void fs_del_dst(struct mlx5_flow_rule *dst)
}
call_to_del_rule_notifiers(dst, fte);
err:
mutex_unlock(&fg->base.lock);
kvfree(match_value);
}

Expand Down

0 comments on commit a592812

Please sign in to comment.