diff options
author | Vlad Buslov <vladbu@mellanox.com> | 2019-08-27 21:49:38 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-08-28 15:53:51 -0700 |
commit | dbf47a2a094edf58983265e323ca4bdcdb58b5ee (patch) | |
tree | 4d67881165f57063cadc0456b7c7e5c8be0b5090 /net/psample | |
parent | 36f1031c51a2538e5558fb44c6d6b88f98d3c0f2 (diff) |
net: sched: act_sample: fix psample group handling on overwrite
Action sample doesn't properly handle psample_group pointer in overwrite
case. Following issues need to be fixed:
- In tcf_sample_init() function RCU_INIT_POINTER() is used to set
s->psample_group, even though we neither setting the pointer to NULL, nor
preventing concurrent readers from accessing the pointer in some way.
Use rcu_swap_protected() instead to safely reset the pointer.
- Old value of s->psample_group is not released or deallocated in any way,
which results resource leak. Use psample_group_put() on non-NULL value
obtained with rcu_swap_protected().
- The function psample_group_put() that released reference to struct
psample_group pointed by rcu-pointer s->psample_group doesn't respect rcu
grace period when deallocating it. Extend struct psample_group with rcu
head and use kfree_rcu when freeing it.
Fixes: 5c5670fae430 ("net/sched: Introduce sample tc action")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/psample')
-rw-r--r-- | net/psample/psample.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/psample/psample.c b/net/psample/psample.c index 841f198ea1a8..66e4b61a350d 100644 --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -154,7 +154,7 @@ static void psample_group_destroy(struct psample_group *group) { psample_group_notify(group, PSAMPLE_CMD_DEL_GROUP); list_del(&group->list); - kfree(group); + kfree_rcu(group, rcu); } static struct psample_group * |