]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5: Take fs_counters dellist before addlist
authorVlad Buslov <vladbu@mellanox.com>
Wed, 26 Sep 2018 10:09:44 +0000 (13:09 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 18 Oct 2018 20:13:31 +0000 (13:13 -0700)
commit8ee73141271d124aba09ed2b89c90ff661d18a86
treeff6d37b177bedb97d527446b48d4d6b6efb58e7c
parent9b7810f7658797ca0d0aea8623dea0ee2033f12a
net/mlx5: Take fs_counters dellist before addlist

In fs_counters elements from both addlist and dellist are removed by
mlx5_fc_stats_work() without any locking. This introduces race condition
when batch of new rules is created and then immediately deleted (for
example, when error occurred during flow creation). In such case some of
the rules might be in dellist, but not in addlist when mlx5_fc_stats_work()
is executed concurrently with tc, which will result rule deletion and
use-after-free on next iteration because deleted rules are still in
addlist.

Always take dellist first to guarantee that rules can only be deleted after
they were removed from addlist.

Fixes: feb4f0f626dd ("net/mlx5: Add new list to store deleted flow counters")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Reported-by: Chris Mi <chrism@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c