[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27472f41-1dd3-66a0-d4fc-6b7290c14b27@mojatatu.com>
Date: Fri, 28 Jul 2017 09:41:44 -0400
From: Jamal Hadi Salim <jhs@...atatu.com>
To: Jiri Pirko <jiri@...nulli.us>
Cc: davem@...emloft.net, netdev@...r.kernel.org,
xiyou.wangcong@...il.com, dsahern@...il.com,
eric.dumazet@...il.com, mrv@...atatu.com,
simon.horman@...ronome.com, alex.aring@...il.com
Subject: Re: [PATCH net-next v11 3/4] net sched actions: dump more than
TCA_ACT_MAX_PRIO actions per batch
On 17-07-25 08:37 AM, Jiri Pirko wrote:
> Tue, Jul 25, 2017 at 02:34:58PM CEST, jhs@...atatu.com wrote:
>> On 17-07-25 07:33 AM, Jiri Pirko wrote:
>>> Tue, Jul 25, 2017 at 01:22:44PM CEST, jhs@...atatu.com wrote:
[..]
>>> What if I pass val 0x1 and selector 0x0 from userspace. I don't have the
>>> bit selected, so you should not process it in kernel, no?
>>>
>>
>> Yes, valid point. I am not sure - should we reject?
>
> I think that the validation might check this and reject. Makes sense to
> me.
>
How does this look? I havent tested it but covers all angles
I can think of.
static int validate_nla_bitfield32(const struct nlattr *nla,
void *valid_flags_allowed)
{
const struct nla_bitfield32 *bf = nla_data(nla);
u32 *valid_flags_mask = valid_flags_allowed;
if (!valid_flags_allowed)
return -EINVAL;
/*disallow invalid selector */
if ((bf->selector & valid_flags_allowed) >*valid_flags_allowed)
return -EINVAL;
/*disallow invalid bit values */
if (bf->value & ~*valid_flags_mask)
return -EINVAL;
/*disallow valid bit values that are not selected*/
if (bf->value & ~nbf->selector)
return -EINVAL;
return 0;
}
cheers,
jamal
Powered by blists - more mailing lists