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]
Date: Mon, 5 Jun 2023 14:09:32 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Simon Horman <simon.horman@...igine.com>
Cc: Jamal Hadi Salim <jhs@...atatu.com>, 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
Subject: Re: [PATCH RFC v2 net-next 04/28] net/sched: act_api: add init_ops
 to struct tc_action_op

On Mon, Jun 05, 2023 at 11:51:14AM +0200, Simon Horman wrote:
> > @@ -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.
> 

Right.  Presumably the author knows that one (and only one) of the
->init or ->init_ops pointers is set.  This kind of relationship between
two variables is something that Smatch tries to track inside a function
but outside of functions, like here, then Smatch doesn't track it.
I can't really think of a scalable way to track this.

So there are a couple options:

1) Ignore the warning.
2) Remove the second if.

	if (a_o->init)
		err = a_o->init();
	else
		err = a_o->init_ops();

I kind of like this, because I think it communicates the if ->init()
isn't set then ->init_ops() must be.

3) Add a return.

	if (a_o->init) {
		err = a_o->init();
	} else if (a_o->init_ops) {
		err = a_o->init_ops();
	} else {
		WARN_ON(1);
		return ERR_PTR(-EINVAL);
	}

4) Add an unreachable.  But the last time I suggested this it led to
link errors and I didn't get a chance to investigate so probably don't
do this:

	if (a_o->init) {
		err = a_o->init();
	} else if (a_o->init_ops) {
		err = a_o->init_ops();
	} else {
		unreachable();
	}

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ