]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
net: sched: act_sample: fix psample group handling on overwrite
authorVlad Buslov <vladbu@mellanox.com>
Tue, 27 Aug 2019 18:49:38 +0000 (21:49 +0300)
committerKhalid Elmously <khalid.elmously@canonical.com>
Thu, 26 Sep 2019 04:34:52 +0000 (00:34 -0400)
commita0c82d24c03cacaa32a28605783e2237e7afe9e9
treecce917a37b467a812a2dade5be9becb48b0614c1
parent1a9da7d8b2be36648865f5a0e03203b6f9bdae66
net: sched: act_sample: fix psample group handling on overwrite

BugLink: https://bugs.launchpad.net/bugs/1843463
[ Upstream commit dbf47a2a094edf58983265e323ca4bdcdb58b5ee ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
include/net/psample.h
net/psample/psample.c
net/sched/act_sample.c