]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/sched: act_api: fix TOCTOU NULL deref on a->goto_chain
authorJamal Hadi Salim <jhs@mojatatu.com>
Sun, 9 Aug 2026 09:09:28 +0000 (05:09 -0400)
committerJakub Kicinski <kuba@kernel.org>
Wed, 12 Aug 2026 01:21:46 +0000 (18:21 -0700)
commitf60b396ee174206fe08ebf997d16cd3801b77b22
treefb1426e742fe3ea0799f5868650a64eb67550428
parent6bcd76c134c55c697148acb5c0194e9666abdf84
net/sched: act_api: fix TOCTOU NULL deref on a->goto_chain

tcf_action_exec() handles TC_ACT_GOTO_CHAIN by first checking
rcu_access_pointer(a->goto_chain) and then calling
tcf_action_goto_chain_exec(), which does a second, independent
rcu_dereference_bh(a->goto_chain) read and immediately dereferences
chain->filter_chain. A concurrent tcf_action_set_ctrlact() (e.g. the gact
replace path) can clear a->goto_chain between the two reads, so the second
read returns NULL and tcf_action_goto_chain_exec() dereferences NULL.

Fix the race by doing a single rcu_dereference_bh() read of a->goto_chain
in tcf_action_exec(), checking it once for NULL, and passing the resulting
chain pointer into tcf_action_goto_chain_exec(). This turns the split
check/use into a single check/use on one value.

Fixes: ee3bbfe806cd ("net/sched: let actions use RCU to access 'goto_chain'")
Reported-by: vega@nebusec.ai
Tested-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
Link: https://patch.msgid.link/20260809090928.868186-1-jhs@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/sched/act_api.c