public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Chengming Zhou <zhouchengming@bytedance.com>
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
Subject: Re: [PATCH] bpf/btf: Fix is_int_ptr()
Date: Wed, 12 Oct 2022 17:50:33 -0700	[thread overview]
Message-ID: <1e01ab5a-c171-0b7a-751a-9ba7da4cd5dd@linux.dev> (raw)
In-Reply-To: <20221012125815.76120-1-zhouchengming@bytedance.com>

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 <zhouchengming@bytedance.com>
> ---
>   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);


  reply	other threads:[~2022-10-13  0:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 12:58 [PATCH] bpf/btf: Fix is_int_ptr() Chengming Zhou
2022-10-13  0:50 ` Martin KaFai Lau [this message]
2022-10-13  2:27   ` Chengming Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e01ab5a-c171-0b7a-751a-9ba7da4cd5dd@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    --cc=zhouchengming@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox