Re: [bpf-next v8 1/2] bpf: Add bpf_copy_from_user_str kfunc

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

 



On Thu, Aug 22, 2024 at 8:45 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Thu, Aug 22, 2024 at 5:22 PM Jordan Rome <linux@xxxxxxxxxxxxxx> wrote:
> >
> > On Thu, Aug 22, 2024 at 8:15 PM Alexei Starovoitov
> > <alexei.starovoitov@xxxxxxxxx> wrote:
> > >
> > > On Thu, Aug 22, 2024 at 5:06 PM Jordan Rome <linux@xxxxxxxxxxxxxx> wrote:
> > > >
> > > > +/**
> > > > + * bpf_copy_from_user_str() - Copy a string from an unsafe user address
> > > > + * @dst:             Destination address, in kernel space.  This buffer must be at
> > > > + *                   least @dst__szk bytes long.
> > > > + * @dst__szk:        Maximum number of bytes to copy, including the trailing NUL.
> > > > + * @unsafe_ptr__ign: Source address, in user space.
> > > > + * @flags:           The only supported flag is BPF_F_PAD_ZEROS
> > > > + *
> > > > + * Copies a NUL-terminated string from userspace to BPF space. If user string is
> > > > + * too long this will still ensure zero termination in the dst buffer unless
> > > > + * buffer size is 0.
> > > > + *
> > > > + * If BPF_F_PAD_ZEROS flag is set, memset the tail of @dst to 0 on success and
> > > > + * memset all of @dst on failure.
> > > > + */
> > > > +__bpf_kfunc int bpf_copy_from_user_str(void *dst, u32 dst__szk, const void __user *unsafe_ptr__ign, u64 flags)
> > >
> > > Did you miss my previous comment re __szk vs __sz ?
> > >
> >
> > Ah, yes, I did miss it. Will fix.
> >
> > > > +enum {
> > > > +       BPF_F_PAD_ZEROS = (1ULL << 0),
> > > > +};
> > >
> > > Pls give enum a name, so it's easier for CORE logic to detect the
> > > presence of this feature in the kernel.
> >
> > How about 'bpf_copy_str_flags' ? As I imagine we will use this flag on
> > 'bpf_copy_from_user_task_str', when I add that.
>
> Maybe 'enum bpf_kfunc_flags' ?
> since BPF_F_PAD_ZEROS is supposed to be generic and apply to various kfuncs.

Works for me.





[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