From: "Mickaël Salaün" <mic@digikod.net>
To: Tingmao Wang <m@maowtm.org>
Cc: "Günther Noack" <gnoack@google.com>, "Jan Kara" <jack@suse.cz>,
linux-security-module@vger.kernel.org,
"Amir Goldstein" <amir73il@gmail.com>,
"Matthew Bobrowski" <repnop@google.com>,
linux-fsdevel@vger.kernel.org,
"Tycho Andersen" <tycho@tycho.pizza>,
"Jann Horn" <jannh@google.com>,
"Andy Lutomirski" <luto@amacapital.net>
Subject: Re: [RFC PATCH 4/9] User-space API for creating a supervisor-fd
Date: Wed, 5 Mar 2025 17:09:30 +0100 [thread overview]
Message-ID: <20250305.peiLairahj3A@digikod.net> (raw)
In-Reply-To: <03d822634936f4c3ac8e4843f9913d1b1fa9d081.1741047969.git.m@maowtm.org>
On Tue, Mar 04, 2025 at 01:13:00AM +0000, Tingmao Wang wrote:
> We allow the user to pass in an additional flag to landlock_create_ruleset
> which will make the ruleset operate in "supervise" mode, with a supervisor
> attached. We create additional space in the landlock_ruleset_attr
> structure to pass the newly created supervisor fd back to user-space.
>
> The intention, while not implemented yet, is that the user-space will read
> events from this fd and write responses back to it.
>
> Note: need to investigate if fd clone on fork() is handled correctly, but
> should be fine if it shares the struct file. We might also want to let the
> user customize the flags on this fd, so that they can request no
> O_CLOEXEC.
>
> NOTE: despite this patch having a new uapi, I'm still very open to e.g.
> re-using fanotify stuff instead (if that makes sense in the end). This is
> just a PoC.
The main security risk of this feature is for this FD to leak and be
used by a sandboxed process to bypass all its restrictions. This should
be highlighted in the UAPI documentation.
>
> Signed-off-by: Tingmao Wang <m@maowtm.org>
> ---
> include/uapi/linux/landlock.h | 10 ++++
> security/landlock/syscalls.c | 102 +++++++++++++++++++++++++++++-----
> 2 files changed, 98 insertions(+), 14 deletions(-)
>
> diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
> index e1d2c27533b4..7bc1eb4859fb 100644
> --- a/include/uapi/linux/landlock.h
> +++ b/include/uapi/linux/landlock.h
> @@ -50,6 +50,15 @@ struct landlock_ruleset_attr {
> * resources (e.g. IPCs).
> */
> __u64 scoped;
> + /**
> + * @supervisor_fd: Placeholder to store the supervisor file
> + * descriptor when %LANDLOCK_CREATE_RULESET_SUPERVISE is set.
> + */
> + __s32 supervisor_fd;
This interface would require the ruleset_attr becoming updatable by the
kernel, which might be OK in theory but requires current syscall wrapper
signature update, see sandboxer.c change. It also creates a FD which
might not be useful (e.g. if an error occurs before the actual
enforcement).
I see a few alternatives. We could just use/extend the ruleset FD
instead of creating a new one, but because leaking current rulesets is
not currently a security risk, we should be careful to not change that.
Another approach, similar to seccomp unotify, is to get a
"[landlock-domain]" FD returned by the landlock_restrict_self(2) when a
new LANDLOCK_RESTRICT_SELF_DOMAIN_FD flag is set. This FD would be a
reference to the newly created domain, which is more specific than the
ruleset used to created this domain (and that can be used to create
other domains). This domain FD could be used for introspection (i.e.
to get read-only properties such as domain ID), but being able to
directly supervise the referenced domain only with this FD would be a
risk that we should limit.
What we can do is to implement an IOCTL command for such domain FD that
would return a supervisor FD (if the LANDLOCK_RESTRICT_SELF_SUPERVISED
flag was also set). The key point is to check (one time) that the
process calling this IOCTL is not restricted by the related domain (see
the scope helpers).
Relying on IOCTL commands (for all these FD types) instead of read/write
operations should also limit the risk of these FDs being misused through
a confused deputy attack (because such IOCTL command would convey an
explicit intent):
https://docs.kernel.org/security/credentials.html#open-file-credentials
https://lore.kernel.org/all/CAG48ez0HW-nScxn4G5p8UHtYy=T435ZkF3Tb1ARTyyijt_cNEg@mail.gmail.com/
We should get inspiration from seccomp unotify for this too:
https://lore.kernel.org/all/20181209182414.30862-1-tycho@tycho.ws/
> + /**
> + * @pad: Unused, must be zero.
> + */
> + __u32 pad;
In this case we should pack the struct instead.
> };
>
> /*
> @@ -60,6 +69,7 @@ struct landlock_ruleset_attr {
> */
> /* clang-format off */
> #define LANDLOCK_CREATE_RULESET_VERSION (1U << 0)
> +#define LANDLOCK_CREATE_RULESET_SUPERVISE (1U << 1)
> /* clang-format on */
>
> /**
[...]
next prev parent reply other threads:[~2025-03-05 16:15 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 1:12 [RFC PATCH 0/9] Landlock supervise: a mechanism for interactive permission requests Tingmao Wang
2025-03-04 1:12 ` [RFC PATCH 1/9] Define the supervisor and event structure Tingmao Wang
2025-03-04 1:12 ` [RFC PATCH 2/9] Refactor per-layer information in rulesets and rules Tingmao Wang
2025-03-04 19:49 ` Mickaël Salaün
2025-03-06 2:58 ` Tingmao Wang
2025-03-08 18:57 ` Mickaël Salaün
2025-03-10 0:38 ` Tingmao Wang
2025-03-04 1:12 ` [RFC PATCH 3/9] Adds a supervisor reference in the per-layer information Tingmao Wang
2025-03-04 1:13 ` [RFC PATCH 4/9] User-space API for creating a supervisor-fd Tingmao Wang
2025-03-05 16:09 ` Mickaël Salaün [this message]
2025-03-10 0:41 ` Tingmao Wang
2025-03-11 19:28 ` Mickaël Salaün
2025-03-26 0:06 ` Tingmao Wang
2025-04-11 10:55 ` Mickaël Salaün
2025-03-04 1:13 ` [RFC PATCH 5/9] Define user structure for events and responses Tingmao Wang
2025-03-04 19:49 ` Mickaël Salaün
2025-03-06 3:05 ` Tingmao Wang
2025-03-08 19:07 ` Mickaël Salaün
2025-03-10 0:39 ` Tingmao Wang
2025-03-11 19:29 ` Mickaël Salaün
2025-03-10 0:39 ` Tingmao Wang
2025-03-11 19:28 ` Mickaël Salaün
2025-03-11 23:18 ` Tingmao Wang
2025-03-12 11:49 ` Mickaël Salaün
2025-03-26 0:02 ` Tingmao Wang
2025-03-05 4:13 ` kernel test robot
2025-03-04 1:13 ` [RFC PATCH 6/9] Creating supervisor events for filesystem operations Tingmao Wang
2025-03-04 19:50 ` Mickaël Salaün
2025-03-10 0:39 ` Tingmao Wang
2025-03-11 19:29 ` Mickaël Salaün
2025-03-05 5:05 ` kernel test robot
2025-03-04 1:13 ` [RFC PATCH 7/9] Implement fdinfo for ruleset and supervisor fd Tingmao Wang
2025-03-04 1:13 ` [RFC PATCH 8/9] Implement fops for supervisor-fd Tingmao Wang
2025-03-04 1:13 ` [RFC PATCH 9/9] Enhance the sandboxer example to support landlock-supervise Tingmao Wang
2025-03-05 3:36 ` kernel test robot
2025-03-04 19:48 ` [RFC PATCH 0/9] Landlock supervise: a mechanism for interactive permission requests Mickaël Salaün
2025-03-06 2:57 ` Tingmao Wang
2025-03-06 17:07 ` Amir Goldstein
2025-03-08 19:14 ` Mickaël Salaün
2025-03-11 0:42 ` Tingmao Wang
2025-03-11 19:28 ` Mickaël Salaün
2025-03-11 20:58 ` Song Liu
2025-03-11 22:03 ` Tingmao Wang
2025-03-11 23:23 ` Song Liu
2025-03-12 11:50 ` Mickaël Salaün
2025-03-12 10:58 ` Jan Kara
2025-03-12 12:26 ` Amir Goldstein
2025-03-08 18:57 ` Mickaël Salaün
2025-03-06 21:04 ` Jan Kara
2025-03-08 19:15 ` Mickaël Salaün
2025-03-12 6:20 ` Tetsuo Handa
2025-03-24 1:58 ` Tingmao Wang
2025-03-24 10:43 ` Tetsuo Handa
2026-02-15 2:41 ` Tingmao Wang
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=20250305.peiLairahj3A@digikod.net \
--to=mic@digikod.net \
--cc=amir73il@gmail.com \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=m@maowtm.org \
--cc=repnop@google.com \
--cc=tycho@tycho.pizza \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.