From: "Mickaël Salaün" <mic@digikod.net>
To: "Günther Noack" <gnoack@google.com>, "Jonathan Corbet" <corbet@lwn.net>
Cc: "Mickaël Salaün" <mic@digikod.net>,
"Christian Brauner" <brauner@kernel.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Shawn Shao" <shawnq1@163.com>,
"Shuah Khan" <skhan@linuxfoundation.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: [PATCH] landlock: Clarify namespace and capability permission boundaries
Date: Tue, 1 Dec 2026 20:38:13 +0100 [thread overview]
Message-ID: <20261201193814.760891-1-mic@digikod.net> (raw)
A report [1] interpreted opening a reference to an existing namespace as
an operation covered by LANDLOCK_PERMISSION_NAMESPACE_USE. The current
wording invites that reading, but a namespace reference identifies a
target without authorizing reassociation or capability exercise.
Distinguish namespace creation and reassociation from opening existing
namespaces. Describe capability exercise as an independent check so
readers can tell how the two permissions limit reachable kernel code.
Cc: Günther Noack <gnoack@google.com>
Cc: Shawn Shao <shawnq1@163.com>
Link: https://patch.msgid.link/179566442733.1993761.8053687674090289362@163.com [1]
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
Documentation/userspace-api/landlock.rst | 54 +++++++++++-------------
1 file changed, 24 insertions(+), 30 deletions(-)
diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst
index 7cc5fde48262..174826793040 100644
--- a/Documentation/userspace-api/landlock.rst
+++ b/Documentation/userspace-api/landlock.rst
@@ -8,7 +8,7 @@ Landlock: unprivileged access control
=====================================
:Author: Mickaël Salaün
-:Date: November 2026
+:Date: December 2026
The goal of Landlock is to enable restriction of ambient rights (e.g. global
filesystem or network access) for a set of processes. Because Landlock
@@ -525,25 +525,23 @@ rights (``handled_access_*``) or cross-domain scopes (``scoped``), per-category
permissions constrain the sandboxed process's own use of these enums; members
not allowed by a rule are denied by default.
-``LANDLOCK_PERMISSION_NAMESPACE_USE`` gates *acquisition of access* to
-namespaces: creation via :manpage:`unshare(2)` / :manpage:`clone(2)`
-/ :manpage:`clone3(2)`, entry via :manpage:`setns(2)`, and fd-reference
-acquisition via :manpage:`open_tree(2)` / :manpage:`fsmount(2)`. Namespaces
-the process is already a member of when the domain is enforced are implicitly
-allowed (the process could not continue running otherwise); rules describe
-which new namespace types the process may acquire.
+``LANDLOCK_PERMISSION_NAMESPACE_USE`` restricts which namespace types a
+process may create or reassociate with. It covers creation even when the
+caller does not join the new namespace, but does not restrict opening an
+existing namespace. Enforcing this permission does not revoke existing
+namespace membership.
+
``LANDLOCK_PERMISSION_CAPABILITY_USE`` gates the exercise of capabilities
after the domain is enforced, regardless
of how the capability was obtained (inherited credentials, ``CLONE_NEWUSER``
-grant, ``setuid``/file-cap-bearing :manpage:`execve(2)`, etc.). Configuring
-both together restricts what privileges are available *and* the namespaces in
-which they take effect, which matters because user namespace creation has no
-capability check and grants all capabilities within the new namespace: gating
-only one of the two leaves a kernel attack-surface widening path open. When a
-domain handles both permissions, an operation is allowed only if each
-independently allows it: :manpage:`unshare(2)` with ``CLONE_NEWNET`` then
-requires both a rule allowing ``CLONE_NEWNET`` and a rule allowing
-``CAP_SYS_ADMIN``.
+grant, ``setuid``/file-cap-bearing :manpage:`execve(2)`, etc.).
+
+Together, the namespace and capability permissions limit reachable kernel code
+by restricting namespace creation and reassociation separately from capability
+exercise. An operation must be allowed by every handled permission that
+applies to it. For example, when both of these permissions are handled,
+:manpage:`unshare(2)` with ``CLONE_NEWNET`` requires rules allowing both
+``CLONE_NEWNET`` and ``CAP_SYS_ADMIN``.
``LANDLOCK_PERMISSION_CAPABILITY_USE`` complements :manpage:`prctl(2)`
``PR_SET_NO_NEW_PRIVS`` but does not replace it. ``PR_SET_NO_NEW_PRIVS``
@@ -579,25 +577,21 @@ effect, so a rule compiled against future kernel headers loads without error on
older kernels. Future kernels gain new members denied by default until a rule
explicitly allows them.
-The single ``LANDLOCK_PERMISSION_NAMESPACE_USE`` bit gates every kernel path
-that grants the calling process access to a namespace of the controlled types,
-whether by becoming a member of the namespace or by holding a file descriptor
-that references it. The covered syscall paths are:
-
-* :manpage:`unshare(2)` with ``CLONE_NEW*``: the caller becomes a member of a
- newly-created namespace.
-* :manpage:`clone(2)` (or :manpage:`clone3(2)`) with ``CLONE_NEW*``: the
- child becomes a member of a newly-created namespace.
-* :manpage:`setns(2)`: the caller becomes a member of an existing namespace
- referenced by file descriptor.
+Examples of covered namespace creation and reassociation operations include:
+
+* :manpage:`unshare(2)` with ``CLONE_NEW*``: creates namespaces for the caller.
+* :manpage:`clone(2)` (or :manpage:`clone3(2)`) with ``CLONE_NEW*``: creates
+ namespaces for the child.
+* :manpage:`setns(2)`: requests reassociation with one or more existing
+ namespaces.
* :manpage:`open_tree(2)` with ``OPEN_TREE_NAMESPACE``: the caller obtains a
file descriptor referring to a newly-created mount namespace.
* :manpage:`open_tree(2)` with ``OPEN_TREE_CLONE``: the caller obtains a file
- descriptor referring to a newly-created anonymous mount namespace.
+ descriptor for a detached mount in a new anonymous mount namespace.
* :manpage:`fsmount(2)` with ``FSMOUNT_NAMESPACE``: the caller obtains a file
descriptor referring to a newly-created mount namespace.
* :manpage:`fsmount(2)` (default): the caller obtains a file descriptor
- referring to a newly-created anonymous mount namespace.
+ for a detached mount in a new anonymous mount namespace.
Anonymous mount namespaces (created by ``open_tree(OPEN_TREE_CLONE)`` and the
default :manpage:`fsmount(2)`) are intentionally covered by the bit even though
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.56.1
next reply other threads:[~2026-12-01 19:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 19:38 Mickaël Salaün [this message]
2026-12-01 19:43 ` [PATCH] landlock: Clarify namespace and capability permission boundaries sashiko-bot
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=20261201193814.760891-1-mic@digikod.net \
--to=mic@digikod.net \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=gnoack@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=shawnq1@163.com \
--cc=skhan@linuxfoundation.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