lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2d941e43-72de-b641-22b8-b9ec970ccf52@fb.com>
Date:   Fri, 10 Apr 2020 16:47:36 -0700
From:   Yonghong Song <yhs@...com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
CC:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        Martin KaFai Lau <kafai@...com>,
        Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [RFC PATCH bpf-next 05/16] bpf: create file or anonymous dumpers



On 4/10/20 3:53 PM, Andrii Nakryiko wrote:
> On Fri, Apr 10, 2020 at 3:43 PM Yonghong Song <yhs@...com> 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.

We could. I just think specifying full path for bpfdump is not necessary 
since it is a single user mount...

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

bpffs is multi mount, which is not a perfect fit for bpfdump,
considering mounting inside namespace, etc, all dumpers are gone.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ