]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
net: sched: fix action overwrite reference counting
authorVlad Buslov <vladbu@nvidia.com>
Wed, 7 Apr 2021 15:36:03 +0000 (18:36 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 May 2021 07:53:26 +0000 (09:53 +0200)
commitbc3a79174c0654a88f775491325c6fda0a04d156
tree48971e92a73f346f65eb90b5923dc99c76206daa
parent6de68970d77749910837bbd6dece866458ead1af
net: sched: fix action overwrite reference counting

BugLink: https://bugs.launchpad.net/bugs/1926368
commit 87c750e8c38bce706eb32e4d8f1e3402f2cebbd4 upstream.

Action init code increments reference counter when it changes an action.
This is the desired behavior for cls API which needs to obtain action
reference for every classifier that points to action. However, act API just
needs to change the action and releases the reference before returning.
This sequence breaks when the requested action doesn't exist, which causes
act API init code to create new action with specified index, but action is
still released before returning and is deleted (unless it was referenced
concurrently by cls API).

Reproduction:

$ sudo tc actions ls action gact
$ sudo tc actions change action gact drop index 1
$ sudo tc actions ls action gact

Extend tcf_action_init() to accept 'init_res' array and initialize it with
action->ops->init() result. In tcf_action_add() remove pointers to created
actions from actions array before passing it to tcf_action_put_many().

Fixes: cae422f379f3 ("net: sched: use reference counting action init")
Reported-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Vlad Buslov <vladbu@nvidia.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: Stefan Bader <stefan.bader@canonical.com>
include/net/act_api.h
net/sched/act_api.c
net/sched/cls_api.c