From: Dickson Wu <dick…@certik.com> A goto-chain action resolves its target in the block of the filter that creates it. A filter in a different block can bind the same action by index. The action init path returns ACT_P_BOUND before checking the control action, so the second filter executes the foreign block's classifiers. Classful qdiscs then interpret a foreign class pointer as one of their own. An unprivileged user in a user and network namespace can trigger a kernel crash or a use-after-free write when the qdiscs are removed. Reject a bound action whose goto chain belongs to another block and release the attempted bind. The check covers every action kind that can carry a goto chain. A reproducer is available on request. Fixes: db50514f9a9c ("net: sched: add termination action to allow goto chain") Signed-off-by: Dickson Wu <dick…@certik.com> --- Tested on net e9d78fc6741a in KVM (x86_64), as an unprivileged user in a user namespace: - base: the cross-block DRR-to-HTB bind panics in htb_enqueue(), and DRR-to-DRR reports list_del corruption with DEBUG_LIST and slub_debug. Patched: tc rejects both binds with the extack message. - a same-block goto-chain bind works on both kernels. - tdc gact, HTB and DRR tests: 43 passes on both kernels. - W=1 build of act_api.o (x86_64 and allmodconfig), no warnings. This was found and the fix prepared with AI coding tools (OpenAI Codex agents, with review by Claude). I went over the analysis and the patch before signing off. net/sched/act_api.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index e142d33dc5ef..2183c6b03d87 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1465,6 +1465,22 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } if (err < 0) goto err_out; + if (err == ACT_P_BOUND && tp) { + struct tcf_chain *goto_ch; + bool foreign; + + rcu_read_lock(); + goto_ch = rcu_dereference(a->goto_chain); + foreign = goto_ch && goto_ch->block != tp->chain->block; + rcu_read_unlock(); + if (foreign) { + NL_SET_ERR_MSG(extack, + "Action's goto chain belongs to another block"); + tcf_idr_release(a, true); + err = -EINVAL; + goto err_out; + } + } *init_res = err; if (!police && tb[TCA_ACT_COOKIE])