diff mbox series

[SRU,J:linux-bluefield,v3,09/11] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used

Message ID 20230606230120.407292-10-witu@nvidia.com
State New
Headers show
Series Support hardware miss to tc action | expand

Commit Message

William Tu June 6, 2023, 11:01 p.m. UTC
From: Ivan Vecera <ivecera@redhat.com>

BugLink: https://bugs.launchpad.net/bugs/2012571

Function tcf_exts_init_ex() sets exts->miss_cookie_node ptr only
when use_action_miss is true so it assumes in other case that
the field is set to NULL by the caller. If not then the field
contains garbage and subsequent tcf_exts_destroy() call results
in a crash.
Ensure that the field .miss_cookie_node pointer is NULL when
use_action_miss parameter is false to avoid this potential scenario.

Fixes: 80cd22c35c90 ("net/sched: cls_api: Support hardware miss to tc action")
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230420183634.1139391-1-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 2cc8a008d62f3c04eeb7ec6fe59e542802bb8df3)
Signed-off-by: William Tu <witu@nvidia.com>
---
 net/sched/cls_api.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 5911e83388e7..9848eb41ec08 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3177,6 +3177,7 @@  int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action,
 #ifdef CONFIG_NET_CLS_ACT
 	exts->type = 0;
 	exts->nr_actions = 0;
+	exts->miss_cookie_node = NULL;
 	/* Note: we do not own yet a reference on net.
 	 * This reference might be taken later from tcf_exts_get_net().
 	 */