bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org, martin.lau@kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH bpf-next 3/3] bpf: don't require bpf_capable() for GET_INFO_BY_FD
Date: Thu, 25 May 2023 21:49:40 +0200	[thread overview]
Message-ID: <c231bac1-b3d4-ccb1-9122-d681cd9624ff@iogearbox.net> (raw)
In-Reply-To: <CAEf4BzbNR+u2fvp82+cd-SOAGOL8QM4QEf4XgUQgQ5mp89Hc5Q@mail.gmail.com>

On 5/25/23 7:20 PM, Andrii Nakryiko wrote:
> On Thu, May 25, 2023 at 6:14 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>> On 5/25/23 12:54 AM, Andrii Nakryiko wrote:
>>> The rest of BPF subsystem follows the rule that if process managed to
>>> get BPF object FD, then it has an ownership of this object, and thus can
>>> query any information about it, or update it. Doing something special in
>>> GET_INFO_BY_FD operation based on bpf_capable() goes against that
>>> philosophy, so drop the check and unify the approach with the rest of
>>> bpf() syscall.
>>>
>>> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
>>> ---
>>>    kernel/bpf/syscall.c | 11 -----------
>>>    1 file changed, 11 deletions(-)
>>>
>>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>>> index 1d74c0a8d903..b07453ce10e7 100644
>>> --- a/kernel/bpf/syscall.c
>>> +++ b/kernel/bpf/syscall.c
>>> @@ -4022,17 +4022,6 @@ static int bpf_prog_get_info_by_fd(struct file *file,
>>>
>>>        info.verified_insns = prog->aux->verified_insns;
>>>
>>> -     if (!bpf_capable()) {
>>> -             info.jited_prog_len = 0;
>>> -             info.xlated_prog_len = 0;
>>> -             info.nr_jited_ksyms = 0;
>>> -             info.nr_jited_func_lens = 0;
>>> -             info.nr_func_info = 0;
>>> -             info.nr_line_info = 0;
>>> -             info.nr_jited_line_info = 0;
>>> -             goto done;
>>> -     }
>>
>> Isn't this leaking raw kernel pointers from JIT image this way for unpriv? I think that
>> is the main reason why we guarded this (originally behind !capable(CAP_SYS_ADMIN)) back
>> then..
> 
> Ah, ok, makes sense. We are protecting kernel from unpriv prog/user,
> so the "if you have FD you can get info about object" rule doesn't
> apply here.

Yeah that is correct.

  reply	other threads:[~2023-05-25 19:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 22:54 [PATCH bpf-next 0/3] Relax checks for unprivileged bpf() commands Andrii Nakryiko
2023-05-24 22:54 ` [PATCH bpf-next 1/3] bpf: drop unnecessary bpf_capable() check in BPF_MAP_FREEZE command Andrii Nakryiko
2023-05-24 22:54 ` [PATCH bpf-next 2/3] bpf: don't require CAP_SYS_ADMIN for getting NEXT_ID Andrii Nakryiko
2023-05-25  3:22   ` Alexei Starovoitov
2023-05-25 17:04     ` Andrii Nakryiko
2023-05-25 17:11       ` Alexei Starovoitov
2023-05-25 17:30         ` Andrii Nakryiko
2023-05-24 22:54 ` [PATCH bpf-next 3/3] bpf: don't require bpf_capable() for GET_INFO_BY_FD Andrii Nakryiko
2023-05-25 13:13   ` Daniel Borkmann
2023-05-25 17:20     ` Andrii Nakryiko
2023-05-25 19:49       ` Daniel Borkmann [this message]
2023-05-25 17:20 ` [PATCH bpf-next 0/3] Relax checks for unprivileged bpf() commands patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c231bac1-b3d4-ccb1-9122-d681cd9624ff@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).