Re: [bug report] bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr

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

 



On Mon, Jul 31, 2023 at 01:47:01PM -0700, Alexei Starovoitov wrote:
> Probably the following will be enough:
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index 56ce5008aedd..eb91cae0612a 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -2270,7 +2270,7 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct
> bpf_dynptr_kern *ptr, u32 offset
>         case BPF_DYNPTR_TYPE_XDP:
>         {
>                 void *xdp_ptr = bpf_xdp_pointer(ptr->data, ptr->offset
> + offset, len);
> -               if (xdp_ptr)
> +               if (!IS_ERR_OR_NULL(xdp_ptr))
>                         return xdp_ptr;

Also please, add a comment to bpf_xdp_pointer() which explains what the
NULL return means.  I couldn't figure it out.

> 
> Also I've noticed:
> void bpf_xdp_copy_buf(struct xdp_buff *xdp, unsigned long off,
>                       void *buf, unsigned long len, bool flush);
> #else /* CONFIG_NET */
> static inline void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
> {
>         return NULL;
> }
> 
> The latter is wrong.

This the only part which I thought I understood.  :P  How is this wrong?

regards,
dan carpenter





[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