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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 31 Jan 2023 16:05:48 -0300
From:   Pedro Tammela <pctammela@...atatu.com>
To:     Simon Horman <simon.horman@...igine.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 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.
Let me know if you think there are other edge cases, perhaps we can add 
more tests to tdc.

Pedro

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ