public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf/btf: Fix is_int_ptr()
@ 2022-10-12 12:58 Chengming Zhou
  2022-10-13  0:50 ` Martin KaFai Lau
  0 siblings, 1 reply; 3+ messages in thread
From: Chengming Zhou @ 2022-10-12 12:58 UTC (permalink / raw)
  To: martin.lau, ast, daniel, andrii, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa
  Cc: bpf, linux-kernel, Chengming Zhou

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.

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))
 		t = btf_type_by_id(btf, t->type);
 
 	return btf_type_is_int(t);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-13  2:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 12:58 [PATCH] bpf/btf: Fix is_int_ptr() Chengming Zhou
2022-10-13  0:50 ` Martin KaFai Lau
2022-10-13  2:27   ` Chengming Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox