git: a592812327de - main - mlx5_core: fix deadlock when using RXTLS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Nov 2023 11:17:50 UTC
The branch main has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=a592812327deaf69ab226afc5c8a01af43dc03c2 commit a592812327deaf69ab226afc5c8a01af43dc03c2 Author: Martin Matuska <mm@FreeBSD.org> AuthorDate: 2023-11-13 13:29:27 +0000 Commit: Martin Matuska <mm@FreeBSD.org> CommitDate: 2023-11-16 11:17:41 +0000 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 --- sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 5966a73c58d1..b76ea7b60582 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -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); }