FAILED: patch "[PATCH] net/sched: Only allow act_ct to bind to clsact/ingress qdiscs" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 11cb63b0d1a0685e0831ae3c77223e002ef18189
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026031221-tissue-upgrade-f4d3@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 11cb63b0d1a0685e0831ae3c77223e002ef18189 Mon Sep 17 00:00:00 2001
From: Victor Nogueira <[email protected]>
Date: Wed, 25 Feb 2026 10:43:48 -0300
Subject: [PATCH] net/sched: Only allow act_ct to bind to clsact/ingress qdiscs
and shared blocks
As Paolo said earlier [1]:
"Since the blamed commit below, classify can return TC_ACT_CONSUMED while the current skb being held by the defragmentation engine. As reported by GangMin Kim, if such packet is that may cause a UaF when the defrag engine later on tries to tuch again such packet."
act_ct was never meant to be used in the egress path, however some users are attaching it to egress today [2]. Attempting to reach a middle ground, we noticed that, while most qdiscs are not handling TC_ACT_CONSUMED, clsact/ingress qdiscs are. With that in mind, we address the issue by only allowing act_ct to bind to clsact/ingress qdiscs and shared blocks. That way it's still possible to attach act_ct to egress (albeit only with clsact).
[1] https://lore.kernel.org/netdev/674b8cbfc385c6f37fb29a1de08d8fe5c2b0fbee.1771321118.git.pabeni@redhat.com/
[2] https://lore.kernel.org/netdev/[email protected]/
include/net/act_api.h +1 -0
@@ -70,6 +70,7 @@ struct tc_action {#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3))#define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4)) +#define TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT (1U << (TCA_ACT_FLAGS_USER_BITS + 5))/* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice.
net/sched/act_ct.c +6 -0
@@ -1360,6 +1360,12 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,return -EINVAL ; } +if (bind && !(flags &TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT )) { +NL_SET_ERR_MSG_MOD (extack, +"Attaching ct to a non ingress/clsact qdisc is unsupported" ); +return -EOPNOTSUPP ; + } + err =nla_parse_nested (tb,TCA_CT_MAX , nla, ct_policy, extack);if (err <0 )return err;
net/sched/cls_api.c +7 -0
@@ -2228,6 +2228,11 @@ static bool is_qdisc_ingress(__u32 classid)return (TC_H_MIN (classid) ==TC_H_MIN (TC_H_MIN_INGRESS )); } +static bool is_ingress_or_clsact (struct tcf_block *block,struct Qdisc *q) +{ +return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); +} +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2420,6 +2425,8 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, flags |=TCA_ACT_FLAGS_NO_RTNL ;if (is_qdisc_ingress (parent)) flags |=TCA_ACT_FLAGS_AT_INGRESS ; +if (is_ingress_or_clsact (block, q)) + flags |=TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT ; err = tp->ops->change (net, skb, tp, cl, t->tcm_handle, tca, &fh, flags, extack);if (err ==0 ) {
Sasha Levin
maintainerPATCH 1/2 act_skbedit: skbedit queue mapping for receive queue
From: Amritha Nambiar <[email protected]>
[ Upstream commit 4a6a676f8c16ec17d2f8d69ce3b5d680277ed0d2 ]
Add support for skbedit queue mapping action on receive side. This is supported only in hardware, so the skip_sw flag is enforced. This enables offloading filters for receive queue selection in the hardware using the skbedit action. Traffic arrives on the Rx queue requested in the skbedit action parameter. A new tc action flag TCA_ACT_FLAGS_AT_INGRESS is introduced to identify the traffic direction the action queue_mapping is requested on during filter addition. This is used to disallow offloading the skbedit queue mapping action on transmit side.
Example:
$tc filter add dev $IFACE ingress protocol ip flower dst_ip $DST_IP\
action skbedit queue_mapping $rxq_id skip_sw
Stable-dep-of: 11cb63b0d1a0 ("net/sched: Only allow act_ct to bind to clsact/ingress qdiscs and shared blocks")
--- include/net/act_api.h | 1 + include/net/flow_offload.h | 2 ++ include/net/tc_act/tc_skbedit.h | 29 +++++++++++++++++++++++++++++ net/sched/act_skbedit.c | 14 ++++++++++++-- net/sched/cls_api.c | 7 +++++++ 5 files changed, 51 insertions(+), 2 deletions(-)
include/net/act_api.h +1 -0
@@ -67,6 +67,7 @@ struct tc_action {#define TCA_ACT_FLAGS_BIND (1U << (TCA_ACT_FLAGS_USER_BITS + 1))#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3)) +#define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4))/* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice.
include/net/flow_offload.h +2 -0
@@ -155,6 +155,7 @@ enum flow_action_id {FLOW_ACTION_MARK ,FLOW_ACTION_PTYPE ,FLOW_ACTION_PRIORITY , +FLOW_ACTION_RX_QUEUE_MAPPING ,FLOW_ACTION_WAKE ,FLOW_ACTION_QUEUE , FLOW_ACTION_SAMPLE,
@@ -247,6 +248,7 @@ struct flow_action_entry {u32 csum_flags;/* FLOW_ACTION_CSUM */ u32 mark;/* FLOW_ACTION_MARK */ u16 ptype;/* FLOW_ACTION_PTYPE */ +u16 rx_queue;/* FLOW_ACTION_RX_QUEUE_MAPPING */ u32 priority;/* FLOW_ACTION_PRIORITY */ struct {/* FLOW_ACTION_QUEUE */ u32 ctx;
include/net/tc_act/tc_skbedit.h +29 -0
@@ -95,12 +95,41 @@ static inline u32 tcf_skbedit_priority(const struct tc_action *a)return priority; } +static inline u16 tcf_skbedit_rx_queue_mapping (const struct tc_action *a) +{ +u16 rx_queue; + +rcu_read_lock (); + rx_queue =rcu_dereference (to_skbedit (a)->params)->queue_mapping; +rcu_read_unlock (); + +return rx_queue; +} +/* Return true iff action is queue_mapping */ static inline bool is_tcf_skbedit_queue_mapping (const struct tc_action *a) {return is_tcf_skbedit_with_flag (a,SKBEDIT_F_QUEUE_MAPPING ); } +/* Return true if action is on ingress traffic */ +static inline bool is_tcf_skbedit_ingress (u32 flags) +{ +return flags &TCA_ACT_FLAGS_AT_INGRESS ; +} + +static inline bool is_tcf_skbedit_tx_queue_mapping (const struct tc_action *a) +{ +return is_tcf_skbedit_queue_mapping (a) && + !is_tcf_skbedit_ingress (a->tcfa_flags); +} + +static inline bool is_tcf_skbedit_rx_queue_mapping (const struct tc_action *a) +{ +return is_tcf_skbedit_queue_mapping (a) && +is_tcf_skbedit_ingress (a->tcfa_flags); +} +/* Return true iff action is inheritdsfield */ static inline bool is_tcf_skbedit_inheritdsfield (const struct tc_action *a) {
net/sched/act_skbedit.c +12 -2
@@ -148,6 +148,11 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, }if (tb[TCA_SKBEDIT_QUEUE_MAPPING ] !=NULL ) { +if (is_tcf_skbedit_ingress (act_flags) && + !(act_flags &TCA_ACT_FLAGS_SKIP_SW )) { +NL_SET_ERR_MSG_MOD (extack,"\"queue_mapping\" option on receive side is hardware only, use skip_sw" ); +return -EOPNOTSUPP ; + } flags |=SKBEDIT_F_QUEUE_MAPPING ; queue_mapping =nla_data (tb[TCA_SKBEDIT_QUEUE_MAPPING ]); }
@@ -378,9 +383,12 @@ static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data }else if (is_tcf_skbedit_priority (act)) { entry->id =FLOW_ACTION_PRIORITY ; entry->priority =tcf_skbedit_priority (act); - }else if (is_tcf_skbedit_queue_mapping (act)) { -NL_SET_ERR_MSG_MOD (extack,"Offload not supported when \"queue_mapping\" option is used" ); + }else if (is_tcf_skbedit_tx_queue_mapping (act)) { +NL_SET_ERR_MSG_MOD (extack,"Offload not supported when \"queue_mapping\" option is used on transmit side" );return -EOPNOTSUPP ; + }else if (is_tcf_skbedit_rx_queue_mapping (act)) { + entry->id =FLOW_ACTION_RX_QUEUE_MAPPING ; + entry->rx_queue =tcf_skbedit_rx_queue_mapping (act); }else if (is_tcf_skbedit_inheritdsfield (act)) {NL_SET_ERR_MSG_MOD (extack,"Offload not supported when \"inheritdsfield\" option is used" );return -EOPNOTSUPP ;
@@ -398,6 +406,8 @@ static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data fl_action->id =FLOW_ACTION_PTYPE ; else if (is_tcf_skbedit_priority(act)) fl_action->id = FLOW_ACTION_PRIORITY; + else if (is_tcf_skbedit_rx_queue_mapping(act)) + fl_action->id = FLOW_ACTION_RX_QUEUE_MAPPING; else return -EOPNOTSUPP; }
net/sched/cls_api.c +7 -0
@@ -1993,6 +1993,11 @@ static void tfilter_put(struct tcf_proto *tp, void *fh) tp->ops->put (tp, fh); } +static bool is_qdisc_ingress (__u32 classid) +{ +return (TC_H_MIN (classid) ==TC_H_MIN (TC_H_MIN_INGRESS )); +} +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2184,6 +2189,8 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, flags |=TCA_ACT_FLAGS_REPLACE ;if (!rtnl_held) flags |=TCA_ACT_FLAGS_NO_RTNL ; +if (is_qdisc_ingress (parent)) + flags |=TCA_ACT_FLAGS_AT_INGRESS ; err = tp->ops->change (net, skb, tp, cl, t->tcm_handle, tca, &fh, flags, extack);if (err ==0 ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/2 net/sched: Only allow act_ct to bind to clsact/ingress qdiscs and shared blocks
From: Victor Nogueira <[email protected]>
[ Upstream commit 11cb63b0d1a0685e0831ae3c77223e002ef18189 ]
As Paolo said earlier [1]:
"Since the blamed commit below, classify can return TC_ACT_CONSUMED while the current skb being held by the defragmentation engine. As reported by GangMin Kim, if such packet is that may cause a UaF when the defrag engine later on tries to tuch again such packet."
act_ct was never meant to be used in the egress path, however some users are attaching it to egress today [2]. Attempting to reach a middle ground, we noticed that, while most qdiscs are not handling TC_ACT_CONSUMED, clsact/ingress qdiscs are. With that in mind, we address the issue by only allowing act_ct to bind to clsact/ingress qdiscs and shared blocks. That way it's still possible to attach act_ct to egress (albeit only with clsact).
[1] https://lore.kernel.org/netdev/674b8cbfc385c6f37fb29a1de08d8fe5c2b0fbee.1771321118.git.pabeni@redhat.com/
[2] https://lore.kernel.org/netdev/[email protected]/
--- include/net/act_api.h | 1 + net/sched/act_ct.c | 6 ++++++ net/sched/cls_api.c | 7 +++++++ 3 files changed, 14 insertions(+)
include/net/act_api.h +1 -0
@@ -68,6 +68,7 @@ struct tc_action {#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3))#define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4)) +#define TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT (1U << (TCA_ACT_FLAGS_USER_BITS + 5))/* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice.
net/sched/act_ct.c +6 -0
@@ -1440,6 +1440,12 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,return -EINVAL ; } +if (bind && !(flags &TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT )) { +NL_SET_ERR_MSG_MOD (extack, +"Attaching ct to a non ingress/clsact qdisc is unsupported" ); +return -EOPNOTSUPP ; + } + err =nla_parse_nested (tb,TCA_CT_MAX , nla, ct_policy, extack);if (err <0 )return err;
net/sched/cls_api.c +7 -0
@@ -1998,6 +1998,11 @@ static bool is_qdisc_ingress(__u32 classid)return (TC_H_MIN (classid) ==TC_H_MIN (TC_H_MIN_INGRESS )); } +static bool is_ingress_or_clsact (struct tcf_block *block,struct Qdisc *q) +{ +return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); +} +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2191,6 +2196,8 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, flags |=TCA_ACT_FLAGS_NO_RTNL ;if (is_qdisc_ingress (parent)) flags |=TCA_ACT_FLAGS_AT_INGRESS ; +if (is_ingress_or_clsact (block, q)) + flags |=TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT ; err = tp->ops->change (net, skb, tp, cl, t->tcm_handle, tca, &fh, flags, extack);if (err ==0 ) {
Signature · 1 line
2.51.0
Greg KH
maintainerRe: [PATCH 6.1.y 2/2] net/sched: Only allow act_ct to bind to clsact/ingress qdiscs and shared blocks
Quoted 30 lines · Sasha Levin
From: Victor Nogueira <[email protected]>
[ Upstream commit
11cb63b0d1a0685e0831ae3c77223e002ef18189]As Paolo said earlier [1]:
"Since the blamed commit below, classify can return
TC_ACT_CONSUMEDwhile the current skb being held by the defragmentation engine. As reported by GangMin Kim, if such packet is that may cause a UaF when the defrag engine later on tries to tuch again such packet."
act_ctwas never meant to be used in the egress path, however some users are attaching it to egress today [2]. Attempting to reach a middle ground, we noticed that, while most qdiscs are not handlingTC_ACT_CONSUMED, clsact/ingress qdiscs are. With that in mind, we address the issue by only allowingact_ctto bind to clsact/ingress qdiscs and shared blocks. That way it's still possible to attachact_ctto egress (albeit only with clsact).[1] https://lore.kernel.org/netdev/674b8cbfc385c6f37fb29a1de08d8fe5c2b0fbee.1771321118.git.pabeni@redhat.com/
[2] https://lore.kernel.org/netdev/[email protected]/Reported-by GangMin Kim <[email protected]>Fixes 3f14b377d01d ("net/sched: act_ct: fix skb leak and crash on ooo frags")Signed-off-by Victor Nogueira <[email protected]>Acked-by Jamal Hadi Salim <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 5 lines
--- include/net/act_api.h | 1 + net/sched/act_ct.c | 6 ++++++ net/sched/cls_api.c | 7 +++++++ 3 files changed, 14 insertions(+)
Ah, it was some trivial fuzz, I've just taken this and not patch 1/2 as that is a new feature not needed here.
thanks,
greg k-h