diff options
author | Feng Zhou <zhoufeng.zf@bytedance.com> | 2023-04-10 16:59:07 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-11 23:17:16 +0900 |
commit | 051cb7751cad4547b7ff00a46c9667a1894aed5f (patch) | |
tree | d4ae13758f2ef5d009f85f05462992e2df5055c0 /kernel | |
parent | d03333ce0ef076d804b98ece5ead497e7e040d3a (diff) | |
download | linux-stable-051cb7751cad4547b7ff00a46c9667a1894aed5f.tar.gz linux-stable-051cb7751cad4547b7ff00a46c9667a1894aed5f.tar.bz2 linux-stable-051cb7751cad4547b7ff00a46c9667a1894aed5f.zip |
bpf/btf: Fix is_int_ptr()
[ Upstream commit 91f2dc6838c19342f7f2993627c622835cc24890 ]
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 did not skip
modifiers before checking it's type. This patch fixes it.
Fixes: bb6728d75611 ("bpf: Allow access to int pointer arguments in tracing programs")
Co-developed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20230410085908.98493-2-zhoufeng.zf@bytedance.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/btf.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 73780748404c..3140a7881665 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -5891,12 +5891,8 @@ struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog) 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) - t = btf_type_by_id(btf, t->type); + /* skip modifiers */ + t = btf_type_skip_modifiers(btf, t->type, NULL); return btf_type_is_int(t); } |