From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [RFC PATCH v3 bpf-next 2/5] bpf/verifier: rewrite subprog boundary detection Date: Tue, 17 Apr 2018 16:48:27 -0700 Message-ID: <20180417234826.egydr2sg2rewzvyu@ast-mbp> References: <99e70dfe-66a1-911a-6616-60eae4ddc689@solarflare.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Daniel Borkmann , netdev@vger.kernel.org To: Edward Cree Return-path: Received: from mail-pl0-f68.google.com ([209.85.160.68]:42288 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752679AbeDQXsa (ORCPT ); Tue, 17 Apr 2018 19:48:30 -0400 Received: by mail-pl0-f68.google.com with SMTP id t20-v6so12893449ply.9 for ; Tue, 17 Apr 2018 16:48:30 -0700 (PDT) Content-Disposition: inline In-Reply-To: <99e70dfe-66a1-911a-6616-60eae4ddc689@solarflare.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Apr 06, 2018 at 06:13:59PM +0100, Edward Cree wrote: > By storing a subprogno in each insn's aux data, we avoid the need to keep > the list of subprog starts sorted or bsearch() it in find_subprog(). > Also, get rid of the weird one-based indexing of subprog numbers. > > Signed-off-by: Edward Cree > --- > include/linux/bpf_verifier.h | 3 +- > kernel/bpf/verifier.c | 284 ++++++++++++++++++++++++++----------------- > 2 files changed, 177 insertions(+), 110 deletions(-) > > diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h > index 8f70dc181e23..17990dd56e65 100644 > --- a/include/linux/bpf_verifier.h > +++ b/include/linux/bpf_verifier.h > @@ -146,6 +146,7 @@ struct bpf_insn_aux_data { > s32 call_imm; /* saved imm field of call insn */ > }; > int ctx_field_size; /* the ctx field size for load insn, maybe 0 */ > + u16 subprogno; /* subprog in which this insn resides */ > bool seen; /* this insn was processed by the verifier */ > }; as I was saying before this is no go. subprogno is meaningless in the hierarchy of: prog -> func -> bb -> insn Soon bpf will have libraries and this field would need to become a pointer back to bb or func structure creating unnecessary circular dependency.