Re: [PATCH v6 bpf-next 2/9] bpf: Factor out helper check_reg_const_str()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 24, 2023 at 4:56 PM Song Liu <song@xxxxxxxxxx> wrote:
>
> ARG_PTR_TO_CONST_STR is used to specify constant string args for BPF
> helpers. The logic that verifies a reg is ARG_PTR_TO_CONST_STR is
> implemented in check_func_arg().
>
> As we introduce kfuncs with constant string args, it is necessary to
> do the same check for kfuncs (in check_kfunc_args). Factor out the logic
> for ARG_PTR_TO_CONST_STR to a new check_reg_const_str() so that it can be
> reused.
>
> check_func_arg() ensures check_reg_const_str() is only called with reg of
> type PTR_TO_MAP_VALUE. Add a redundent type check in check_reg_const_str()
> to avoid misuse in the future. Other than this redundent check, there is
> no change in behavior.
>
> Signed-off-by: Song Liu <song@xxxxxxxxxx>
> ---
>  kernel/bpf/verifier.c | 85 +++++++++++++++++++++++++------------------
>  1 file changed, 49 insertions(+), 36 deletions(-)
>

LGTM, I don't feel too strongly about that added WARN_ON_ONCE.

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>


> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 857d76694517..238a8e08e781 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -8571,6 +8571,54 @@ static enum bpf_dynptr_type dynptr_get_type(struct bpf_verifier_env *env,
>         return state->stack[spi].spilled_ptr.dynptr.type;
>  }
>

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux