From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Kenny Ho <y2kenny@gmail.com>
Cc: Kenny Ho <Kenny.Ho@amd.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org,
Alex Deucher <alexander.deucher@amd.com>,
amd-gfx list <amd-gfx@lists.freedesktop.org>
Subject: Re: [RFC] Add BPF_PROG_TYPE_CGROUP_IOCTL
Date: Mon, 2 Nov 2020 21:32:44 -0800 [thread overview]
Message-ID: <20201103053244.khibmr66p7lhv7ge@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <CAOWid-d=a1Q3R92s7GrzxWhXx7_dc8NQvQg7i7RYTVv3+jHxkQ@mail.gmail.com>
On Mon, Nov 02, 2020 at 02:23:02PM -0500, Kenny Ho wrote:
> Adding a few more emails from get_maintainer.pl and bumping this
> thread since there hasn't been any comments so far. Is this too
> crazy? Am I missing something fundamental?
sorry for delay. Missed it earlier. Feel free to ping the mailing list
sooner next time.
> On Wed, Oct 7, 2020 at 11:24 AM Kenny Ho <Kenny.Ho@amd.com> wrote:
> >
> > This is a skeleton implementation to invite comments and generate
> > discussion around the idea of introducing a bpf-cgroup program type to
> > control ioctl access. This is modelled after
> > BPF_PROG_TYPE_CGROUP_DEVICE. The premise is to allow system admins to
> > write bpf programs to block some ioctl access, potentially in conjunction
> > with data collected by other bpf programs stored in some bpf maps and
> > with bpf_spin_lock.
> >
> > For example, a bpf program has been accumulating resource usaging
> > statistic and a second bpf program of BPF_PROG_TYPE_CGROUP_IOCTL would
> > block access to previously mentioned resource via ioctl when the stats
> > stored in a bpf map reaches certain threshold.
> >
> > Like BPF_PROG_TYPE_CGROUP_DEVICE, the default is permissive (i.e.,
> > ioctls are not blocked if no bpf program is present for the cgroup.) to
> > maintain current interface behaviour when this functionality is unused.
> >
> > Performance impact to ioctl calls is minimal as bpf's in-kernel verifier
> > ensure attached bpf programs cannot crash and always terminate quickly.
> >
> > TODOs:
> > - correct usage of the verifier
> > - toolings
> > - samples
> > - device driver may provide helper functions that take
> > bpf_cgroup_ioctl_ctx and return something more useful for specific
> > device
> >
> > Signed-off-by: Kenny Ho <Kenny.Ho@amd.com>
...
> > @@ -45,6 +46,10 @@ long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> > if (!filp->f_op->unlocked_ioctl)
> > goto out;
> >
> > + error = BPF_CGROUP_RUN_PROG_IOCTL(filp, cmd, arg);
> > + if (error)
> > + goto out;
> > +
That's a bit problematic, since we have bpf_lsm now.
Could you use security_file_ioctl hook and do the same filtering there?
It's not cgroup based though. Is it a concern?
If cgroup scoping is really necessary then it's probably better
to add it to bpf_lsm. Then all hooks will become cgroup aware.
next prev parent reply other threads:[~2020-11-03 5:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 15:23 [RFC] Add BPF_PROG_TYPE_CGROUP_IOCTL Kenny Ho
2020-11-02 19:23 ` Kenny Ho
2020-11-03 5:32 ` Alexei Starovoitov [this message]
2020-11-03 5:39 ` Kenny Ho
2020-11-03 5:42 ` Alexei Starovoitov
2020-11-03 19:19 ` Kenny Ho
2020-11-03 21:04 ` Alexei Starovoitov
2020-11-03 22:57 ` Kenny Ho
2020-11-03 23:28 ` Alexei Starovoitov
2021-02-01 14:49 ` Daniel Vetter
2021-02-01 16:51 ` Kenny Ho
2021-02-03 11:09 ` Daniel Vetter
2021-02-03 19:01 ` Kenny Ho
2021-02-05 13:49 ` Daniel Vetter
2021-05-07 2:06 ` Kenny Ho
2021-05-07 8:59 ` Daniel Vetter
2021-05-07 15:33 ` Kenny Ho
2021-05-07 16:13 ` Daniel Vetter
2021-05-07 16:19 ` Alex Deucher
2021-05-07 16:26 ` Daniel Vetter
2021-05-07 16:31 ` Alex Deucher
2021-05-07 16:50 ` Alex Deucher
2021-05-07 16:54 ` Daniel Vetter
2021-05-07 17:04 ` Kenny Ho
2021-05-07 19:33 ` Tejun Heo
2021-05-07 19:55 ` Alex Deucher
2021-05-07 20:59 ` Tejun Heo
2021-05-07 22:30 ` Alex Deucher
2021-05-07 23:45 ` Tejun Heo
2021-05-11 15:48 ` Alex Deucher
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=20201103053244.khibmr66p7lhv7ge@ast-mbp.dhcp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=Kenny.Ho@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=viro@zeniv.linux.org.uk \
--cc=y2kenny@gmail.com \
--cc=yhs@fb.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).