From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Paul Blakey <paulb@nvidia.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
Date: Thu, 20 Apr 2023 19:59:52 +0200 [thread overview]
Message-ID: <20230420175952.1114302-1-ivecera@redhat.com> (raw)
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.
Initialize .miss_cookie_node pointer to 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>
---
net/sched/cls_api.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 35785a36c80298..8bc5b9d6a2916e 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3224,8 +3224,12 @@ int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action,
exts->action = action;
exts->police = police;
- if (!use_action_miss)
+ if (!use_action_miss) {
+#ifdef CONFIG_NET_CLS_ACT
+ exts->miss_cookie_node = NULL;
+#endif
return 0;
+ }
err = tcf_exts_miss_cookie_base_alloc(exts, tp, handle);
if (err)
--
2.39.2
next reply other threads:[~2023-04-20 18:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 17:59 Ivan Vecera [this message]
2023-04-20 18:21 ` [PATCH net] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Pedro Tammela
2023-04-20 18:35 ` Ivan Vecera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230420175952.1114302-1-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulb@nvidia.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox