hulk inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9DNKF CVE: CVE-2024-26669
--------------------------------
Fix kabi change.
Fixes: 32f2a0afa95f ("net/sched: flower: Fix chain template offload") Signed-off-by: Zhengchao Shao shaozhengchao@huawei.com --- include/net/sch_generic.h | 5 +---- net/sched/cls_api.c | 25 +++++++++++++++++++------ net/sched/cls_flower.c | 11 ++++++++++- 3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 13f6609644df..fad29c9961cc 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -369,10 +369,7 @@ struct tcf_proto_ops { struct nlattr **tca, struct netlink_ext_ack *extack); void (*tmplt_destroy)(void *tmplt_priv); - void (*tmplt_reoffload)(struct tcf_chain *chain, - bool add, - flow_setup_cb_t *cb, - void *cb_priv); + /* rtnetlink specific */ int (*dump)(struct net*, struct tcf_proto*, void *, struct sk_buff *skb, struct tcmsg*, diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 521fd4d6eb31..7801d8c552c9 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -1397,6 +1397,19 @@ void tcf_block_put(struct tcf_block *block)
EXPORT_SYMBOL(tcf_block_put);
+void (* const tmplt_reoffload)(struct tcf_chain *chain, bool add, + flow_setup_cb_t *cb, void *cb_priv); +EXPORT_SYMBOL(tmplt_reoffload); + +static void cls_tmplt_reoffload(struct tcf_chain *chain, bool add, + flow_setup_cb_t *cb, void *cb_priv) +{ + if (!tmplt_reoffload) + return; + + tmplt_reoffload(chain, add, cb, cb_priv); +} + static int tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, void *cb_priv, bool add, bool offload_in_use, @@ -1414,8 +1427,9 @@ tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, chain = __tcf_get_next_chain(block, chain), tcf_chain_put(chain_prev)) { if (chain->tmplt_ops && add) - chain->tmplt_ops->tmplt_reoffload(chain, true, cb, - cb_priv); + if (!strcmp(chain->tmplt_ops->kind, "flower")) + cls_tmplt_reoffload(chain, true, cb, cb_priv); + for (tp = __tcf_get_next_proto(chain, NULL); tp; tp_prev = tp, tp = __tcf_get_next_proto(chain, tp), @@ -1432,8 +1446,8 @@ tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, } } if (chain->tmplt_ops && !add) - chain->tmplt_ops->tmplt_reoffload(chain, false, cb, - cb_priv); + if (!strcmp(chain->tmplt_ops->kind, "flower")) + cls_tmplt_reoffload(chain, false, cb, cb_priv); }
return 0; @@ -2778,8 +2792,7 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net, ops = tcf_proto_lookup_ops(name, true, extack); if (IS_ERR(ops)) return PTR_ERR(ops); - if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump || - !ops->tmplt_reoffload) { + if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) { NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier"); module_put(ops->owner); return -EOPNOTSUPP; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 96c137d48aab..3a1c139c426e 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -336,6 +336,12 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, return -1; }
+extern void (*tmplt_reoffload)(struct tcf_chain *chain, bool add, + flow_setup_cb_t *cb, void *cb_priv); + +static void fl_tmplt_reoffload(struct tcf_chain *chain, bool add, + flow_setup_cb_t *cb, void *cb_priv); + static int fl_init(struct tcf_proto *tp) { struct cls_fl_head *head; @@ -350,6 +356,8 @@ static int fl_init(struct tcf_proto *tp) rcu_assign_pointer(tp->root, head); idr_init(&head->handle_idr);
+ tmplt_reoffload = &fl_tmplt_reoffload; + return rhashtable_init(&head->ht, &mask_ht_params); }
@@ -588,6 +596,8 @@ static void fl_destroy(struct tcf_proto *tp, bool rtnl_held,
__module_get(THIS_MODULE); tcf_queue_work(&head->rwork, fl_destroy_sleepable); + + tmplt_reoffload = NULL; }
static void fl_put(struct tcf_proto *tp, void *arg) @@ -3233,7 +3243,6 @@ static struct tcf_proto_ops cls_fl_ops __read_mostly = { .bind_class = fl_bind_class, .tmplt_create = fl_tmplt_create, .tmplt_destroy = fl_tmplt_destroy, - .tmplt_reoffload = fl_tmplt_reoffload, .tmplt_dump = fl_tmplt_dump, .owner = THIS_MODULE, .flags = TCF_PROTO_OPS_DOIT_UNLOCKED,