From: Roberto Sassu <roberto.sassu@huaweicloud.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Lorenz Bauer <oss@lmb.io>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, bpf <bpf@vger.kernel.org>,
LSM List <linux-security-module@vger.kernel.org>,
Paul Moore <paul@paul-moore.com>,
Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: Closing the BPF map permission loophole
Date: Mon, 12 Dec 2022 19:19:05 +0100 [thread overview]
Message-ID: <3fa1fdafc4335c43f84259261dcd1f7d588985a6.camel@huaweicloud.com> (raw)
In-Reply-To: <CAADnVQLU+c+gsZ=V6myG0-GhU3EzZgqjzTPvqvYmCDBjqMoF+Q@mail.gmail.com>
On Mon, 2022-12-12 at 09:07 -0800, Alexei Starovoitov wrote:
> On Mon, Dec 12, 2022 at 8:11 AM Roberto Sassu
> <roberto.sassu@huaweicloud.com> wrote:
> > On Mon, 2022-11-07 at 13:11 +0100, Roberto Sassu wrote:
> >
> > [...]
> >
> > > > > > P.S. We can extend this to BPF-side BPF_F_RDONLY_PROG |
> > > > > > BPF_F_WRONLY_PROG as well, it's just that we'll need to define how
> > > > > > user will control that. E.g., FS read-only permission, does it
> > > > > > restrict both user-space and BPF-view, or just user-space view? We can
> > > > > > certainly extend file_flags to allow users to get BPF-side read-only
> > > > > > and user-space-side read-write BPF map FD, for example. Obviously, BPF
> > > > > > verifier would need to know about struct bpf_map_view when accepting
> > > > > > BPF map FD in ldimm64 and such.
> > > > >
> > > > > I guess, this patch could be used:
> > > > >
> > > > > https://lore.kernel.org/bpf/20220926154430.1552800-3-roberto.sassu@huaweicloud.com/
> > > > >
> > > > > When passing a fd to an eBPF program, the permissions of the user space
> > > > > side cannot exceed those defined from eBPF program side.
> > > >
> > > > Don't know, maybe. But I can see how BPF-side can be declared r/w for
> > > > BPF programs, while user-space should be restricted to read-only. I'm
> > > > a bit hesitant to artificially couple both together.
> > >
> > > Ok. At least what I would do is to forbid write, if you provide a read-
> > > only fd.
> >
> > Ok, we didn't do too much progress for a while. I would like to resume
> > the discussion.
> >
> > Can we start from the first point Lorenz mentioned? Given a read-only
> > map fd, it is not possible to write to the map. Can we make sure that
> > this properly work?
> >
> > In my opinion, to achieve this particular goal, the map view
> > abstraction Andrii suggested, should not be necessary.
>
> What do you 'not necessary' ?
> afair the map view abstraction is only one that actually addresses
> all the issues.
For the first issue, map iterators, you need to ensure that the fd is
read-write if the key/value can be modified.
For the second issue, fd modes ignored by the verifier, you need to
restrict operations on the map, to meet the expectactions of whoever
granted the fd to the requestor (as Lorenz said, if you have a read-
only fd, you should not be able to write to the map).
Maybe I missed something, I didn't get how the map view abstraction
could help better in these cases.
Thanks
Roberto
next prev parent reply other threads:[~2022-12-12 18:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a6c0bb85-6eeb-407e-a515-06f67e70db57@www.fastmail.com>
[not found] ` <8e243ad132ecf2885fc65c33c7793f0703937890.camel@huaweicloud.com>
[not found] ` <7f7c3337-74f1-424e-a14d-578c4c7ee2fe@www.fastmail.com>
[not found] ` <65546f56be138ab326544b7b2e59bb3175ec884a.camel@huaweicloud.com>
[not found] ` <b0c00f80-c11e-4f5d-ba63-2e9fb7cad561@www.fastmail.com>
[not found] ` <9aba20351924aa0d82d258205030ad4f2c404de2.camel@huaweicloud.com>
[not found] ` <98a26e5c-d44f-4e65-8186-c4e94918daa1@www.fastmail.com>
[not found] ` <06a47f11778ca9d074c815e57dc1c75d073b3a85.camel@huaweicloud.com>
[not found] ` <439dd1e5-71b8-49ed-8268-02b3428a55a4@www.fastmail.com>
2022-09-28 9:42 ` Closing the BPF map permission loophole Roberto Sassu
2022-09-28 10:33 ` Toke Høiland-Jørgensen
2022-09-28 11:23 ` Roberto Sassu
2022-09-29 0:24 ` Paul Moore
2022-09-29 7:54 ` Roberto Sassu
2022-09-29 15:27 ` Casey Schaufler
2022-09-30 7:42 ` Roberto Sassu
2022-09-29 22:30 ` Paul Moore
2022-09-30 9:56 ` Roberto Sassu
2022-09-30 20:43 ` Paul Moore
2022-10-04 8:03 ` Roberto Sassu
[not found] ` <21be7356-8710-408a-94e3-1a0d3f5f842e@www.fastmail.com>
2022-10-06 7:15 ` Roberto Sassu
[not found] ` <CAEf4BzawXPiXY3mNabi0ggyTS9wtg6mh8x97=fYGhuGj4=2hnw@mail.gmail.com>
2022-10-31 11:53 ` Roberto Sassu
2022-11-04 21:10 ` Andrii Nakryiko
2022-11-07 12:11 ` Roberto Sassu
2022-12-12 16:10 ` Roberto Sassu
2022-12-12 17:07 ` Alexei Starovoitov
2022-12-12 18:19 ` Roberto Sassu [this message]
2022-12-16 10:23 ` Roberto Sassu
2022-12-20 20:44 ` Paul Moore
2022-12-21 9:53 ` Roberto Sassu
2022-12-22 0:55 ` Paul Moore
2023-01-10 9:11 ` Roberto Sassu
2023-01-13 23:44 ` Andrii Nakryiko
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=3fa1fdafc4335c43f84259261dcd1f7d588985a6.camel@huaweicloud.com \
--to=roberto.sassu@huaweicloud.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=casey@schaufler-ca.com \
--cc=daniel@iogearbox.net \
--cc=kpsingh@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=oss@lmb.io \
--cc=paul@paul-moore.com \
--cc=sdf@google.com \
/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).