From: Kui-Feng Lee <thinker.li@xxxxxxxxx> Pointers to int are always accepted when checking accesses of a context in btf_ctx_access(). However, we are going to support pointers to scalar types with PTR_TO_BTF_ID. Changing the order of checking prog->aux->ctx_arg_info and checking is_int_ptr() enables the extension in the following patches. Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx> --- kernel/bpf/btf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index ef380e546952..0847035bba99 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -6252,9 +6252,6 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, */ return true; - if (is_int_ptr(btf, t)) - return true; - /* this is a pointer to another type */ for (i = 0; i < prog->aux->ctx_arg_info_size; i++) { const struct bpf_ctx_arg_aux *ctx_arg_info = &prog->aux->ctx_arg_info[i]; @@ -6272,6 +6269,9 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, } } + if (is_int_ptr(btf, t)) + return true; + info->reg_type = PTR_TO_BTF_ID; if (prog_args_trusted(prog)) info->reg_type |= PTR_TRUSTED; -- 2.34.1