Re: [RFC PATCH bpf-next 05/16] bpf: create file or anonymous dumpers

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

 



On Fri, Apr 10, 2020 at 3:43 PM Yonghong Song <yhs@xxxxxx> wrote:
>
>
>
> On 4/9/20 8:00 PM, Alexei Starovoitov wrote:
> > On Wed, Apr 08, 2020 at 04:25:26PM -0700, Yonghong Song wrote:
> >> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> >> index 0f1cbed446c1..b51d56fc77f9 100644
> >> --- a/include/uapi/linux/bpf.h
> >> +++ b/include/uapi/linux/bpf.h
> >> @@ -354,6 +354,7 @@ enum {
> >>   /* Flags for accessing BPF object from syscall side. */
> >>      BPF_F_RDONLY            = (1U << 3),
> >>      BPF_F_WRONLY            = (1U << 4),
> >> +    BPF_F_DUMP              = (1U << 5),
> > ...
> >>   static int bpf_obj_pin(const union bpf_attr *attr)
> >>   {
> >> -    if (CHECK_ATTR(BPF_OBJ) || attr->file_flags != 0)
> >> +    if (CHECK_ATTR(BPF_OBJ) || attr->file_flags & ~BPF_F_DUMP)
> >>              return -EINVAL;
> >>
> >> +    if (attr->file_flags == BPF_F_DUMP)
> >> +            return bpf_dump_create(attr->bpf_fd,
> >> +                                   u64_to_user_ptr(attr->dumper_name));
> >> +
> >>      return bpf_obj_pin_user(attr->bpf_fd, u64_to_user_ptr(attr->pathname));
> >>   }
> >
> > I think kernel can be a bit smarter here. There is no need for user space
> > to pass BPF_F_DUMP flag to kernel just to differentiate the pinning.
> > Can prog attach type be used instead?
>
> Think again. I think a flag is still useful.
> Suppose that we have the following scenario:
>    - the current directory /sys/fs/bpf/
>    - user says pin a tracing/dump (target task) prog to "p1"
>
> It is not really clear whether user wants to pin to
>     /sys/fs/bpf/p1
> or user wants to pin to
>     /sys/kernel/bpfdump/task/p1
>
> unless we say that a tracing/dump program cannot pin
> to /sys/fs/bpf which seems unnecessary restriction.
>
> What do you think?

Instead of special-casing dumper_name, can we require specifying full
path, and then check whether it is in BPF FS vs BPFDUMP FS? If the
latter, additionally check that it is in the right sub-directory
matching its intended target type.

But honestly, just doing everything within BPF FS starts to seem
cleaner at this point...



[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