lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZH2wEocXqLEjiaqc@corigine.com>
Date: Mon, 5 Jun 2023 11:51:14 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Jamal Hadi Salim <jhs@...atatu.com>
Cc: netdev@...r.kernel.org, deb.chatterjee@...el.com,
	anjali.singhai@...el.com, namrata.limaye@...el.com, tom@...anda.io,
	p4tc-discussions@...devconf.info, mleitner@...hat.com,
	Mahesh.Shirshyad@....com, Vipin.Jain@....com,
	tomasz.osinski@...el.com, jiri@...nulli.us,
	xiyou.wangcong@...il.com, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, vladbu@...dia.com,
	khalidm@...dia.com, toke@...hat.com,
	Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: [PATCH RFC v2 net-next 04/28] net/sched: act_api: add init_ops
 to struct tc_action_op

CC: Dan Carpenter

On Wed, May 17, 2023 at 07:02:08AM -0400, Jamal Hadi Salim wrote:
> The initialisation of P4TC action instances require access to a struct p4tc_act
> (which appears in later patches) to help us to retrieve information like the
> dynamic action parameters etc. In order to retrieve struct p4tc_act we need the
> pipeline name or id and the action name or id. Also recall that P4TC
> action IDs are dynamic and  are net namespace specific. The init callback from
> tc_action_ops parameters had no way of supplying us that information. To solve
> this issue, we decided to create a new tc_action_ops callback (init_ops), that
> provides us with the tc_action_ops struct which then provides us with the
> pipeline and action name. In addition we add a new refcount to struct
> tc_action_ops called dyn_ref, which accounts for how many action instances we
> have of a specific dynamic action.
> 
> Co-developed-by: Victor Nogueira <victor@...atatu.com>
> Signed-off-by: Victor Nogueira <victor@...atatu.com>
> Co-developed-by: Pedro Tammela <pctammela@...atatu.com>
> Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@...atatu.com>

Hi Jamal, Victor and Pedro,

> index bc4e178873e4..0ba5a4b5db6f 100644
> --- a/net/sched/act_api.c
> +++ b/net/sched/act_api.c
> @@ -1006,7 +1006,7 @@ int tcf_register_action(struct tc_action_ops *act,
>  	struct tc_action_ops *a;
>  	int ret;
>  
> -	if (!act->act || !act->dump || !act->init)
> +	if (!act->act || !act->dump || (!act->init && !act->init_ops))
>  		return -EINVAL;
>  
>  	/* We have to register pernet ops before making the action ops visible,
> @@ -1494,8 +1494,13 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
>  			}
>  		}
>  
> -		err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, tp,
> -				userflags.value | flags, extack);
> +		if (a_o->init)
> +			err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, tp,
> +					userflags.value | flags, extack);
> +		else if (a_o->init_ops)
> +			err = a_o->init_ops(net, tb[TCA_ACT_OPTIONS], est, &a,
> +					    tp, a_o, userflags.value | flags,
> +					    extack);

By my reading the initialisation of a occurs here.
Which is now conditional.

>  	} else {
>  		err = a_o->init(net, nla, est, &a, tp, userflags.value | flags,
>  				extack);

A bit further down, outside of the else clause above, the code looks like
this.

        if (!police && tb[TCA_ACT_COOKIE])
                tcf_set_action_cookie(&a->user_cookie, user_cookie);

        if (!police)
                a->hw_stats = hw_stats;

Which causes Smatch to complain that a may be used uninitialised.
Is this the case?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ