From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [RFC 3/5] bpf: fix validation of eal_divmod Date: Wed, 7 Nov 2018 11:51:47 -0800 Message-ID: <20181107115147.67f026e6@shemminger-XPS-13-9360> References: <20181106214901.1392-1-stephen@networkplumber.org> <20181106214901.1392-4-stephen@networkplumber.org> <2601191342CEEE43887BDE71AB9772580103069BF3@irsmsx105.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: "Ananyev, Konstantin" Return-path: Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 886CE14EC for ; Wed, 7 Nov 2018 20:51:51 +0100 (CET) Received: by mail-pg1-f195.google.com with SMTP id r9-v6so7756046pgv.6 for ; Wed, 07 Nov 2018 11:51:51 -0800 (PST) In-Reply-To: <2601191342CEEE43887BDE71AB9772580103069BF3@irsmsx105.ger.corp.intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 7 Nov 2018 12:54:54 +0000 "Ananyev, Konstantin" wrote: > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > > Sent: Tuesday, November 6, 2018 9:49 PM > > To: dev@dpdk.org > > Cc: Stephen Hemminger > > Subject: [dpdk-dev] [RFC 3/5] bpf: fix validation of eal_divmod > > > > Coverity spotted self assignment in BPF eval_divmod. > > Yep, there is one. > As I remember I have to add it because one of old versions > of compiler (clang???) complained about 'variable being used uninitialized'. > > > This looks like a bug where the incoming source register > > should have been used instead. > > Nope, that's a wrong guess. > We shouldn't do it here. > Konstantin > > > > > Coverity issue: 302850 > > Fixes: 8021917293d0 ("bpf: add extra validation for input BPF program") > > Signed-off-by: Stephen Hemminger > > --- > > lib/librte_bpf/bpf_validate.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c > > index 83983efc4e5c..b768f72c4c02 100644 > > --- a/lib/librte_bpf/bpf_validate.c > > +++ b/lib/librte_bpf/bpf_validate.c > > @@ -512,7 +512,7 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs, > > if (op == BPF_MOD) > > rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1); > > else > > - rd->u.max = rd->u.max; > > + rd->u.max = rs->u.max; > > rd->u.min = 0; > > } > > > > -- > > 2.17.1 > Well it was being used unintialized, your trick of self assignment fooled clang but did not fool Coverity. What does the other BPF validator do?