mlx5_core: fix deadlock when using RXTLS

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
This commit is contained in:
Martin Matuska 2023-11-13 14:29:27 +01:00
parent a6ed8c9593
commit a592812327

View file

@ -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);
}
}
@ -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);
@ -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);
}