OSDN Git Service

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)
commitfd3307130344ef5fa5af0089d343ca4fc074322e
treeff6d37b177bedb97d527446b48d4d6b6efb58e7c
parent4972e6fa3a04032830bc3d6bb343d08ab3546773
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: 6e5e22839136 ("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