From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3637C433DF for ; Wed, 29 Jul 2020 18:55:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DF6A20809 for ; Wed, 29 Jul 2020 18:55:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SY6KRJhU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbgG2SzO (ORCPT ); Wed, 29 Jul 2020 14:55:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57750 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726365AbgG2SzO (ORCPT ); Wed, 29 Jul 2020 14:55:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596048911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HP2WV24a7sGcCziuK1Df6/63OJKTSQXyapplnTgZGYw=; b=SY6KRJhUE2xU+NTWyDHogU2oHRbzFNRMRlE/M7hwAUYFU5eNYD1VZ9UUESajsCKXiwPM8G 44SaTq379m+11HGAPIWoovFwcpery9Oenw/mF6vYDQQSG8WCe4LIuYNgsRt1BAUaqrycwM MFsfXX13h/1pdt74uTQk2tiwHRr15EI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-8gy1ArkENoq9GT5uyYVSFw-1; Wed, 29 Jul 2020 14:55:09 -0400 X-MC-Unique: 8gy1ArkENoq9GT5uyYVSFw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 877AA8005B0; Wed, 29 Jul 2020 18:55:07 +0000 (UTC) Received: from krava (unknown [10.40.193.247]) by smtp.corp.redhat.com (Postfix) with SMTP id 5E49E100EBA4; Wed, 29 Jul 2020 18:55:01 +0000 (UTC) Date: Wed, 29 Jul 2020 20:55:00 +0200 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Song Liu , Yonghong Song , Martin KaFai Lau , David Miller , John Fastabend , Wenbo Zhang , KP Singh , Brendan Gregg , Florent Revest , Al Viro Subject: Re: [PATCH v8 bpf-next 07/13] bpf: Add btf_struct_ids_match function Message-ID: <20200729185500.GN1319041@krava> References: <20200722211223.1055107-1-jolsa@kernel.org> <20200722211223.1055107-8-jolsa@kernel.org> <20200729160419.GM1319041@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jul 29, 2020 at 10:51:26AM -0700, Andrii Nakryiko wrote: > On Wed, Jul 29, 2020 at 9:04 AM Jiri Olsa wrote: > > > > On Tue, Jul 28, 2020 at 04:35:16PM -0700, Andrii Nakryiko wrote: > > > > SNIP > > > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > > > index bae557ff2da8..c981e258fed3 100644 > > > > --- a/include/linux/bpf.h > > > > +++ b/include/linux/bpf.h > > > > @@ -1306,6 +1306,8 @@ int btf_struct_access(struct bpf_verifier_log *log, > > > > const struct btf_type *t, int off, int size, > > > > enum bpf_access_type atype, > > > > u32 *next_btf_id); > > > > +bool btf_struct_ids_match(struct bpf_verifier_log *log, > > > > + int off, u32 id, u32 mid); > > > > int btf_resolve_helper_id(struct bpf_verifier_log *log, > > > > const struct bpf_func_proto *fn, int); > > > > > > > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > > > > index 1ab5fd5bf992..562d4453fad3 100644 > > > > --- a/kernel/bpf/btf.c > > > > +++ b/kernel/bpf/btf.c > > > > @@ -4140,6 +4140,35 @@ int btf_struct_access(struct bpf_verifier_log *log, > > > > return -EINVAL; > > > > } > > > > > > > > +bool btf_struct_ids_match(struct bpf_verifier_log *log, > > > > + int off, u32 id, u32 mid) > > just realized that if id == mid and off == 0, btf_struct_ids_match() > will return false. Right now verifier is careful to not call > btf_struct_ids_match in such case, but I wonder if it's better to make > that (common) case also work? right, also we should call btf_struct_ids_match when IDs are equal and off != 0, which we don't do now jirka