From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamal Hadi Salim Subject: Re: [PATCH net-next v11 3/4] net sched actions: dump more than TCA_ACT_MAX_PRIO actions per batch Date: Fri, 28 Jul 2017 09:41:44 -0400 Message-ID: <27472f41-1dd3-66a0-d4fc-6b7290c14b27@mojatatu.com> References: <1500860146-26970-1-git-send-email-jhs@emojatatu.com> <1500860146-26970-4-git-send-email-jhs@emojatatu.com> <20170724112750.GC1868@nanopsycho> <7057a692-7233-4632-4f66-2f57c98322ea@mojatatu.com> <20170725113352.GA3186@nanopsycho> <355f2140-d8e8-8a4e-1f31-cbbcbfd6821b@mojatatu.com> <20170725123728.GC3186@nanopsycho> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: davem@davemloft.net, netdev@vger.kernel.org, xiyou.wangcong@gmail.com, dsahern@gmail.com, eric.dumazet@gmail.com, mrv@mojatatu.com, simon.horman@netronome.com, alex.aring@gmail.com To: Jiri Pirko Return-path: Received: from mail-it0-f65.google.com ([209.85.214.65]:34940 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751782AbdG1Nlx (ORCPT ); Fri, 28 Jul 2017 09:41:53 -0400 Received: by mail-it0-f65.google.com with SMTP id v127so15569745itd.2 for ; Fri, 28 Jul 2017 06:41:53 -0700 (PDT) In-Reply-To: <20170725123728.GC3186@nanopsycho> Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: On 17-07-25 08:37 AM, Jiri Pirko wrote: > Tue, Jul 25, 2017 at 02:34:58PM CEST, jhs@mojatatu.com wrote: >> On 17-07-25 07:33 AM, Jiri Pirko wrote: >>> Tue, Jul 25, 2017 at 01:22:44PM CEST, jhs@mojatatu.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