netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
@ 2023-04-20 18:36 Ivan Vecera
  2023-04-20 18:41 ` Pedro Tammela
  2023-04-22  3:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Ivan Vecera @ 2023-04-20 18:36 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Marcelo Ricardo Leitner, open list

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>
---
 net/sched/cls_api.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 35785a36c80298..3c3629c9e7b65c 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3211,6 +3211,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().
 	 */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
  2023-04-20 18:36 [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Ivan Vecera
@ 2023-04-20 18:41 ` Pedro Tammela
  2023-04-21  9:09   ` Simon Horman
  2023-04-22  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Tammela @ 2023-04-20 18:41 UTC (permalink / raw)
  To: Ivan Vecera, netdev
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Marcelo Ricardo Leitner, open list

On 20/04/2023 15:36, Ivan Vecera wrote:
> 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>
> ---
>   net/sched/cls_api.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index 35785a36c80298..3c3629c9e7b65c 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -3211,6 +3211,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().
>   	 */

Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
  2023-04-20 18:41 ` Pedro Tammela
@ 2023-04-21  9:09   ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-21  9:09 UTC (permalink / raw)
  To: Pedro Tammela
  Cc: Ivan Vecera, netdev, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Marcelo Ricardo Leitner, open list

On Thu, Apr 20, 2023 at 03:41:17PM -0300, Pedro Tammela wrote:
> On 20/04/2023 15:36, Ivan Vecera wrote:
> > 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>
> > ---
> >   net/sched/cls_api.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> > index 35785a36c80298..3c3629c9e7b65c 100644
> > --- a/net/sched/cls_api.c
> > +++ b/net/sched/cls_api.c
> > @@ -3211,6 +3211,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().
> >   	 */
> 
> Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
  2023-04-20 18:36 [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Ivan Vecera
  2023-04-20 18:41 ` Pedro Tammela
@ 2023-04-22  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-22  3:40 UTC (permalink / raw)
  To: Ivan Vecera
  Cc: netdev, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni,
	simon.horman, marcelo.leitner, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 20 Apr 2023 20:36:33 +0200 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net,v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used
    https://git.kernel.org/netdev/net/c/2cc8a008d62f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-22  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-20 18:36 [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Ivan Vecera
2023-04-20 18:41 ` Pedro Tammela
2023-04-21  9:09   ` Simon Horman
2023-04-22  3:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).