[PATCH v2 0/2] Fix failure to access u32* argument of tracked function

Feng zhou posted 2 patches 2 years, 10 months ago
There is a newer version of this series
kernel/bpf/btf.c                                    |  5 ++---
net/bpf/test_run.c                                  |  8 +++++++-
.../testing/selftests/bpf/verifier/btf_ctx_access.c | 13 +++++++++++++
3 files changed, 22 insertions(+), 4 deletions(-)
[PATCH v2 0/2] Fix failure to access u32* argument of tracked function
Posted by Feng zhou 2 years, 10 months ago
From: Feng Zhou <zhoufeng.zf@bytedance.com>

When access traced function arguments with type is u32*, bpf verifier failed.
Because u32 have typedef, needs to skip modifier. Add btf_type_is_modifier in
is_int_ptr. Add a selftest to check it.

Feng Zhou (2):
  bpf/btf: Fix is_int_ptr()
  selftests/bpf: Add test to access u32 ptr argument in tracing program

Changelog:
v1->v2: Addressed comments from Martin KaFai Lau
- Add a selftest.
- use btf_type_skip_modifiers.
Some details in here:
https://lore.kernel.org/all/20221012125815.76120-1-zhouchengming@bytedance.com/

 kernel/bpf/btf.c                                    |  5 ++---
 net/bpf/test_run.c                                  |  8 +++++++-
 .../testing/selftests/bpf/verifier/btf_ctx_access.c | 13 +++++++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)

-- 
2.20.1
Re: [PATCH v2 0/2] Fix failure to access u32* argument of tracked function
Posted by Jiri Olsa 2 years, 10 months ago
On Fri, Apr 07, 2023 at 04:46:06PM +0800, Feng zhou wrote:
> From: Feng Zhou <zhoufeng.zf@bytedance.com>
> 
> When access traced function arguments with type is u32*, bpf verifier failed.
> Because u32 have typedef, needs to skip modifier. Add btf_type_is_modifier in
> is_int_ptr. Add a selftest to check it.
> 
> Feng Zhou (2):
>   bpf/btf: Fix is_int_ptr()
>   selftests/bpf: Add test to access u32 ptr argument in tracing program

hi,
it breaks several tests in test_progs suite:

#11/36   bpf_iter/link-iter:FAIL
#11      bpf_iter:FAIL
test_dummy_st_ops_attach:FAIL:dummy_st_ops_load unexpected error: -13
#63/1    dummy_st_ops/dummy_st_ops_attach:FAIL
test_dummy_init_ret_value:FAIL:dummy_st_ops_load unexpected error: -13
#63/2    dummy_st_ops/dummy_init_ret_value:FAIL
test_dummy_init_ptr_arg:FAIL:dummy_st_ops_load unexpected error: -13
#63/3    dummy_st_ops/dummy_init_ptr_arg:FAIL
test_dummy_multiple_args:FAIL:dummy_st_ops_load unexpected error: -13
#63/4    dummy_st_ops/dummy_multiple_args:FAIL
test_dummy_sleepable:FAIL:dummy_st_ops_load unexpected error: -13
#63/5    dummy_st_ops/dummy_sleepable:FAIL
#63      dummy_st_ops:FAIL
test_fentry_fexit:FAIL:fentry_skel_load unexpected error: -13
#69      fentry_fexit:FAIL
test_fentry_test:FAIL:fentry_skel_load unexpected error: -13
#70      fentry_test:FAIL

jirka

> 
> Changelog:
> v1->v2: Addressed comments from Martin KaFai Lau
> - Add a selftest.
> - use btf_type_skip_modifiers.
> Some details in here:
> https://lore.kernel.org/all/20221012125815.76120-1-zhouchengming@bytedance.com/
> 
>  kernel/bpf/btf.c                                    |  5 ++---
>  net/bpf/test_run.c                                  |  8 +++++++-
>  .../testing/selftests/bpf/verifier/btf_ctx_access.c | 13 +++++++++++++
>  3 files changed, 22 insertions(+), 4 deletions(-)
> 
> -- 
> 2.20.1
>