]> git.baikalelectronics.ru Git - kernel.git/commit
net/sched: tcindex: update imperfect hash filters respecting rcu
authorPedro Tammela <pctammela@mojatatu.com>
Thu, 9 Feb 2023 14:37:39 +0000 (11:37 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:59:52 +0000 (12:59 +0100)
commitdce9c9cccc06d28e9e0ce80fffb44c26056eff79
tree334a6d685f9df6b012937f4ea9281a724f1d2961
parent257cefbac4086ee60f89964781d45841b42af573
net/sched: tcindex: update imperfect hash filters respecting rcu

commit a360550222867a1c23864561681ae9c601fdf2e9 upstream.

The imperfect hash area can be updated while packets are traversing,
which will cause a use-after-free when 'tcf_exts_exec()' is called
with the destroyed tcf_ext.

CPU 0:               CPU 1:
tcindex_set_parms    tcindex_classify
tcindex_lookup
                     tcindex_lookup
tcf_exts_change
                     tcf_exts_exec [UAF]

Stop operating on the shared area directly, by using a local copy,
and update the filter with 'rcu_replace_pointer()'. Delete the old
filter version only after a rcu grace period elapsed.

Fixes: 865cd087b2ea ("net: sched: avoid atomic swap in tcf_exts_change")
Reported-by: valis <sec@valis.email>
Suggested-by: valis <sec@valis.email>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Link: https://lore.kernel.org/r/20230209143739.279867-1-pctammela@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/cls_tcindex.c