Re: [PATCH bpf-next 1/4] helpers: make few bpf helpers public

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

 



On Fri, Apr 25, 2025 at 5:59 AM Mykyta Yatsenko
<mykyta.yatsenko5@xxxxxxxxx> wrote:
>
> From: Mykyta Yatsenko <yatsenko@xxxxxxxx>
>
> Make bpf_dynptr_slice_rdwr, bpf_dynptr_check_off_len and
> __bpf_dynptr_write available outside of the helpers.c by
> adding their prototypes into linux/include/bpf.h.
> These functions are going to be used from bpf_trace.c in the next
> patch of this series.
>
> Signed-off-by: Mykyta Yatsenko <yatsenko@xxxxxxxx>
> ---
>  include/linux/bpf.h  | 7 +++++++
>  kernel/bpf/helpers.c | 6 +++---
>  2 files changed, 10 insertions(+), 3 deletions(-)
>

LGTM

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 3f0cc89c0622..14f219921b4c 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1349,6 +1349,13 @@ u32 __bpf_dynptr_size(const struct bpf_dynptr_kern *ptr);
>  const void *__bpf_dynptr_data(const struct bpf_dynptr_kern *ptr, u32 len);
>  void *__bpf_dynptr_data_rw(const struct bpf_dynptr_kern *ptr, u32 len);
>  bool __bpf_dynptr_is_rdonly(const struct bpf_dynptr_kern *ptr);
> +int __bpf_dynptr_write(const struct bpf_dynptr_kern *dst, u32 offset,
> +                      void *src, u32 len, u64 flags);
> +int bpf_dynptr_check_off_len(const struct bpf_dynptr_kern *ptr, u32 offset, u32 len);
> +void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr *p, u32 offset,
> +                           void *buffer__opt, u32 buffer__szk);
> +int bpf_dynptr_check_off_len(const struct bpf_dynptr_kern *ptr,
> +                            u32 offset, u32 len);
>
>  #ifdef CONFIG_BPF_JIT
>  int bpf_trampoline_link_prog(struct bpf_tramp_link *link,
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index e3a2662f4e33..2aad7c57425b 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -1713,7 +1713,7 @@ void bpf_dynptr_set_null(struct bpf_dynptr_kern *ptr)
>         memset(ptr, 0, sizeof(*ptr));
>  }
>
> -static int bpf_dynptr_check_off_len(const struct bpf_dynptr_kern *ptr, u32 offset, u32 len)
> +int bpf_dynptr_check_off_len(const struct bpf_dynptr_kern *ptr, u32 offset, u32 len)
>  {
>         u32 size = __bpf_dynptr_size(ptr);
>
> @@ -1809,8 +1809,8 @@ static const struct bpf_func_proto bpf_dynptr_read_proto = {
>         .arg5_type      = ARG_ANYTHING,
>  };
>
> -static int __bpf_dynptr_write(const struct bpf_dynptr_kern *dst, u32 offset, void *src,
> -                             u32 len, u64 flags)
> +int __bpf_dynptr_write(const struct bpf_dynptr_kern *dst, u32 offset, void *src,
> +                      u32 len, u64 flags)
>  {
>         enum bpf_dynptr_type type;
>         int err;
> --
> 2.49.0
>





[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