Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp182502rwi; Wed, 12 Oct 2022 18:15:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77DwSUEygWEsG3PgygeDBTvXw41KJgvocBvmTHNoFVwYDYvOXaDt9W9UvpjlYtFP38IVPn X-Received: by 2002:a17:907:162a:b0:783:d11a:a553 with SMTP id hb42-20020a170907162a00b00783d11aa553mr25077401ejc.482.1665623720575; Wed, 12 Oct 2022 18:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665623720; cv=none; d=google.com; s=arc-20160816; b=tOgOBISFapKjHjZ+WM5ktaKrGEnKNNmA9ha1V186xK+c9NqEOpXpkGS4dDNBEzIcVD hsuAi7wVuq52f7+xzVBFkQAkXDScHFzhbbspaoQKDEA9KpWSdSVUZtqoztT7f1yw0bi3 9WOP5TXddqY9gRaCL12T6ldPwvmGbHmGg6nNEchX2OcOnWsK6GP6K4iFRnWKIDVG0M/L YVVpHiYwQUT3kIoAJRJRnpu+KRpWo7aSHIAqhSjQvehHv4LuIMWcDmc9g0GDlYgmKrZV kxYgUo9lKAf/QYb9M7Q41NdPBr/qKyt3Eqi2r3I63Fd2auUkb6KaBA0xTkXAla4Nyj2v E4Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=k/4PQl6S8K8YKQWiw/lI3bN5DKyscYp+FE64FP1WhMc=; b=ooTrPLMa5PCM+D3eTeGEwLNrer+RKp0D17BDFvvUAQaLxYIM/2oL+AzT8jV2JO2fXh Hg3vKwWYjumAEsQc2SzV9iJfjCLCesSi04CMAolbhUfxln2t/H0jfOMYFJZ8+ugLWcIS g0RhBvZi+G/zz9eI/ScaS8EqelT04zvfxik7AcNpE1zH20zhLPzHoNdY8+8skgyYreVl u+nI5XyF+dPOHIkolL6IvpG2LqZJt17Fpl92q67Sw65eLPhbRiFKQjMW82zh/tqXFyc1 qkin1lTIYiGurfGZcicIdQErmqo6QHhQdE1mrLoTkFx/otumL7XYrSk1ki4xhfy/nExe i7OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vwmhvq8r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb10-20020a170907960a00b007848e6eaef1si14171354ejc.733.2022.10.12.18.14.33; Wed, 12 Oct 2022 18:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vwmhvq8r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232183AbiJMAzN (ORCPT + 99 others); Wed, 12 Oct 2022 20:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbiJMAyv (ORCPT ); Wed, 12 Oct 2022 20:54:51 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867093FED2; Wed, 12 Oct 2022 17:51:48 -0700 (PDT) Message-ID: <1e01ab5a-c171-0b7a-751a-9ba7da4cd5dd@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1665622237; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k/4PQl6S8K8YKQWiw/lI3bN5DKyscYp+FE64FP1WhMc=; b=vwmhvq8re7hbiOG4qBRSk4FXZM/nzGus4gj56imZuUUEOGAxRTzr7oem1Nr2XYucFaM8ws 9tblSdKkJ607zHYuoMz3/+F/LF5zj97zTGnXJS4b8/gu3zTke9pJcpEx3Hyq0nDR7WTSm/ xIu1wnErkWQRoNRpyICmTSuwHnEpFGM= Date: Wed, 12 Oct 2022 17:50:33 -0700 MIME-Version: 1.0 Subject: Re: [PATCH] bpf/btf: Fix is_int_ptr() Content-Language: en-US To: Chengming Zhou Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org References: <20221012125815.76120-1-zhouchengming@bytedance.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20221012125815.76120-1-zhouchengming@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/22 5:58 AM, Chengming Zhou wrote: > When tracing a kernel function with arg type is u32*, btf_ctx_access() > would report error: arg2 type INT is not a struct. > > The commit bb6728d75611 ("bpf: Allow access to int pointer arguments > in tracing programs") added support for int pointer, but don't skip > modifiers before checking it's type. This patch fixes it. A selftest is needed. You can refer to the selftest added in the patch set [0] of the commit bb6728d75611. This belongs to bpf-next. Please tag it as bpf-next and also v2 in the next revision: Documentation/bpf/bpf_devel_QA.rst (Q: How do I indicate which tree....) [0]: https://lore.kernel.org/bpf/20211208193245.172141-2-jolsa@kernel.org/ > > Fixes: bb6728d75611 ("bpf: Allow access to int pointer arguments in tracing programs") > Signed-off-by: Chengming Zhou > --- > kernel/bpf/btf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index eba603cec2c5..2b343c42ed10 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -5316,8 +5316,8 @@ static bool is_int_ptr(struct btf *btf, const struct btf_type *t) > /* t comes in already as a pointer */ > t = btf_type_by_id(btf, t->type); > > - /* allow const */ > - if (BTF_INFO_KIND(t->info) == BTF_KIND_CONST) > + /* skip modifiers */ > + while (btf_type_is_modifier(t)) There is btf_type_skip_modifiers() that should be useful here. > t = btf_type_by_id(btf, t->type); > > return btf_type_is_int(t);