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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 DF033C433E1 for ; Sun, 9 Aug 2020 14:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDEBE206E9 for ; Sun, 9 Aug 2020 14:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="irFd1tVE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgHIOrT (ORCPT ); Sun, 9 Aug 2020 10:47:19 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44221 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726199AbgHIOrS (ORCPT ); Sun, 9 Aug 2020 10:47:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596984437; 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=gKK414gvYPxO64jiz+P/8qj08kR5l/OAlU0hgufW1/c=; b=irFd1tVEYIGOHe0dg/P1yfLgaSTl1hI5HfHHNgm2+zbR/X2Yo8yOXtUuiEX/Wac2PcttVV hh2uZSXygrMf05XNoT4CqvuoXIb6skJoVboIeIJrGqCjjHkYZTZjGKWclplL/IzXUu5YyC oAKjwP0IyuRQKTKdszTEiWMcrCf4vXo= 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-30-PPsk5wR5Mw2jNQC81EhACQ-1; Sun, 09 Aug 2020 10:47:13 -0400 X-MC-Unique: PPsk5wR5Mw2jNQC81EhACQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EC768015CE; Sun, 9 Aug 2020 14:47:11 +0000 (UTC) Received: from krava (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with SMTP id B150C6179B; Sun, 9 Aug 2020 14:47:07 +0000 (UTC) Date: Sun, 9 Aug 2020 16:47:06 +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 v10 bpf-next 08/14] bpf: Add btf_struct_ids_match function Message-ID: <20200809144706.GD619980@krava> References: <20200807094559.571260-1-jolsa@kernel.org> <20200807094559.571260-9-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Aug 07, 2020 at 01:04:26PM -0700, Andrii Nakryiko wrote: SNIP > > + } > > } > > } else if (!fn->check_btf_id(reg->btf_id, arg)) { > > Put this on a wishlist for now. I don't think we should expect > fb->check_btf_id() to do btf_struct_ids_match() internally, so to > support this, we'd have to call fb->check_btf_id() inside the loop > while doing WALK_STRUCT struct. But let's not change all this in this > patch set, it's involved enough already. > > > verbose(env, "Helper does not support %s in R%d\n", > > @@ -3977,7 +3982,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, > > > > return -EACCES; > > } > > - if (!tnum_is_const(reg->var_off) || reg->var_off.value || reg->off) { > > + if (!ids_match && > > + (!tnum_is_const(reg->var_off) || reg->var_off.value || reg->off)) { > > Isn't this still wrong? if ids_match, but reg->var_off is non-zero, > that's still bad, right? > ids_match just "mitigates" reg->off check, so should be something like this: > > if ((reg->off && !ids_match) || !tnum_is_const(reg->var_off) || > reg->var_off.value) > ... then bad ... damn you're right, those are separated things, I mixed it up, I'll send new version thanks, jirka