Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH] landlock: Clarify namespace and capability permission boundaries
@ 2026-12-01 19:38 Mickaël Salaün
  2026-12-01 19:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Mickaël Salaün @ 2026-12-01 19:38 UTC (permalink / raw)
  To: Günther Noack, Jonathan Corbet
  Cc: Mickaël Salaün, Christian Brauner, Randy Dunlap,
	Shawn Shao, Shuah Khan, linux-doc, linux-kernel,
	linux-security-module

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] landlock: Clarify namespace and capability permission boundaries
  2026-12-01 19:38 [PATCH] landlock: Clarify namespace and capability permission boundaries Mickaël Salaün
@ 2026-12-01 19:43 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01 19:43 UTC (permalink / raw)
  Cc: linux-security-module

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] landlock: incomplete update of namespace fd-reference wording in
  docs
--

commit b0c0c94c5196be874090a6228b828116a0227e60
Author: Mickaël Salaün <mic@digikod.net>

landlock: Clarify namespace and capability permission boundaries

This commit rewords the capability and namespace restrictions section in
Documentation/userspace-api/landlock.rst to clarify that
LANDLOCK_PERMISSION_NAMESPACE_USE covers namespace creation and
reassociation rather than opening existing namespaces, and describes
capability exercise as an independent check.

Link: https://patch.msgid.link/179566442733.1993761.8053687674090289362@163.com [1]

> diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst
> index 7cc5fde482623..1748267930408 100644
> --- a/Documentation/userspace-api/landlock.rst
> +++ b/Documentation/userspace-api/landlock.rst

[ ... ]

> @@ -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.

[Severity: Low]
Should the other occurrences of the "fd-reference acquisition" phrasing in
this document and in the UAPI header kernel-doc (which is included into
this guide) be updated to match?

In Documentation/userspace-api/landlock.rst under "Creating a new ruleset":

  For namespace access-control, we can add rules that allow using specific
  namespace types (see :manpage:`namespaces(7)` for the list of ``CLONE_NEW*``
  values): creating them via :manpage:`unshare(2)` / :manpage:`clone(2)` /
  :manpage:`clone3(2)`, joining them via :manpage:`setns(2)`, or acquiring an fd
  reference via :manpage:`open_tree(2)` / :manpage:`fsmount(2)`.

In Documentation/userspace-api/landlock.rst under "Namespace (ABI < 12)":

  Starting with the Landlock ABI version 12, it is possible to restrict namespace
  use (see :manpage:`namespaces(7)`) across creation (:manpage:`unshare(2)`,
  :manpage:`clone(2)`, :manpage:`clone3(2)`), entry (:manpage:`setns(2)`), and
  fd-reference acquisition (:manpage:`open_tree(2)`, :manpage:`fsmount(2)`) with
  the new ``LANDLOCK_PERMISSION_NAMESPACE_USE`` permission flag and
  ``LANDLOCK_RULE_NAMESPACE`` rule type.

And in include/uapi/linux/landlock.h:

   * - %LANDLOCK_PERMISSION_NAMESPACE_USE: Restrict the use of specific namespace
   *   types: creation (:manpage:`unshare(2)`, :manpage:`clone(2)`,
   *   :manpage:`clone3(2)`), joining (:manpage:`setns(2)`), and acquiring an fd
   *   reference (:manpage:`open_tree(2)`, :manpage:`fsmount(2)`).

Leaving those three passages unchanged keeps the old distinction between
creation and fd-reference acquisition in the same rendered userspace API
guide.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201193814.760891-1-mic@digikod.net?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:38 [PATCH] landlock: Clarify namespace and capability permission boundaries Mickaël Salaün
2026-12-01 19:43 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox