public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Fix tainted pointer delete is case of flow rules creation fail
@ 2024-06-04 10:05 Aleksandr Mishin
  2024-06-04 21:58 ` Jacob Keller
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aleksandr Mishin @ 2024-06-04 10:05 UTC (permalink / raw)
  To: Mark Bloch
  Cc: Aleksandr Mishin, Saeed Mahameed, Leon Romanovsky, Tariq Toukan,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maor Gottlieb, Jacob Keller, Shay Drory, Jianbo Liu, Jinjie Ruan,
	netdev, linux-rdma, linux-kernel, lvc-project

In case of flow rule creation fail in mlx5_lag_create_port_sel_table(),
instead of previously created rules, the tainted pointer is deleted
deveral times.
Fix this bug by using correct flow rules pointers.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 352899f384d4 ("net/mlx5: Lag, use buckets in hash mode")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
index c16b462ddedf..ab2717012b79 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
@@ -88,9 +88,13 @@ static int mlx5_lag_create_port_sel_table(struct mlx5_lag *ldev,
 								      &dest, 1);
 			if (IS_ERR(lag_definer->rules[idx])) {
 				err = PTR_ERR(lag_definer->rules[idx]);
-				while (i--)
-					while (j--)
+				do {
+					while (j--) {
+						idx = i * ldev->buckets + j;
 						mlx5_del_flow_rules(lag_definer->rules[idx]);
+					}
+					j = ldev->buckets;
+				} while (i--);
 				goto destroy_fg;
 			}
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-05 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 10:05 [PATCH net] net/mlx5: Fix tainted pointer delete is case of flow rules creation fail Aleksandr Mishin
2024-06-04 21:58 ` Jacob Keller
2024-06-05  5:14 ` Tariq Toukan
2024-06-05 21:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox