From 913f26a838b4df876d6431b643f43143b95a12f3 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Sat, 13 Apr 2024 16:30:06 +0800 Subject: [PATCH] net/sched: act_mirred: don't override retval if we already lost the skb mainline inclusion from mainline-v6.8-rc6 commit 166c2c8a6a4dc2e4ceba9e10cfe81c3e469e3210 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9E2LZ CVE: CVE-2024-26739 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=166c2c8a6a4dc2e4ceba9e10cfe81c3e469e3210 -------------------------------- If we're redirecting the skb, and haven't called tcf_mirred_forward(), yet, we need to tell the core to drop the skb by setting the retcode to SHOT. If we have called tcf_mirred_forward(), however, the skb is out of our hands and returning SHOT will lead to UaF. Move the retval override to the error path which actually need it. Reviewed-by: Michal Swiatkowski Fixes: e5cf1baf92cb ("act_mirred: use TC_ACT_REINSERT when possible") Signed-off-by: Jakub Kicinski Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Conflicts: net/sched/act_mirred.c Signed-off-by: Zhengchao Shao --- net/sched/act_mirred.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 336db2c938b5..0909c0d7b54f 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -305,15 +305,18 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, } err = tcf_mirred_forward(skb_at_tc_ingress(skb), want_ingress, skb2); - if (err) { -out: + if (err) qstats_overlimit_inc(this_cpu_ptr(m->common.cpu_qstats)); - if (tcf_mirred_is_act_redirect(m_eaction)) - retval = TC_ACT_SHOT; - } __this_cpu_dec(mirred_rec_level); return retval; + +out: + tcf_action_inc_overlimit_qstats(&m->common); + if (tcf_mirred_is_act_redirect(m_eaction)) + retval = TC_ACT_SHOT; + __this_cpu_dec(mirred_nest_level); + return retval; } static void tcf_stats_update(struct tc_action *a, u64 bytes, u32 packets, -- Gitee