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] [day] [month] [year] [list]
Message-ID: <Y9plT+gHmdwbuRJO@corigine.com>
Date:   Wed, 1 Feb 2023 14:12:47 +0100
From:   Simon Horman <simon.horman@...igine.com>
To:     Pedro Tammela <pctammela@...atatu.com>
Cc:     netdev@...r.kernel.org, jhs@...atatu.com, xiyou.wangcong@...il.com,
        jiri@...nulli.us, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, pabeni@...hat.com
Subject: Re: [PATCH net-next v5 1/2] net/sched: transition act_pedit to rcu
 and percpu stats

On Tue, Jan 31, 2023 at 04:05:48PM -0300, Pedro Tammela wrote:
> On 31/01/2023 13:07, Simon Horman wrote:
> > On Tue, Jan 31, 2023 at 11:51:48AM -0300, Pedro Tammela wrote:
> > > The software pedit action didn't get the same love as some of the
> > > other actions and it's still using spinlocks and shared stats in the
> > > datapath.
> > > Transition the action to rcu and percpu stats as this improves the
> > > action's performance dramatically on multiple cpu deployments.
> > > 
> > > Reviewed-by: Jamal Hadi Salim <jhs@...atatu.com>
> > > Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
> > 
> > ...
> > 
> > > diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> > > index a0378e9f0121..674b534be46e 100644
> > > --- a/net/sched/act_pedit.c
> > > +++ b/net/sched/act_pedit.c
> > 
> > ...
> > 
> > > @@ -143,8 +154,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
> > >   	bool bind = flags & TCA_ACT_FLAGS_BIND;
> > >   	struct nlattr *tb[TCA_PEDIT_MAX + 1];
> > >   	struct tcf_chain *goto_ch = NULL;
> > > -	struct tc_pedit_key *keys = NULL;
> > > -	struct tcf_pedit_key_ex *keys_ex;
> > > +	struct tcf_pedit_parms *oparms, *nparms;
> > 
> > nit: reverse xmas tree
> > 
> > >   	struct tc_pedit *parm;
> > >   	struct nlattr *pattr;
> > >   	struct tcf_pedit *p;
> > 
> > ...
> > 
> > > @@ -212,48 +228,51 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
> > >   		ret = err;
> > >   		goto out_release;
> > >   	}
> > > -	p = to_pedit(*a);
> > > -	spin_lock_bh(&p->tcf_lock);
> > > -	if (ret == ACT_P_CREATED ||
> > > -	    (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys)) {
> > > -		keys = kmalloc(ksize, GFP_ATOMIC);
> > > -		if (!keys) {
> > > -			spin_unlock_bh(&p->tcf_lock);
> > > -			ret = -ENOMEM;
> > > -			goto put_chain;
> > > -		}
> > > -		kfree(p->tcfp_keys);
> > > -		p->tcfp_keys = keys;
> > > -		p->tcfp_nkeys = parm->nkeys;
> > > +	nparms->tcfp_off_max_hint = 0;
> > > +	nparms->tcfp_flags = parm->flags;
> > > +	nparms->tcfp_nkeys = parm->nkeys;
> > > +
> > > +	nparms->tcfp_keys = kmalloc(ksize, GFP_KERNEL);
> > 
> > Can ksize be zero?
> > 
> > ...
> 
> Hi Simon,
> 
> Thanks for your thorough review.
> From the parsing code on lines 183-188:
>           parm = nla_data(pattr);
>           if (!parm->nkeys) {
>                   NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be
> passed");
>                   return -EINVAL;
>           }
>           ksize = parm->nkeys * sizeof(struct tc_pedit_key);
> 
> So it seems ksize can't be zero.

Yes, that is pretty obvious.
Sorry for missing it.

> Let me know if you think there are other edge cases, perhaps we can add more
> tests to tdc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ