Skip to contentSkip to conversation

Landlock: Namespace and capability control

PATCH Superseded Mickaël Salaün 4 participants 25 messages Jul 26 – Sep 10

Subsystems (5)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Mickaël Salaün

author maintainer
#0 lore raw

v3 cover Landlock: Namespace and capability control

This series builds on Christian Brauner's namespace LSM blob RFC [1], included as patches 1 and 2 (a preparatory anonymous-mount-namespace fix and the LSM blob and hooks it enables). The FOR_EACH_NS_TYPE patch from v1 has been merged in master: commit 935a04923ad2 ("nsproxy:
Add FOR_EACH_NS_TYPE() X-macro and CLONE_NS_ALL").

Christian, could you please review patch 1? It splits the anonymous mount-namespace free-path fix you proposed out of the LSM blob patch:
free_mnt_ns() now calls ns_common_free() unconditionally, and __ns_common_free() releases the proc inum only for dynamically allocated namespaces, so the reserved anonymous-mount inum is never returned to the allocator.

Paul, could you please review patch 2 and 3? The first adds the new LSM hooks and the second adds LSM_AUDIT_DATA_NS, a new audit record type that logs namespace_type and ns_id for namespace-related LSM denials.

Tingmao, could you please review patches 7 and 8? They extend your quiet feature to the capability and namespace permissions and diverge from your earlier quiet_perm suggestion; the rationale is in the commit message. Patches 4 and 6 also rename and re-home the quiet mask your feature added (quiet_masks -> quiet_access, copied in the merge helper).

Günther and Tingmao, I dropped your Reviewed-by tags from patches 7 and 8: those tags covered the v1 patches, which did not carry the per-member quiet support folded in here. A fresh review of the quiet additions is welcome.

Motivation
==========

Namespaces are a fundamental building block for containers and application sandboxes, but user namespace creation significantly widens the kernel attack surface. CVE-2026-43284 / CVE-2026-43500 ("Dirty Frag"), CVE-2026-46300 ("Fragnesia"), CVE-2023-32233 and CVE-2022-25636 (netfilter), CVE-2022-0492 (cgroup v1 release_agent), and CVE-2022-0185 (filesystem mount parsing) all demonstrate vulnerabilities exploitable only through capabilities gained via user namespaces. Advisories for the 2026 CVEs recommend disabling unprivileged user-namespace creation as a temporary mitigation. Some distributions (e.g. Debian and Arch's linux-hardened kernel via the kernel.unprivileged_userns_clone sysctl) block user namespace creation entirely, but this removes a useful isolation primitive. Fine-grained control allows trusted programs to use namespaces while preventing unnecessary exposure for programs that do not need them.

Existing mechanisms (user.max_*_namespaces sysctls, userns_create LSM hook, PR_SET_NO_NEW_PRIVS, and capset) each address part of this threat but none provides per-process, fine-grained control over both namespace types and capabilities. Container runtimes resort to seccomp-based clone/unshare filtering, but seccomp cannot dereference clone3's flag structure, forcing runtimes to block clone3 entirely.

Landlock's composable layer model enables several patterns: a user session manager can restrict namespace types and capabilities broadly while allowing trusted programs to create the namespaces they need, and each deeper layer can further restrict the allowed set. Container runtimes can similarly deny namespace creation inside managed containers.

Permissions
===========

Two permissions are needed because the controlled operations sit on different LSM hook sites (namespace_init/namespace_install vs capable) and address independent threat axes: capability acquisition via user-namespace creation, and capability exercise after acquisition. Collapsing them into a single permission would conflate hook semantics. LANDLOCK_PERM_NAMESPACE_USE intentionally covers every kernel path that grants access to a namespace (creation, entry, and fd reference) because each path widens the kernel attack surface for that namespace type; splitting it into finer create/enter/fd-reference permissions would add UAPI surface without isolating a distinct attack axis.

This series adds two new permission categories to Landlock:

- LANDLOCK_PERM_NAMESPACE_USE: Restricts which namespace types a sandboxed process can use: creation (unshare/clone), entry (setns), and fd reference (open_tree, fsmount). User namespace creation has no capability check in the kernel, so this is the only enforcement mechanism for that path.

- LANDLOCK_PERM_CAPABILITY_USE: Restricts which Linux capabilities a sandboxed process can use, regardless of how they were obtained (including through user namespace creation).

Both use new handled_perm and LANDLOCK_RULE_* constants following the existing allow-list model. The UAPI uses raw CAP_* and CLONE_NEW* values directly; unknown values are silently accepted for forward compatibility (the allow-list denies them by default). This series is rebased onto v7.2-rc4, which already ships Landlock ABI 10 (UDP support and Tingmao Wang's quiet feature) without the new permissions, so the series bumps the Landlock ABI to 11.

Each rule can also quiet the audit records of specific denied members, per member and independently of the allowed set, via the quiet_capabilities and quiet_namespace_types rule fields. This extends Tingmao Wang's quiet feature (LANDLOCK_ADD_RULE_QUIET for filesystem and network objects) to the two new permissions, but uses a per-rule bitmask instead of the shared flag because capabilities and namespace types are a bounded, kernel-defined member set rather than unbounded rb-tree objects. This diverges from the earlier coarse quiet_perm suggestion; the rationale is in the commit message.

The handled_perm infrastructure is designed to be reusable by future permission categories. The last patch documents the design rationale for the permission model and the criteria for choosing between handled_access_*, handled_perm, and scoped. A patch series to add socket creation control is under review [2]; it could benefit from the same permission model to achieve complete deny-by-default coverage of socket creation.

Enforcement
===========

All of these example vulnerabilities follow the same pattern: an unprivileged user creates a user namespace to obtain capabilities, then creates a second namespace to exercise them against vulnerable code. LANDLOCK_PERM_NAMESPACE_USE prevents this by denying the user namespace (eliminating the capability grant) or the specific namespace type needed to exercise it. LANDLOCK_PERM_CAPABILITY_USE independently prevents it by denying the required capability.

Namespace restriction is enforced at two hook sites: namespace_init (unshare/clone) and namespace_install (setns). Together, these ensure a process denied a namespace type cannot circumvent the restriction by entering a pre-existing namespace via setns() on an inherited or passed file descriptor. When a domain handles both permissions, both must independently allow the operation (e.g., unshare(CLONE_NEWNET) requires both CAP_SYS_ADMIN to be allowed and CLONE_NEWNET to be allowed).

Design evolution
================

The first approach added CAP_OPT flags to security_capable() to distinguish namespace creation contexts. This was too invasive and would have required capability splitting (a dedicated CAP_NAMESPACE) which does not help because the CAP_SYS_ADMIN fallback for backward compatibility undermines the distinction.

The second stored the namespace creator's domain in the LSM blob and used domain ancestry comparison in hook_capable() to bypass capability checks for namespace management operations. A SCOPE_NAMESPACE flag restricted setns() by the namespace creator's domain, like SCOPE_SIGNAL. Both were dropped: scopes should only concern Landlock properties (domain relationships), not kernel namespace state; and the cross-namespace heuristic (ns != cred->user_ns) did not accurately identify namespace management operations.

The final design drops all of this. The key insight is that capabilities gained through user namespace creation are only exercisable against namespaces of a specific type: creating a network namespace is what makes CAP_NET_ADMIN exercisable. LANDLOCK_PERM_NAMESPACE_USE controls where capabilities are exercisable by restricting which namespace types can be acquired. LANDLOCK_PERM_CAPABILITY_USE controls which capabilities are available, as a pure per-layer bitmask check with no namespace awareness. The two are independently enforced at their own hook sites, with no interaction in hook_capable(). No scope flag is added in this series.

Limitations and future work
===========================

When Landlock filesystem restrictions are in use, mount namespace creation has an inherent limitation: all mount topology changes are denied when any filesystem right is handled. A dedicated mount access control type is left for future work [3].

Per Paul Moore's review, no security_namespace_switch() post-hook is added in this series: such a hook would only serve LSMs that maintain per-task state derived from the active namespace set (SELinux-style state tracking), and no current LSM (including this series) needs that. Landlock enforces at namespace_install() and namespace_init(), before the task-to-nsproxy switch. The hook is left for a separate LSM infrastructure proposal once a concrete user emerges.

https://lore.kernel.org/r/[email protected] [1]
https://lore.kernel.org/r/[email protected] [2]
https://github.com/landlock-lsm/linux/issues/14 [3]

Changes since v2:
https://patch.msgid.link/[email protected]
- Rebased onto v7.2-rc4, which now ships ABI 10 (UDP support and the
merged quiet feature) and the series' dependencies; the new
permissions therefore bump the Landlock ABI to 11, and handled_perm
is placed after the released quiet_access_*/quiet_scoped fields.
- Added per-member quiet support for the capability and namespace permissions to their enforcement patches (patches 7 and 8): each rule carries independent allowed and quiet member bitmasks
(quiet_capabilities / quiet_namespace_types). The capability and namespace rule attributes are renamed accordingly (perm plus allowed_* plus quiet_*) and grow to 24 bytes.
- Extended the namespace and capability selftests (patches 9 and 10)
for the rebase and the per-member quiet feature: renamed the rule attributes (perm plus allowed_*/quiet_*), bumped the ABI expectation
to 11, and added per-member quiet audit tests (quiet-only denial, per-member quiet, allow-and-quiet, quiet-inert-when-also-allowed, youngest-layer-wins, parent-only-denying). Added further coverage: a positive both-caps mount setns leg and a both-perms inverse test, an install-hook mirror
of the unknown-bit no-runtime-effect test, quieted-setns and unknown-quiet-bit audit cases, positive controls proving quiet and CAP_OPT_NOAUDIT suppression are per-member (not global), an
assertion that a quieted capability is still denied, and a combined-unshare pair proving CLONE_NEWUSER combined with another
type in one unshare(2) still needs an allowed CAP_SYS_ADMIN.
- Dropped the Reviewed-by tags from Günther Noack and Tingmao Wang on patches 7 and 8: those tags covered the v1 patches, which did not
carry the per-member quiet support folded in here; a fresh review of
the quiet additions is welcome.
- Removed the RCU note from the security_namespace_free() kdoc
(patch 2, suggested by Paul Moore).
- Documentation: fixed the CAP_BPF forward-compatibility example (rules allow-list), dropped the "category" jargon, added capabilities(7) / namespaces(7) references, and clarified the namespace "use" semantics (suggested by Günther Noack); also documented the combined deny-by-default, that creating a non-user namespace needs
CAP_SYS_ADMIN even when CLONE_NEWUSER is combined in one unshare(),
and the per-member audit quieting for the two permissions.
- Sandboxer (patch 11): added LL_CAP_QUIET and LL_NS_QUIET to quiet capability and namespace-type denials, merged with the allowed bits
into one rule per category.
- New patch 1 ("ns: Free anonymous mount namespaces via
ns_common_free()"): the anonymous-mount free-path change is split out
of the LSM hooks patch, with a commit message explaining the
inum-range check (suggested by Christian Brauner and Paul Moore).
- New patches 4 and 6 ("landlock: Rename quiet_masks to quiet_access"
and "landlock: Copy the quiet mask in the ruleset merge helper"):
rename the base's quiet-mask field for symmetry with the new
quiet_perm, and copy both quiet masks inside merge_ruleset() under the ruleset lock so a new domain captures a single atomic snapshot of the ruleset (allowed plus quiet); no user-visible change.

Changes since RFC v1:
https://patch.msgid.link/[email protected]
- Move security_namespace_install() before ns->ops->install() in validate_ns() and fix proc_free_inum() error path when inum is caller-provided (patch 1, suggested by Christian Brauner).
- Replace inum with ns_id in namespace audit records: ns_id is the stable 64-bit namespace identifier, never recycled (patches 2, 4, 6, 9; suggested by Christian Brauner).
- Fix user_denied.setns test to expect EPERM from Landlock instead of EINVAL from userns_install() after hook reordering (patch 6).
- Add __packed __aligned(sizeof(u64)) to struct perm_masks to fix m68k build failure where GCC packs bitfields at byte granularity, and add WARN_ON_ONCE guards for invalid perm_bit or request_value in landlock_perm_is_denied() (patch 4, suggested by Tingmao Wang).
- Fix anonymous mount namespace blob leak: make __ns_common_free() always call security_namespace_free() and conditionally call proc_free_inum() via MNT_NS_INO_SPECIAL_MAX, so free_mnt_ns() calls ns_common_free() unconditionally (patch 1, suggested by Christian Brauner, also reported by Daniel Durning).
- Unify hook_namespace_init() and hook_namespace_install() into a shared check_ns_type() helper and drop the redundant entry-level WARN_ON_ONCE (the downstream warns in landlock_ns_type_to_bit() and landlock_perm_is_denied() suffice; patch 4).
- Remove duplicate ns_audit.unshare_denied test (identical to ns_audit.create_denied; patch 6).
- Add sandboxed_allowed variant to setns_cross_process to cover allowed cross-process setns (patch 6).
- Rebase onto landlock-next (includes the resolve_unix and UDP series). No ABI bump in v2: the series is planned to merge in the same kernel as the UDP series, which already bumped to 10.
- Drop three patches now upstream on landlock-next: the two audit-test fixes (filter dealloc records, default audit socket timeout) sent independently with Cc: stable, plus the allowed_access best-effort filtering demonstration patch.
- Rename LANDLOCK_PERM_NAMESPACE_ENTER to LANDLOCK_PERM_NAMESPACE_USE (and audit blocker perm.namespace_enter to perm.namespace_use) for semantic accuracy: the verb _ENTER fits setns/unshare/clone but misleads for open_tree and fsmount where the caller holds an fd reference without entering. _USE covers both cases and mirrors LANDLOCK_PERM_CAPABILITY_USE.
- Add a Design philosophy section to Documentation/security/landlock.rst stating Landlock's principle:
restrict access to data, other tasks, and kernel resources.
- Rewrite Documentation/security/landlock.rst Ruleset restriction models with the per-object (handled_access_*) versus per-category (handled_perm) framing in place of the previous chokepoints/ gateways wording.
- Enumerate the seven syscall paths covered by LANDLOCK_PERM_NAMESPACE_USE in Documentation/userspace-api/landlock.rst (membership via unshare/clone/setns; fd reference via open_tree and fsmount).
- Document the deterministic-semantics rationale for accepting unknown category member values in rule bodies (per-category permissions section of Documentation/security/landlock.rst); range-checking against CAP_LAST_CAP is intentionally avoided.
- Address Günther Noack's nits in the layer_config wrapper patch:
clarify that _LANDLOCK_ACCESS_FS_INITIALLY_DENIED is ORed with the .handled field of all ruleset->layers[] entries; rename landlock_upgrade_handled_access_masks() to landlock_upgrade_handled_layer_config() to match the parameter type; rewrap the @layers kdoc to greedy fill (eliminating v1's manual short "rulesets in a" line).
- Rename struct layer_rights to struct layer_config: "config" is the more general term for per-layer state.
- Rename internal struct perm_rules to struct perm_masks to parallel the sibling access_masks in struct layer_config.
- Collect Reviewed-by tags from Günther Noack on patches 2, 3, 4, and 5 from the v1 thread. Patch 1 and patch 8 changed substantially since v1 (the mount-namespace blob leak fix and validate_ns() reordering for patch 1; the libcap migration for patch 8), so the Reviewed-by tags from reviewers who had not requested those changes are not carried forward; the affected reviewers are kept as Cc:.
- Rename security_namespace_alloc() to security_namespace_init() (and the LSM hook namespace_alloc -> namespace_init, plus Landlock's hook_namespace_alloc() -> hook_namespace_init()) to match the caller-name convention and reflect that the hook initialises LSM state attached to a constructed ns_common rather than allocating it (patch 1, suggested by Paul Moore).
- Refine the security_namespace_free() kdoc to clarify that RCU-safe blob freeing is required only if an LSM exposes data within the blob to concurrent RCU readers, and document that the blob memory itself is released with kfree() after the namespace_free hooks return (patch 1, suggested by Paul Moore).
- Use cap_from_name(3) from libcap in the sandboxer; LL_CAP now takes colon-delimited capability names (e.g. "cap_sys_chroot") or numbers (libcap's numeric fallback), and the Makefile links libcap (patch 8, suggested by Günther Noack).
- Rename the sandboxer env var LL_CAPS to LL_CAP for consistency with the singular form used by all other LL_* sandboxer env vars (LL_NS, LL_FS_RO, LL_FS_RW, LL_TCP_BIND, LL_TCP_CONNECT, LL_SCOPED, LL_FORCE_LOG; patch 8).
- Add a bridging sentence in the per-category permissions section of Documentation/security/landlock.rst contrasting per-category permissions with per-object access rights (patch 9, suggested by Günther Noack).
- Disambiguate the orthogonality invariant in Documentation/security/landlock.rst ("all new scoped features" -> "all Landlock access controls") to avoid clash with the UAPI scoped field (patch 9, suggested by Justin Suess).
- Add an introductory paragraph in Documentation/userspace-api/landlock.rst contrasting LANDLOCK_PERM_CAPABILITY_USE with PR_SET_NO_NEW_PRIVS (patch 9, suggested by Justin Suess).
- Add an explicit static_assert that LANDLOCK_NUM_PERM_CAP + LANDLOCK_NUM_PERM_NS fits in u64, complementing the implicit sizeof guard on struct perm_masks (patch 5).
- Document that setns_cross_process exercises only CLONE_NEWUTS (patch 6).
- Add add_rule_unknown_no_runtime_effect tests asserting that a rule listing only unknown bits has no runtime effect (patches 6, 7).
- Extend the cap/ns stacking tests with the parent-denies/child- allows variant to complete per-layer walker direction coverage (patches 6, 7).

Christian Brauner (2):
ns: Free anonymous mount namespaces via ns_common_free()
security: add LSM blob and hooks for namespaces

Mickaël Salaün (10):
security: Add LSM_AUDIT_DATA_NS for namespace audit records
landlock: Rename quiet_masks to quiet_access
landlock: Wrap per-layer access masks in struct layer_config
landlock: Copy the quiet mask in the ruleset merge helper
landlock: Enforce namespace use restrictions
landlock: Enforce capability restrictions selftests/landlock: Add namespace restriction tests selftests/landlock: Add capability restriction tests samples/landlock: Add capability and namespace restriction support
landlock: Add documentation for capability and namespace restrictions

 Documentation/admin-guide/LSM/landlock.rst   |   19 +-
 Documentation/security/landlock.rst          |  173 +-
 Documentation/userspace-api/landlock.rst     |  236 +-
 fs/namespace.c                               |    3 +-
 include/linux/lsm_audit.h                    |    5 +
 include/linux/lsm_hook_defs.h                |    3 +
 include/linux/lsm_hooks.h                    |    1 +
 include/linux/ns/ns_common_types.h           |    3 +
 include/linux/security.h                     |   20 +
 include/uapi/linux/landlock.h                |  127 +-
 include/uapi/linux/nsfs.h                    |    1 +
 kernel/nscommon.c                            |   17 +-
 kernel/nsproxy.c                             |    6 +
 samples/landlock/Makefile                    |    1 +
 samples/landlock/sandboxer.c                 |  200 +-
 security/landlock/Makefile                   |    4 +-
 security/landlock/access.h                   |   77 +-
 security/landlock/audit.c                    |   31 +-
 security/landlock/audit.h                    |    2 +
 security/landlock/cap.c                      |  137 +
 security/landlock/cap.h                      |   50 +
 security/landlock/cred.h                     |   55 +-
 security/landlock/domain.h                   |   10 +-
 security/landlock/limits.h                   |    9 +
 security/landlock/ns.c                       |  156 ++
 security/landlock/ns.h                       |   74 +
 security/landlock/ruleset.c                  |   43 +-
 security/landlock/ruleset.h                  |   73 +-
 security/landlock/setup.c                    |    4 +
 security/landlock/syscalls.c                 |  178 +-
 security/lsm_audit.c                         |    4 +
 security/lsm_init.c                          |    2 +
 security/security.c                          |   72 +
 tools/testing/selftests/landlock/base_test.c |   20 +-
 tools/testing/selftests/landlock/cap_test.c  |  889 +++++++
 tools/testing/selftests/landlock/common.h    |   23 +
 tools/testing/selftests/landlock/config      |    5 +
 tools/testing/selftests/landlock/fs_test.c   |   13 +-
 tools/testing/selftests/landlock/ns_test.c   | 2380 ++++++++++++++++++
 tools/testing/selftests/landlock/wrappers.h  |   29 +
 40 files changed, 5054 insertions(+), 101 deletions(-)
 create mode 100644 security/landlock/cap.c
 create mode 100644 security/landlock/cap.h
 create mode 100644 security/landlock/ns.c
 create mode 100644 security/landlock/ns.h
 create mode 100644 tools/testing/selftests/landlock/cap_test.c
 create mode 100644 tools/testing/selftests/landlock/ns_test.c
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH v3 1/12 ns: Free anonymous mount namespaces via ns_common_free()

From: Christian Brauner <[email protected]>

free_mnt_ns() skipped ns_common_free() for anonymous mount namespaces (the "if (!is_anon_ns(ns))" guard) because they carry the reserved inum MNT_NS_ANON_INO, which proc_free_inum() must never release.

A following change needs ns_common_free() to run for every namespace, to release per-namespace state attached during __ns_common_init(). Move the reserved-inum decision into __ns_common_free() and let free_mnt_ns() call ns_common_free() unconditionally.

__ns_common_free() is shared by all namespace types, so it gates proc_free_inum() on ns->inum > MNT_NS_INO_SPECIAL_MAX (a new alias for MNT_NS_ANON_INO) rather than the mount-specific is_anon_ns(). The reserved inums (MNT_NS_ANON_INO and the *_NS_INIT_INO values just above it) belong to namespaces that are never freed, except the anonymous mount namespace; dynamically allocated inums are >= PROC_DYNAMIC_FIRST. So the comparison frees every dynamic inum and skips exactly the anonymous mount namespace, matching the previous guard.

---

Changes since v2:
- New patch, split from "security: add LSM blob and hooks for namespaces" (suggested by Paul Moore).

---
 fs/namespace.c            | 3 +--
 include/uapi/linux/nsfs.h | 1 +
 kernel/nscommon.c         | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
fs/namespace.c +1 -2
index 3d5cd5bf3b05..0602f133f3a0 100644
@@ -4186,8 +4186,7 @@ static void dec_mnt_namespaces(struct ucounts *ucounts)
 
 static void free_mnt_ns(struct mnt_namespace *ns)
 {
-	if (!is_anon_ns(ns))
-		ns_common_free(ns);
+	ns_common_free(ns);
 	dec_mnt_namespaces(ns->ucounts);
 	mnt_ns_tree_remove(ns);
 }
include/uapi/linux/nsfs.h +1 -0
index a25e38d1c874..ea0f0267d90f 100644
@@ -55,6 +55,7 @@ enum init_ns_ino {
 	MNT_NS_INIT_INO		= 0xEFFFFFF8U,
 #ifdef __KERNEL__
 	MNT_NS_ANON_INO		= 0xEFFFFFF7U,
+	MNT_NS_INO_SPECIAL_MAX	= MNT_NS_ANON_INO,
 #endif
 };
 
kernel/nscommon.c +2 -1
index 3166c1fd844a..e6f623e1bc37 100644
@@ -91,7 +91,8 @@ int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_ope
 
 void __ns_common_free(struct ns_common *ns)
 {
-	proc_free_inum(ns->inum);
+	if (ns->inum > MNT_NS_INO_SPECIAL_MAX)
+		proc_free_inum(ns->inum);
 }
 
 struct ns_common *__must_check ns_owner(struct ns_common *ns)
Signature · 1 line
2.54.0
maintainer Reviewed-by on v3 1/12
#2 lore raw

Re: [PATCH v3 01/12] ns: Free anonymous mount namespaces via ns_common_free()

Hi Mickaël,

Quoted 18 lines

free_mnt_ns() skipped ns_common_free() for anonymous mount namespaces (the "if (!is_anon_ns(ns))" guard) because they carry the reserved inum MNT_NS_ANON_INO, which proc_free_inum() must never release.

A following change needs ns_common_free() to run for every namespace, to release per-namespace state attached during __ns_common_init(). Move the reserved-inum decision into __ns_common_free() and let free_mnt_ns() call ns_common_free() unconditionally.

__ns_common_free() is shared by all namespace types, so it gates proc_free_inum() on ns->inum > MNT_NS_INO_SPECIAL_MAX (a new alias for MNT_NS_ANON_INO) rather than the mount-specific is_anon_ns(). The reserved inums (MNT_NS_ANON_INO and the *_NS_INIT_INO values just above it) belong to namespaces that are never freed, except the anonymous mount namespace; dynamically allocated inums are >= PROC_DYNAMIC_FIRST. So the comparison frees every dynamic inum and skips exactly the anonymous mount namespace, matching the previous guard.

Quoted 4 lines

Seems good,

author maintainer
#3 lore raw

PATCH v3 2/12 security: add LSM blob and hooks for namespaces

In reply to Mickaël Salaün

From: Christian Brauner <[email protected]>

All namespace types now share the same ns_common infrastructure. Extend this to include a security blob so LSMs can start managing namespaces uniformly without having to add one-off hooks or security fields to every individual namespace type.

Add a ns_security pointer to ns_common and the corresponding lbs_ns blob size to lsm_blob_sizes. Allocation and freeing hooks are called from the common __ns_common_init() and __ns_common_free() paths so every namespace type gets covered in one go. All information about the namespace type and the appropriate casting helpers to get at the containing namespace are available via ns_common making it straightforward for LSMs to differentiate when they need to.

A namespace_install hook is called from validate_ns() during setns(2) giving LSMs a chance to enforce policy on namespace transitions. The LSM check runs before ns->ops->install() so the security module can deny the operation before any type-specific installation effects.

Individual namespace types can still have their own specialized security hooks when needed. This is just the common baseline that makes it easy to track and manage namespaces from the security side without requiring every namespace type to reinvent the wheel.

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Split the anonymous mount-namespace free-path change into a preceding preparatory commit: dropping the is_anon_ns() guard in free_mnt_ns(), adding MNT_NS_INO_SPECIAL_MAX, and guarding proc_free_inum() in __ns_common_free() now live there, so that commit can be reviewed on its own; only the security_namespace_free() call in __ns_common_free() remains here (suggested by Christian Brauner and Paul Moore).
- Remove the RCU note from the security_namespace_free() kdoc; it read as generic RCU and object-lifetime guidance (suggested by Paul Moore).

Changes since v1:
https://patch.msgid.link/[email protected]
- Move security_namespace_install() before ns->ops->install() in validate_ns() (suggested by Christian Brauner).
- Only call proc_free_inum() on security_namespace_alloc() failure when inum was allocated by this function (suggested by Christian Brauner).
- Fix anonymous mount namespace blob leak: move security_namespace_free() into __ns_common_free() and make proc_free_inum() conditional on dynamically allocated inums via MNT_NS_INO_SPECIAL_MAX, so free_mnt_ns() can call ns_common_free() unconditionally (suggested by Christian Brauner). Also reported by Daniel Durning while working on SELinux support for these hooks:
https://lore.kernel.org/r/[email protected]
- Rename security_namespace_alloc() to security_namespace_init() to match the caller-name convention and reflect that the hook initialises LSM state attached to a constructed ns_common rather than allocating the ns_common itself (suggested by Paul Moore).
- Refine the security_namespace_free() kdoc to clarify that RCU-safe blob freeing is required only if an LSM exposes data within the blob to concurrent RCU readers, and document that the blob memory itself is released with kfree() after the namespace_free hooks return (suggested by Paul Moore).
- Günther Noack's v1 Reviewed-by is not carried forward to v2:
the validate_ns() reordering and the anonymous-mount-namespace blob-leak fix are semantic changes that were not part of his review. Cc'd instead.

---
 include/linux/lsm_hook_defs.h      |  3 ++
 include/linux/lsm_hooks.h          |  1 +
 include/linux/ns/ns_common_types.h |  3 ++
 include/linux/security.h           | 20 +++++++++
 kernel/nscommon.c                  | 14 ++++++
 kernel/nsproxy.c                   |  6 +++
 security/lsm_init.c                |  2 +
 security/security.c                | 72 ++++++++++++++++++++++++++++++
 8 files changed, 121 insertions(+)
include/linux/lsm_hook_defs.h +3 -0
index 65c9609ec207..0da6c7e8f659 100644
@@ -265,6 +265,9 @@ LSM_HOOK(int, -ENOSYS, task_prctl, int option, unsigned long arg2,
 LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p,
 	 struct inode *inode)
 LSM_HOOK(int, 0, userns_create, const struct cred *cred)
+LSM_HOOK(int, 0, namespace_init, struct ns_common *ns)
+LSM_HOOK(void, LSM_RET_VOID, namespace_free, struct ns_common *ns)
+LSM_HOOK(int, 0, namespace_install, const struct nsset *nsset, struct ns_common *ns)
 LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag)
 LSM_HOOK(void, LSM_RET_VOID, ipc_getlsmprop, struct kern_ipc_perm *ipcp,
 	 struct lsm_prop *prop)
include/linux/lsm_hooks.h +1 -0
index b4f8cad53ddb..5cff13069529 100644
@@ -112,6 +112,7 @@ struct lsm_blob_sizes {
 	unsigned int lbs_ipc;
 	unsigned int lbs_key;
 	unsigned int lbs_msg_msg;
+	unsigned int lbs_ns;
 	unsigned int lbs_perf_event;
 	unsigned int lbs_task;
 	unsigned int lbs_xattr_count; /* num xattr slots in new_xattrs array */
include/linux/ns/ns_common_types.h +3 -0
index ea45c54e4435..5cfe0ce3c881 100644
@@ -116,6 +116,9 @@ struct ns_common {
 	struct dentry *stashed;
 	const struct proc_ns_operations *ops;
 	unsigned int inum;
+#ifdef CONFIG_SECURITY
+	void *ns_security;
+#endif
 	union {
 		struct ns_tree;
 		struct rcu_head ns_rcu;
include/linux/security.h +20 -0
index 153e9043058f..bf002ed14ac8 100644
@@ -67,6 +67,7 @@ enum fs_value_type;
 struct watch;
 struct watch_notification;
 struct lsm_ctx;
+struct nsset;
 
 /* Default (no) options for the capable function */
 #define CAP_OPT_NONE 0x0
@@ -80,6 +81,7 @@ struct lsm_ctx;
 
 struct ctl_table;
 struct audit_krule;
+struct ns_common;
 struct user_namespace;
 struct timezone;
 
@@ -540,6 +542,9 @@ int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 			unsigned long arg4, unsigned long arg5);
 void security_task_to_inode(struct task_struct *p, struct inode *inode);
 int security_create_user_ns(const struct cred *cred);
+int security_namespace_init(struct ns_common *ns);
+void security_namespace_free(struct ns_common *ns);
+int security_namespace_install(const struct nsset *nsset, struct ns_common *ns);
 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
 void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp, struct lsm_prop *prop);
 int security_msg_msg_alloc(struct msg_msg *msg);
@@ -1431,6 +1436,21 @@ static inline int security_create_user_ns(const struct cred *cred)
 	return 0;
 }
 
+static inline int security_namespace_init(struct ns_common *ns)
+{
+	return 0;
+}
+
+static inline void security_namespace_free(struct ns_common *ns)
+{
+}
+
+static inline int security_namespace_install(const struct nsset *nsset,
+					     struct ns_common *ns)
+{
+	return 0;
+}
+
 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
 					  short flag)
 {
kernel/nscommon.c +14 -0
index e6f623e1bc37..e72426bba29a 100644
@@ -4,6 +4,7 @@
 #include <linux/ns_common.h>
 #include <linux/nstree.h>
 #include <linux/proc_ns.h>
+#include <linux/security.h>
 #include <linux/user_namespace.h>
 #include <linux/vfsdebug.h>
 
@@ -59,6 +60,9 @@ int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_ope
 
 	refcount_set(&ns->__ns_ref, 1);
 	ns->stashed = NULL;
+#ifdef CONFIG_SECURITY
+	ns->ns_security = NULL;
+#endif
 	ns->ops = ops;
 	ns->ns_id = 0;
 	ns->ns_type = ns_type;
@@ -77,6 +81,14 @@ int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_ope
 		ret = proc_alloc_inum(&ns->inum);
 	if (ret)
 		return ret;
+
+	ret = security_namespace_init(ns);
+	if (ret) {
+		if (!inum)
+			proc_free_inum(ns->inum);
+		return ret;
+	}
+
 	/*
 	 * Tree ref starts at 0. It's incremented when namespace enters
 	 * active use (installed in nsproxy) and decremented when all
@@ -91,6 +103,8 @@ int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_ope
 
 void __ns_common_free(struct ns_common *ns)
 {
+	security_namespace_free(ns);
+
 	if (ns->inum > MNT_NS_INO_SPECIAL_MAX)
 		proc_free_inum(ns->inum);
 }
kernel/nsproxy.c +6 -0
index d9d3d5973bf5..0f1b208d8eef 100644
@@ -385,6 +385,12 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset)
 
 static inline int validate_ns(struct nsset *nsset, struct ns_common *ns)
 {
+	int ret;
+
+	ret = security_namespace_install(nsset, ns);
+	if (ret)
+		return ret;
+
 	return ns->ops->install(nsset, ns);
 }
 
security/lsm_init.c +2 -0
index 7c0fd17f1601..dcd2a228c4f6 100644
@@ -303,6 +303,7 @@ static void __init lsm_prepare(struct lsm_info *lsm)
 	lsm_blob_size_update(&blobs->lbs_ipc, &blob_sizes.lbs_ipc);
 	lsm_blob_size_update(&blobs->lbs_key, &blob_sizes.lbs_key);
 	lsm_blob_size_update(&blobs->lbs_msg_msg, &blob_sizes.lbs_msg_msg);
+	lsm_blob_size_update(&blobs->lbs_ns, &blob_sizes.lbs_ns);
 	lsm_blob_size_update(&blobs->lbs_perf_event,
 			     &blob_sizes.lbs_perf_event);
 	lsm_blob_size_update(&blobs->lbs_sock, &blob_sizes.lbs_sock);
@@ -450,6 +451,7 @@ int __init security_init(void)
 		lsm_pr("blob(ipc) size %d\n", blob_sizes.lbs_ipc);
 		lsm_pr("blob(key) size %d\n", blob_sizes.lbs_key);
 		lsm_pr("blob(msg_msg)_size %d\n", blob_sizes.lbs_msg_msg);
+		lsm_pr("blob(ns) size %d\n", blob_sizes.lbs_ns);
 		lsm_pr("blob(sock) size %d\n", blob_sizes.lbs_sock);
 		lsm_pr("blob(superblock) size %d\n", blob_sizes.lbs_superblock);
 		lsm_pr("blob(perf_event) size %d\n", blob_sizes.lbs_perf_event);
security/security.c +72 -0

90 lines not on this page · raw message

Signature · 1 line
2.54.0
author maintainer
#4 lore raw

PATCH v3 3/12 security: Add LSM_AUDIT_DATA_NS for namespace audit records

In reply to Mickaël Salaün

Add a new LSM audit data type LSM_AUDIT_DATA_NS that logs namespace information in audit records. Two fields are provided:

- ns_type: the CLONE_NEW* flag identifying the namespace type, logged in hexadecimal.

- ns_id: the unique 64-bit namespace identifier, retrievable from userspace via NS_GET_ID or listns(2). Unlike the proc inode number (inum), ns_id is never recycled. For namespace creation denials, ns_id is 0 because the namespace does not exist yet.

A new audit data type is needed because no existing LSM_AUDIT_DATA_* type carries namespace information. The closest alternatives (e.g. LSM_AUDIT_DATA_TASK or LSM_AUDIT_DATA_NONE with custom strings) would either lose the namespace type or require ad-hoc formatting that bypasses the structured audit data union.

---

Changes since v1:
https://patch.msgid.link/[email protected]
- Replace inum with ns_id in the audit record: ns_id is the stable 64-bit namespace identifier (never recycled), accessible to userspace via NS_GET_ID and listns(2) (suggested by Christian Brauner).
- Add Reviewed-by: Christian Brauner.
- Add Reviewed-by: Günther Noack.

---
 include/linux/lsm_audit.h | 5 +++++
 security/lsm_audit.c      | 4 ++++
 2 files changed, 9 insertions(+)
include/linux/lsm_audit.h +5 -0
index 584db296e43b..526a8e7471c8 100644
@@ -78,6 +78,7 @@ struct common_audit_data {
 #define LSM_AUDIT_DATA_NOTIFICATION 16
 #define LSM_AUDIT_DATA_ANONINODE	17
 #define LSM_AUDIT_DATA_NLMSGTYPE	18
+#define LSM_AUDIT_DATA_NS		19
 	union 	{
 		struct path path;
 		struct dentry *dentry;
@@ -100,6 +101,10 @@ struct common_audit_data {
 		int reason;
 		const char *anonclass;
 		u16 nlmsg_type;
+		struct {
+			u32 ns_type;
+			u64 ns_id;
+		} ns;
 	} u;
 	/* this union contains LSM specific data */
 	union {
security/lsm_audit.c +4 -0
index 737f5a263a8f..404ccbbbf94c 100644
@@ -403,6 +403,10 @@ void audit_log_lsm_data(struct audit_buffer *ab,
 	case LSM_AUDIT_DATA_NLMSGTYPE:
 		audit_log_format(ab, " nl-msgtype=%hu", a->u.nlmsg_type);
 		break;
+	case LSM_AUDIT_DATA_NS:
+		audit_log_format(ab, " namespace_type=0x%x namespace_id=%llu",
+				 a->u.ns.ns_type, a->u.ns.ns_id);
+		break;
 	} /* switch (a->type) */
 }
 
Signature · 1 line
2.54.0
maintainer
#5 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 11 lines · On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

Add a new LSM audit data type LSM_AUDIT_DATA_NS that logs namespace information in audit records. Two fields are provided:

- ns_type: the CLONE_NEW* flag identifying the namespace type, logged in hexadecimal.

- ns_id: the unique 64-bit namespace identifier, retrievable from userspace via NS_GET_ID or listns(2). Unlike the proc inode number (inum), ns_id is never recycled. For namespace creation denials, ns_id is 0 because the namespace does not exist yet.

Based on the code in this patch, "ns_type" should be "namespace_type" and a similar change needs to be done for "ns_id". Regardless, the first three patches look fine to me (I can fixup the above during a merge).

As mentioned previously, I want to merge at least the first three patches via the LSM tree since we have multiple LSMs which depend on these new hooks. I'm happy to also merge the remaining Landlock patches in this patchset via the LSM tree, or you can manage those separately; let me know how you would like to proceed with that.

Since we are at -rc7, this is obviously something for after the upcoming merge window so I'm going to merge the first three patches into the lsm/dev-staging branch now with the understanding that they will move over to the lsm/dev branch after the upcoming merge window is finished. If you want me to merge the Landlock patches too, just let me know.

Quoted 20 lines

A new audit data type is needed because no existing LSM_AUDIT_DATA_* type carries namespace information. The closest alternatives (e.g. LSM_AUDIT_DATA_TASK or LSM_AUDIT_DATA_NONE with custom strings) would either lose the namespace type or require ad-hoc formatting that bypasses the structured audit data union.

---
Changes since v1:
https://patch.msgid.link/[email protected]
- Replace inum with ns_id in the audit record: ns_id is the stable 64-bit namespace identifier (never recycled), accessible to userspace via NS_GET_ID and listns(2) (suggested by Christian Brauner).
- Add Reviewed-by: Christian Brauner.
- Add Reviewed-by: Günther Noack.

Quoted 4 lines
---
 include/linux/lsm_audit.h | 5 +++++
 security/lsm_audit.c      | 4 ++++
 2 files changed, 9 insertions(+)

--
paul-moore.com

maintainer
#6 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 24 lines · Paul Moore
Quoted 11 lines · On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

Add a new LSM audit data type LSM_AUDIT_DATA_NS that logs namespace information in audit records. Two fields are provided:

- ns_type: the CLONE_NEW* flag identifying the namespace type, logged in hexadecimal.

- ns_id: the unique 64-bit namespace identifier, retrievable from userspace via NS_GET_ID or listns(2). Unlike the proc inode number (inum), ns_id is never recycled. For namespace creation denials, ns_id is 0 because the namespace does not exist yet.

Based on the code in this patch, "ns_type" should be "namespace_type" and a similar change needs to be done for "ns_id". Regardless, the first three patches look fine to me (I can fixup the above during a merge).

As mentioned previously, I want to merge at least the first three patches via the LSM tree since we have multiple LSMs which depend on these new hooks. I'm happy to also merge the remaining Landlock patches in this patchset via the LSM tree, or you can manage those separately; let me know how you would like to proceed with that.

Quoted 6 lines

Since we are at -rc7, this is obviously something for after the upcoming merge window so I'm going to merge the first three patches into the lsm/dev-staging branch now with the understanding that they will move over to the lsm/dev branch after the upcoming merge window is finished. If you want me to merge the Landlock patches too, just let me know.

The first three patches are now in lsm/dev, thanks everyone.

Mickaël, if you would like me to merge the remaining patches in this patchset into the lsm/dev branch just let me know.

Signature · 1 line
paul-moore.com
author maintainer
#7 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 25 lines · Paul Moore
Quoted 24 lines · Paul Moore
Quoted 11 lines · On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

Add a new LSM audit data type LSM_AUDIT_DATA_NS that logs namespace information in audit records. Two fields are provided:

- ns_type: the CLONE_NEW* flag identifying the namespace type, logged in hexadecimal.

- ns_id: the unique 64-bit namespace identifier, retrievable from userspace via NS_GET_ID or listns(2). Unlike the proc inode number (inum), ns_id is never recycled. For namespace creation denials, ns_id is 0 because the namespace does not exist yet.

Based on the code in this patch, "ns_type" should be "namespace_type" and a similar change needs to be done for "ns_id". Regardless, the first three patches look fine to me (I can fixup the above during a merge).

As mentioned previously, I want to merge at least the first three patches via the LSM tree since we have multiple LSMs which depend on these new hooks. I'm happy to also merge the remaining Landlock patches in this patchset via the LSM tree, or you can manage those separately; let me know how you would like to proceed with that.

Quoted 8 lines
Quoted 6 lines

Since we are at -rc7, this is obviously something for after the upcoming merge window so I'm going to merge the first three patches into the lsm/dev-staging branch now with the understanding that they will move over to the lsm/dev branch after the upcoming merge window is finished. If you want me to merge the Landlock patches too, just let me know.

The first three patches are now in lsm/dev, thanks everyone.

Thanks.

Quoted 3 lines

Mickaël, if you would like me to merge the remaining patches in this patchset into the lsm/dev branch just let me know.

I'll send a new patch series soon because this v3 would not apply anymore. I'll include your lsm/dev patches to keep a consistent patch series.

maintainer
#8 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 3 lines · Mickaël Salaün
Quoted 2 lines · Paul Moore
Quoted 1 line · Paul Moore

On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

...

Quoted 5 lines
Quoted 2 lines

Mickaël, if you would like me to merge the remaining patches in this patchset into the lsm/dev branch just let me know.

I'll send a new patch series soon because this v3 would not apply anymore.

Okay.

Quoted 2 lines

I'll include your lsm/dev patches to keep a consistent patch series.

Please don't as those are already merged. If you want to stick with the same patch series, which is fine, just note that the first three patches have already been merged into the LSM tree. It's not uncommon for patchsets to add or drop patches over time as both the patchset and the surrounding environment progress.

Signature · 1 line
paul-moore.com
author maintainer
#9 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 15 lines · Paul Moore
Quoted 3 lines · Mickaël Salaün
Quoted 2 lines · Paul Moore
Quoted 1 line · Paul Moore

On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

...

Quoted 5 lines
Quoted 2 lines

Mickaël, if you would like me to merge the remaining patches in this patchset into the lsm/dev branch just let me know.

I'll send a new patch series soon because this v3 would not apply anymore.

Okay.

Quoted 8 lines
Quoted 2 lines

I'll include your lsm/dev patches to keep a consistent patch series.

Please don't as those are already merged. If you want to stick with the same patch series, which is fine, just note that the first three patches have already been merged into the LSM tree. It's not uncommon for patchsets to add or drop patches over time as both the patchset and the surrounding environment progress.

Yeah, I know, but at the same time are there (merged) users of these hooks? Anyway, we should of course avoid to have two commits for the same patch in different branches (even if that would not be an issue for Git), but having to handle several origins (e.g. the lsm/dev branch for new hooks and the master branch for fixes) might lead to an unpleasant gymnastic.

Another concern is to ease review (for both humans and bots), which might require a well-known base commit, instead of a (transient?) merge commit. That's the reason why I wanted to keep the complete series, even if when we'll apply it, we can drop the first (already applied) patches.

My understanding is also that Linus prefers consistent pull requests, and I'm wondering if that would be ok to send a PR with the lsm/dev (in flight to be merged in master, but not yet) as origin. That could still lead to merge conflicts though...

At least, I think it would help to have these three commits rebased on a (recent) Linux tag (without other commits in between, like the cred's one).

maintainer
#10 lore raw

Re: [PATCH v3 3/12] security: Add LSM_AUDIT_DATA_NS for namespace audit records

Quoted 25 lines · Mickaël Salaün
Quoted 15 lines · Paul Moore
Quoted 3 lines · Mickaël Salaün
Quoted 2 lines · Paul Moore
Quoted 1 line · Paul Moore

On Jul 26, 2026 =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <[email protected]> wrote:

...

Quoted 5 lines
Quoted 2 lines

Mickaël, if you would like me to merge the remaining patches in this patchset into the lsm/dev branch just let me know.

I'll send a new patch series soon because this v3 would not apply anymore.

Okay.

Quoted 8 lines
Quoted 2 lines

I'll include your lsm/dev patches to keep a consistent patch series.

Please don't as those are already merged. If you want to stick with the same patch series, which is fine, just note that the first three patches have already been merged into the LSM tree. It's not uncommon for patchsets to add or drop patches over time as both the patchset and the surrounding environment progress.

Quoted 6 lines

Yeah, I know, but at the same time are there (merged) users of these hooks? Anyway, we should of course avoid to have two commits for the same patch in different branches (even if that would not be an issue for Git), but having to handle several origins (e.g. the lsm/dev branch for new hooks and the master branch for fixes) might lead to an unpleasant gymnastic.

We discussed this already during an unrelated offline conversation, but for the sake of others who might be wondering, that's not quite how things work in the LSM tree. As a refresher, here is how the LSM is managed:

https://github.com/LinuxSecurityModule/kernel/blob/main/README.md#kernel-source-branches-and-development-process

As a quick summary, the lsm/stable-X.Y branch (the current being lsm/stable-7.3) contains patches that go up to Linus during the v7.3-rcX cycle. When relevant, patches in lsm/stable-X.Y are also tagged for linux-stable. New development targeting the upcoming merge window is merged into the lsm/dev branch.

The lsm/next branch feeds into the daily linux-next tree and is composed by cloning the latest lsm/stable-X.Y branch and merging the lsm/dev branch on top. This enables linux-next testing of patches bound for both the current RC cycle as well as the upcoming merge window. During the normal RC cycle, the lsm/next branch is updated whenever there is a change to either the latest lsm/stable-X.Y branch or the lsm/dev branch.

While one might imagine merge conflicts in lsm/next requiring manual intervention would be common, after years of experience I can say that they are not. On the rare occasion when conflicts require manual intervention, they haven't been very difficult to resolve. If we do arrive at such a situation we can work together to sort it out.

Quoted 3 lines

Another concern is to ease review (for both humans and bots) ... which might require a well-known base commit, instead of a (transient?) merge commit.

As documented in the link above, lsm/dev should be a stable branch that you can use as a base for patchsets. It will move forward as patches are added, but it is rebased only under extreme cases (e.g. filesystem corruption, etc.), and rebases are typically communicated to the list.

Signature · 1 line
paul-moore.com
author maintainer
#11 lore raw

PATCH v3 4/12 landlock: Rename quiet_masks to quiet_access

In reply to Mickaël Salaün

The base stores the fs/net/scope quiet bitmasks in a struct access_masks field named quiet_masks. A following commit adds the sibling struct perm_masks field quiet_perm for capabilities and namespaces. quiet_masks drops the access category and keeps the type half ("masks"), while quiet_perm keeps the category and drops the type half, so the two read as an inconsistent pair.

Rename the base field to quiet_access, giving the symmetric, category-named pair quiet_access/quiet_perm that also matches the UAPI handled_access_*/quiet_access_* naming. This is a no-functional-change rename.

Cc Günther Noack <[email protected]>
Cc Tingmao Wang <[email protected]>

---

Changes since v2:
- New patch.

---
 security/landlock/audit.c    |  4 ++--
 security/landlock/domain.h   |  4 ++--
 security/landlock/ruleset.c  |  2 +-
 security/landlock/ruleset.h  |  6 +++---
 security/landlock/syscalls.c | 10 +++++-----
 5 files changed, 13 insertions(+), 13 deletions(-)
security/landlock/audit.c +2 -2
index 50536c568526..4f357a7f8532 100644
@@ -625,7 +625,7 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
 		 */
 		const access_mask_t quiet_mask =
 			pick_access_mask_for_request_type(
-				request->type, youngest_denied->quiet_masks);
+				request->type, youngest_denied->quiet_access);
 
 		quiet_applicable_to_access = (quiet_mask & missing) == missing;
 	} else {
@@ -634,7 +634,7 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
 		 * We check request->type to distinguish between the two cases.
 		 */
 		const access_mask_t quiet_mask =
-			youngest_denied->quiet_masks.scope;
+			youngest_denied->quiet_access.scope;
 
 		switch (request->type) {
 		case LANDLOCK_REQUEST_SCOPE_SIGNAL:
security/landlock/domain.h +2 -2
index 2a1660e3dea7..56cceed5f50c 100644
@@ -112,10 +112,10 @@ struct landlock_hierarchy {
 		 */
 		log_new_exec : 1;
 	/**
-	 * @quiet_masks: Bitmasks of access that should be quieted (i.e. not
+	 * @quiet_access: Bitmasks of access that should be quieted (i.e. not
 	 * logged) if the related object is marked as quiet.
 	 */
-	struct access_masks quiet_masks;
+	struct access_masks quiet_access;
 #endif /* CONFIG_AUDIT */
 };
 
security/landlock/ruleset.c +1 -1
index 4dd09ea22c84..6bccba2ec1ac 100644
@@ -588,7 +588,7 @@ landlock_merge_ruleset(struct landlock_ruleset *const parent,
 		return ERR_PTR(err);
 
 #ifdef CONFIG_AUDIT
-	new_dom->hierarchy->quiet_masks = ruleset->quiet_masks;
+	new_dom->hierarchy->quiet_access = ruleset->quiet_access;
 #endif /* CONFIG_AUDIT */
 
 	return no_free_ptr(new_dom);
security/landlock/ruleset.h +3 -3
index 0437adf17428..f1fdad1d528e 100644
@@ -157,7 +157,7 @@ struct landlock_ruleset {
 		 * section.  This is only used by
 		 * landlock_put_ruleset_deferred() when @usage reaches zero.
 		 * The fields @lock, @usage, @num_rules, @num_layers,
-		 * @quiet_masks and @access_masks are then unused.
+		 * @quiet_access and @access_masks are then unused.
 		 */
 		struct work_struct work_free;
 		struct {
@@ -184,11 +184,11 @@ struct landlock_ruleset {
 			 */
 			u32 num_layers;
 			/**
-			 * @quiet_masks: Stores the quiet flags for an unmerged
+			 * @quiet_access: Stores the quiet flags for an unmerged
 			 * ruleset.  For a merged domain, this is stored in each
 			 * layer's struct landlock_hierarchy instead.
 			 */
-			struct access_masks quiet_masks;
+			struct access_masks quiet_access;
 			/**
 			 * @access_masks: Contains the subset of filesystem and
 			 * network actions that are restricted by a ruleset.
security/landlock/syscalls.c +5 -5
index 36b02892c62f..66a852e5aaf0 100644
@@ -277,9 +277,9 @@ SYSCALL_DEFINE3(landlock_create_ruleset,
 	if (IS_ERR(ruleset))
 		return PTR_ERR(ruleset);
 
-	ruleset->quiet_masks.fs = ruleset_attr.quiet_access_fs;
-	ruleset->quiet_masks.net = ruleset_attr.quiet_access_net;
-	ruleset->quiet_masks.scope = ruleset_attr.quiet_scoped;
+	ruleset->quiet_access.fs = ruleset_attr.quiet_access_fs;
+	ruleset->quiet_access.net = ruleset_attr.quiet_access_net;
+	ruleset->quiet_access.scope = ruleset_attr.quiet_scoped;
 
 	/* Creates anonymous FD referring to the ruleset. */
 	ruleset_fd = anon_inode_getfd("[landlock-ruleset]", &ruleset_fops,
@@ -372,7 +372,7 @@ static int add_rule_path_beneath(struct landlock_ruleset *const ruleset,
 		return -EINVAL;
 
 	/* Checks for useless quiet flag. */
-	if (flags & LANDLOCK_ADD_RULE_QUIET && !ruleset->quiet_masks.fs)
+	if (flags & LANDLOCK_ADD_RULE_QUIET && !ruleset->quiet_access.fs)
 		return -EINVAL;
 
 	/* Gets and checks the new rule. */
@@ -413,7 +413,7 @@ static int add_rule_net_port(struct landlock_ruleset *ruleset,
 		return -EINVAL;
 
 	/* Checks for useless quiet flag. */
-	if (flags & LANDLOCK_ADD_RULE_QUIET && !ruleset->quiet_masks.net)
+	if (flags & LANDLOCK_ADD_RULE_QUIET && !ruleset->quiet_access.net)
 		return -EINVAL;
 
 	/* Denies inserting a rule with port greater than 65535. */
Signature · 1 line
2.54.0
author maintainer
#13 lore raw

PATCH v3 5/12 landlock: Wrap per-layer access masks in struct layer_config

In reply to Mickaël Salaün

The per-layer FAM in struct landlock_ruleset currently stores struct access_masks directly, but upcoming permission features (capability and namespace restrictions) need additional per-layer data beyond the handled-access bitfields.

Introduce struct layer_config as a wrapper around struct access_masks and rename the FAM from access_masks[] to layers[]. This makes room for future per-layer fields (e.g. allowed bitmasks) without modifying struct access_masks itself, which is also used as a lightweight parameter type for functions that only need the handled-access bitfields.

No functional change.

---

Changes since v2:
https://patch.msgid.link/[email protected]
- The rebase required adopting the released check-time struct layer_masks and the new per-ruleset quiet_access (added by the base's merged quiet feature) and updating the struct landlock_ruleset @layers kdoc; struct layer_config already existed in v2.

Changes since v1:
https://patch.msgid.link/[email protected]
- Add Reviewed-by: Tingmao Wang.
- Address Günther Noack's review nits:
- Clarify that _LANDLOCK_ACCESS_FS_INITIALLY_DENIED is ORed with

    the .handled field of all ruleset->layers[] entries (not the
    entries themselves).

- Rename landlock_upgrade_handled_access_masks() to landlock_upgrade_handled_layer_config() to match the parameter type.
- Rewrap the @layers kdoc in struct landlock_ruleset.
- Rename struct layer_rights to struct layer_config: "config" is the more general term for per-layer state.
- Add Reviewed-by: Günther Noack.

---
 security/landlock/access.h   | 32 ++++++++++++++++++++---------
 security/landlock/cred.h     |  2 +-
 security/landlock/ruleset.c  | 16 +++++++--------
 security/landlock/ruleset.h  | 39 ++++++++++++++++++------------------
 security/landlock/syscalls.c |  2 +-
 5 files changed, 52 insertions(+), 39 deletions(-)
security/landlock/access.h +23 -9
index d926078bf0a5..b4f79508729e 100644
@@ -19,9 +19,9 @@
 
 /*
  * All access rights that are denied by default whether they are handled or not
- * by a ruleset/layer.  This must be ORed with all ruleset->access_masks[]
- * entries when we need to get the absolute handled access masks, see
- * landlock_upgrade_handled_access_masks().
+ * by a ruleset/layer.  This must be ORed with the .handled field of all
+ * ruleset->layers[] entries when we need to get the absolute handled access
+ * masks, see landlock_upgrade_handled_layer_config().
  */
 /* clang-format off */
 #define _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \
@@ -45,7 +45,7 @@ static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_SCOPE);
 /* Makes sure for_each_set_bit() and for_each_clear_bit() calls are OK. */
 static_assert(sizeof(unsigned long) >= sizeof(access_mask_t));
 
-/* Ruleset access masks. */
+/* Handled access masks (bitfields only). */
 struct access_masks {
 	access_mask_t fs : LANDLOCK_NUM_ACCESS_FS;
 	access_mask_t net : LANDLOCK_NUM_ACCESS_NET;
@@ -61,6 +61,20 @@ union access_masks_all {
 static_assert(sizeof(typeof_member(union access_masks_all, masks)) ==
 	      sizeof(typeof_member(union access_masks_all, all)));
 
+/**
+ * struct layer_config - Per-layer access configuration
+ *
+ * Wraps the per-layer handled-access bitfields.  This is the element type of
+ * the &struct landlock_ruleset.layers FAM.
+ */
+struct layer_config {
+	/**
+	 * @handled: Bitmask of access rights handled (i.e. restricted) by this
+	 * layer.
+	 */
+	struct access_masks handled;
+};
+
 /**
  * struct layer_mask - The access rights and rule flags for a layer.
  *
@@ -123,17 +137,17 @@ static_assert(BITS_PER_TYPE(deny_masks_t) >=
 static_assert(HWEIGHT(LANDLOCK_MAX_NUM_LAYERS) == 1);
 
 /* Upgrades with all initially denied by default access rights. */
-static inline struct access_masks
-landlock_upgrade_handled_access_masks(struct access_masks access_masks)
+static inline struct layer_config
+landlock_upgrade_handled_layer_config(struct layer_config layer_config)
 {
 	/*
 	 * All access rights that are denied by default whether they are
 	 * explicitly handled or not.
 	 */
-	if (access_masks.fs)
-		access_masks.fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
+	if (layer_config.handled.fs)
+		layer_config.handled.fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
 
-	return access_masks;
+	return layer_config;
 }
 
 /* Checks the subset relation between access masks. */
security/landlock/cred.h +1 -1
index f287c56b5fd4..3e2a7e88710e 100644
@@ -139,7 +139,7 @@ landlock_get_applicable_subject(const struct cred *const cred,
 	for (layer_level = domain->num_layers - 1; layer_level >= 0;
 	     layer_level--) {
 		union access_masks_all layer = {
-			.masks = domain->access_masks[layer_level],
+			.masks = domain->layers[layer_level].handled,
 		};
 
 		if (layer.all & masks_all.all) {
security/landlock/ruleset.c +8 -8
index 6bccba2ec1ac..af08a8cc705c 100644
@@ -33,7 +33,7 @@ static struct landlock_ruleset *create_ruleset(const u32 num_layers)
 {
 	struct landlock_ruleset *new_ruleset;
 
-	new_ruleset = kzalloc_flex(*new_ruleset, access_masks, num_layers,
+	new_ruleset = kzalloc_flex(*new_ruleset, layers, num_layers,
 				   GFP_KERNEL_ACCOUNT);
 	if (!new_ruleset)
 		return ERR_PTR(-ENOMEM);
@@ -47,9 +47,9 @@ static struct landlock_ruleset *create_ruleset(const u32 num_layers)
 
 	new_ruleset->num_layers = num_layers;
 	/*
-	 * hierarchy = NULL
-	 * num_rules = 0
-	 * access_masks[] = 0
+	 * - hierarchy = NULL
+	 * - num_rules = 0
+	 * - layers[] = 0
 	 */
 	return new_ruleset;
 }
@@ -387,8 +387,8 @@ static int merge_ruleset(struct landlock_ruleset *const dst,
 		err = -EINVAL;
 		goto out_unlock;
 	}
-	dst->access_masks[dst->num_layers - 1] =
-		landlock_upgrade_handled_access_masks(src->access_masks[0]);
+	dst->layers[dst->num_layers - 1] =
+		landlock_upgrade_handled_layer_config(src->layers[0]);
 
 	/* Merges the @src inode tree. */
 	err = merge_tree(dst, src, LANDLOCK_KEY_INODE);
@@ -470,8 +470,8 @@ static int inherit_ruleset(struct landlock_ruleset *const parent,
 		goto out_unlock;
 	}
 	/* Copies the parent layer stack and leaves a space for the new layer. */
-	memcpy(child->access_masks, parent->access_masks,
-	       flex_array_size(parent, access_masks, parent->num_layers));
+	memcpy(child->layers, parent->layers,
+	       flex_array_size(parent, layers, parent->num_layers));
 
 	if (WARN_ON_ONCE(!parent->hierarchy)) {
 		err = -EINVAL;
security/landlock/ruleset.h +19 -20
index f1fdad1d528e..2a825b1f08b9 100644
@@ -157,7 +157,7 @@ struct landlock_ruleset {
 		 * section.  This is only used by
 		 * landlock_put_ruleset_deferred() when @usage reaches zero.
 		 * The fields @lock, @usage, @num_rules, @num_layers,
-		 * @quiet_access and @access_masks are then unused.
+		 * @quiet_access and @layers are then unused.
 		 */
 		struct work_struct work_free;
 		struct {
@@ -190,18 +190,16 @@ struct landlock_ruleset {
 			 */
 			struct access_masks quiet_access;
 			/**
-			 * @access_masks: Contains the subset of filesystem and
-			 * network actions that are restricted by a ruleset.
-			 * A domain saves all layers of merged rulesets in a
-			 * stack (FAM), starting from the first layer to the
-			 * last one.  These layers are used when merging
-			 * rulesets, for user space backward compatibility
-			 * (i.e. future-proof), and to properly handle merged
-			 * rulesets without overlapping access rights.  These
-			 * layers are set once and never changed for the
-			 * lifetime of the ruleset.
+			 * @layers: Per-layer access configuration.  A domain
+			 * saves all layers of merged rulesets in a stack (FAM),
+			 * starting from the first layer to the last one.  These
+			 * layers are used when merging rulesets, for user space
+			 * backward compatibility (i.e. future-proof), and to
+			 * properly handle merged rulesets without overlapping
+			 * access rights.  These layers are set once and never
+			 * changed for the lifetime of the ruleset.
 			 */
-			struct access_masks access_masks[];
+			struct layer_config layers[] __counted_by(num_layers);
 		};
 	};
 };
@@ -241,7 +239,8 @@ static inline void landlock_get_ruleset(struct landlock_ruleset *const ruleset)
  *
  * @domain: Landlock ruleset (used as a domain)
  *
- * Return: An access_masks result of the OR of all the domain's access masks.
+ * Return: An access_masks result of the OR of all the domain's handled access
+ * masks.
  */
 static inline struct access_masks
 landlock_union_access_masks(const struct landlock_ruleset *const domain)
@@ -251,7 +250,7 @@ landlock_union_access_masks(const struct landlock_ruleset *const domain)
 
 	for (layer_level = 0; layer_level < domain->num_layers; layer_level++) {
 		union access_masks_all layer = {
-			.masks = domain->access_masks[layer_level],
+			.masks = domain->layers[layer_level].handled,
 		};
 
 		matches.all |= layer.all;
@@ -269,7 +268,7 @@ landlock_add_fs_access_mask(struct landlock_ruleset *const ruleset,
 
 	/* Should already be checked in sys_landlock_create_ruleset(). */
 	WARN_ON_ONCE(fs_access_mask != fs_mask);
-	ruleset->access_masks[layer_level].fs |= fs_mask;
+	ruleset->layers[layer_level].handled.fs |= fs_mask;
 }
 
 static inline void
@@ -281,7 +280,7 @@ landlock_add_net_access_mask(struct landlock_ruleset *const ruleset,
 
 	/* Should already be checked in sys_landlock_create_ruleset(). */
 	WARN_ON_ONCE(net_access_mask != net_mask);
-	ruleset->access_masks[layer_level].net |= net_mask;
+	ruleset->layers[layer_level].handled.net |= net_mask;
 }
 
 static inline void
@@ -292,7 +291,7 @@ landlock_add_scope_mask(struct landlock_ruleset *const ruleset,
 
 	/* Should already be checked in sys_landlock_create_ruleset(). */
 	WARN_ON_ONCE(scope_mask != mask);
-	ruleset->access_masks[layer_level].scope |= mask;
+	ruleset->layers[layer_level].handled.scope |= mask;
 }
 
 static inline access_mask_t
@@ -300,7 +299,7 @@ landlock_get_fs_access_mask(const struct landlock_ruleset *const ruleset,
 			    const u16 layer_level)
 {
 	/* Handles all initially denied by default access rights. */
-	return ruleset->access_masks[layer_level].fs |
+	return ruleset->layers[layer_level].handled.fs |
 	       _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
 }
 
@@ -308,14 +307,14 @@ static inline access_mask_t
 landlock_get_net_access_mask(const struct landlock_ruleset *const ruleset,
 			     const u16 layer_level)
 {
-	return ruleset->access_masks[layer_level].net;
+	return ruleset->layers[layer_level].handled.net;
 }
 
 static inline access_mask_t
 landlock_get_scope_mask(const struct landlock_ruleset *const ruleset,
 			const u16 layer_level)
 {
-	return ruleset->access_masks[layer_level].scope;
+	return ruleset->layers[layer_level].handled.scope;
 }
 
 bool landlock_unmask_layers(const struct landlock_rule *const rule,
security/landlock/syscalls.c +1 -1
index 66a852e5aaf0..1924c703c280 100644
@@ -367,7 +367,7 @@ static int add_rule_path_beneath(struct landlock_ruleset *const ruleset,
 		return -ENOMSG;
 
 	/* Checks that allowed_access matches the @ruleset constraints. */
-	mask = ruleset->access_masks[0].fs;
+	mask = ruleset->layers[0].handled.fs;
 	if ((path_beneath_attr.allowed_access | mask) != mask)
 		return -EINVAL;
 
Signature · 1 line
2.54.0
Reviewed-by on v3 5/12
#14 lore raw

Re: [PATCH v3 05/12] landlock: Wrap per-layer access masks in struct layer_config

security/landlock/access.h union access_masks_all { · line 70

Quoted 12 lines · Mickaël Salaün

[...]

security/landlock/access.h +7 -0
@@ -61,6 +61,20 @@ union access_masks_all {
 static_assert(sizeof(typeof_member(union access_masks_all, masks)) ==
 	      sizeof(typeof_member(union access_masks_all, all)));
 
+/**
+ * struct layer_config - Per-layer access configuration
+ *
+ * Wraps the per-layer handled-access bitfields.  This is the element type of
+ * the &struct landlock_ruleset.layers FAM.
+ */
+struct layer_config {

This will be nice to have for the supervise stuff.

Quoted 10 lines
security/landlock/access.h +7 -0
+	/**
+	 * @handled: Bitmask of access rights handled (i.e. restricted) by this
+	 * layer.
+	 */
+	struct access_masks handled;
+};
+
 /**
  * struct layer_mask - The access rights and rule flags for a layer.
  *
author maintainer
#15 lore raw

PATCH v3 6/12 landlock: Copy the quiet mask in the ruleset merge helper

In reply to Mickaël Salaün

Relocate the quiet_access hierarchy copy from landlock_merge_ruleset() into merge_ruleset(), where the ruleset lock is already held and the per-layer state is snapshotted.

No behavioral change: quiet_access is set once in create_ruleset() and never modified afterwards. This is done for consistency with the following commit, which copies quiet_perm (mutated per rule by landlock_add_rule()) at the same site so it is captured atomically with the allowed mask.

Cc Günther Noack <[email protected]>
Cc Tingmao Wang <[email protected]>

---

Changes since v2:
- New patch.

---
 security/landlock/ruleset.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
security/landlock/ruleset.c +4 -4
index af08a8cc705c..b6552415f3be 100644
@@ -402,6 +402,10 @@ static int merge_ruleset(struct landlock_ruleset *const dst,
 		goto out_unlock;
 #endif /* IS_ENABLED(CONFIG_INET) */
 
+#ifdef CONFIG_AUDIT
+	dst->hierarchy->quiet_access = src->quiet_access;
+#endif /* CONFIG_AUDIT */
+
 out_unlock:
 	mutex_unlock(&src->lock);
 	mutex_unlock(&dst->lock);
@@ -587,10 +591,6 @@ landlock_merge_ruleset(struct landlock_ruleset *const parent,
 	if (err)
 		return ERR_PTR(err);
 
-#ifdef CONFIG_AUDIT
-	new_dom->hierarchy->quiet_access = ruleset->quiet_access;
-#endif /* CONFIG_AUDIT */
-
 	return no_free_ptr(new_dom);
 }
 
Signature · 1 line
2.54.0
author maintainer
#17 lore raw

PATCH v3 7/12 landlock: Enforce namespace use restrictions

In reply to Mickaël Salaün

Add Landlock enforcement for namespace use via the LSM namespace_init and namespace_install hooks. This lets a sandboxed process restrict which namespace types it can acquire, using LANDLOCK_PERM_NAMESPACE_USE and per-type rules.

Introduce the handled_perm field in struct landlock_ruleset_attr for per-category permissions: each permission gates all uses of a kernel-defined category (CLONE_NEW* for namespace types, CAP_* for capabilities) and provides complete deny-by-default coverage of category members. Rule values reference constants from other kernel subsystems (CLONE_NEW* for namespaces); unknown values are silently accepted because the allow-list denies them by default. See the "Ruleset restriction models" section in the kernel documentation for the full design rationale.

The new permissions extend the UAPI, so this bumps the Landlock ABI version to 11.

Both hooks share check_ns_type(): if the namespace's CLONE_NEW* type is not in the layer's allowed set, the operation is denied. No domain ancestry bypass, no namespace creator tracking, just a flat per-layer allowed-types bitmask.

- hook_namespace_init() fires during unshare(CLONE_NEW*) and clone(CLONE_NEW*) via __ns_common_init().

- hook_namespace_install() fires during setns() via validate_ns().

Both record namespace_type and ns_id in the audit data; ns_id is zero at namespace creation.

struct perm_masks is __packed __aligned(sizeof(u64)) because on m68k GCC packs bitfields at byte granularity, so without it a u64 bitfield struct can be smaller than sizeof(u64).

The rule's perm selector must be LANDLOCK_PERM_NAMESPACE_USE and reserves room for future per-rule-type sub-permissions. allowed_namespace_types lists the allowed CLONE_NEW* flags; unknown bits are accepted for forward compatibility and have no effect since the allow-list denies by default.

The rule also carries a quiet_namespace_types bitmask that silences the audit records of specific denied members without granting them. A sandbox that knowingly runs a caller probing a namespace type or capability it will never be granted (e.g. an old runtime kept for compatibility) would otherwise flood the audit log and drown the surprising denials that matter. Quiet is per-member rather than a coarse per-category ruleset bit so a sandbox can silence one member (CLONE_NEWNET) while still auditing another (CLONE_NEWUTS). Making quiet the complement of the allowed set would be broad, could not audit a member that is neither allowed nor explicitly quieted, and would auto-hide members added by future kernels. For the same reason a sandbox should quiet only specific members known to be requested but expected to be denied, never a blanket set, which follows the running kernel's known members and hides surprising or future denials. A bit set in both allowed_namespace_types and quiet_namespace_types has no effect, since an allowed member is never denied and its layer can never become the youngest denying layer for that member.

The merged filesystem and network quiet feature marks unbounded rb-tree objects (paths, ports) quiet through the LANDLOCK_ADD_RULE_QUIET flag and the ruleset quiet_access_* masks. Capabilities and namespace types are instead a small, bounded, kernel-defined member set, so their quiet list is a per-rule bitmask sibling to the allowed bitmask, and the shared flag is rejected for these rule types. A single add_rule call can allow some members and quiet others independently, and a quiet-only rule (empty allowed set) is valid. Only the youngest denying layer's quiet mask decides, so a parent cannot silence a denial made by a deeper layer.

User namespace creation does not require capabilities, so Landlock can restrict it directly. Non-user namespace types require CAP_SYS_ADMIN before the Landlock check is reached; when both LANDLOCK_PERM_NAMESPACE_USE and LANDLOCK_PERM_CAPABILITY_USE are handled, both must allow the operation.

Cc: Christian Brauner <[email protected]>
Cc: Günther Noack <[email protected]>
Cc: Paul Moore <[email protected]>
Cc: Serge E. Hallyn <[email protected]>
Depends-on: 935a04923ad2 ("nsproxy: Add FOR_EACH_NS_TYPE() X-macro and CLONE_NS_ALL")

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Rename the namespace rule attribute fields (allowed_perm to perm, namespace_types to allowed_namespace_types) and add a quiet_namespace_types bitmask that suppresses the audit records of specific denied namespace types, together with the shared per-layer quiet member mask read in landlock_log_denial(); the rule attribute grows from 16 to 24 bytes.
- Copy the accumulated quiet_perm mask into the domain hierarchy in merge_ruleset(), under the ruleset merge lock and atomically with the allowed mask (no separate lock).
- Dropped Reviewed-by: Günther Noack and Tingmao Wang, as this version adds the quiet member mask described above, which their v1 review did not cover. Fresh review welcome.

Changes since v1:
https://patch.msgid.link/[email protected]
- Add __packed __aligned(sizeof(u64)) to struct perm_masks to fix static_assert failure on m68k, where GCC packs bitfields at byte granularity.
- Use ns_id instead of inum in namespace audit records.
- Add WARN_ON_ONCE guards for invalid perm_bit or request_value in landlock_perm_is_denied(), denying with the youngest layer on invalid input (suggested by Tingmao Wang).
- Fix double backtick in landlock_perm_is_denied() kernel-doc.
- Add Reviewed-by: Tingmao Wang.
- Mention commit 935a04923ad2 ("nsproxy: Add FOR_EACH_NS_TYPE() X-macro and CLONE_NS_ALL") as a dependency in the body and add
Depends-on: trailer.
- Rename internal struct perm_rules to perm_masks to parallel the sibling access_masks in struct layer_config.
- Document the allowed_perm design rationale (extensibility for future sub-permissions, type discriminant safeguard).
- Rename LANDLOCK_PERM_NAMESPACE_ENTER to LANDLOCK_PERM_NAMESPACE_USE and audit blocker perm.namespace_enter to perm.namespace_use for semantic accuracy. The verb _ENTER fits setns/unshare/clone (caller becomes namespace member) but misleads for open_tree and fsmount (caller holds an fd reference, does not enter). _USE covers both cases and mirrors LANDLOCK_PERM_CAPABILITY_USE. Update the commit title accordingly.
- Replace "chokepoint"/"gateway" prose in @handled_perm kdoc and the Permission flags DOC block with the per-category framing.
- Expand the LANDLOCK_PERM_NAMESPACE_USE kdoc to enumerate creation (unshare/clone/clone3), joining (setns), and fd-reference (open_tree/fsmount) paths.
- Rewrite the commit body to drop chokepoint/gateway terminology in favour of per-category framing, matching the doc rewrite.
- Rename struct layer_rights to struct layer_config (companion change to the introducing commit).
- Surface the empty-check semantics in the landlock_namespace_attr.namespace_types kdoc: a rule that sets only bits unknown to the running kernel succeeds but has no runtime effect.
- Cascade the LSM hook rename namespace_alloc -> namespace_init (LSM_HOOK_INIT registration and local handler hook_namespace_alloc -> hook_namespace_init), companion change to the introducing commit.
- Rename the static helper landlock_check_ns_type() to check_ns_type():
the landlock_ prefix is reserved for non-static symbols exported via headers; file-static helpers follow the prefix-free convention used in security/landlock/.
- Add Reviewed-by: Günther Noack.

---
 include/uapi/linux/landlock.h                |  80 +++++++++-
 security/landlock/Makefile                   |   3 +-
 security/landlock/access.h                   |  39 ++++-
 security/landlock/audit.c                    |  17 ++
 security/landlock/audit.h                    |   1 +
 security/landlock/cred.h                     |  50 ++++++
 security/landlock/domain.h                   |   6 +
 security/landlock/limits.h                   |   7 +
 security/landlock/ns.c                       | 156 +++++++++++++++++++
 security/landlock/ns.h                       |  74 +++++++++
 security/landlock/ruleset.c                  |  19 ++-
 security/landlock/ruleset.h                  |  54 +++++--
 security/landlock/setup.c                    |   2 +
 security/landlock/syscalls.c                 |  92 ++++++++++-
 tools/testing/selftests/landlock/base_test.c |   2 +-
 15 files changed, 575 insertions(+), 27 deletions(-)
 create mode 100644 security/landlock/ns.c
 create mode 100644 security/landlock/ns.h
include/uapi/linux/landlock.h +79 -1
index 7ffe2ef127ee..343cb4e0f51a 100644
@@ -78,6 +78,15 @@ struct landlock_ruleset_attr {
 	 * @quiet_scoped: Bitmask of scoped actions which should not be logged.
 	 */
 	__u64 quiet_scoped;
+	/**
+	 * @handled_perm: Bitmask of permissions (cf. `Permission flags`_) that
+	 * this ruleset handles.  Each permission controls a per-category
+	 * operation gated by an enum (CLONE_NEW* for namespace types, CAP_* for
+	 * capabilities); all uses of category members are denied unless
+	 * explicitly allowed by a rule.  See
+	 * Documentation/security/landlock.rst for the rationale.
+	 */
+	__u64 handled_perm;
 };
 
 /**
@@ -215,6 +224,10 @@ enum landlock_rule_type {
 	 * landlock_net_port_attr .
 	 */
 	LANDLOCK_RULE_NET_PORT,
+	/**
+	 * @LANDLOCK_RULE_NAMESPACE: Type of a &struct landlock_namespace_attr .
+	 */
+	LANDLOCK_RULE_NAMESPACE,
 };
 
 /**
@@ -268,6 +281,40 @@ struct landlock_net_port_attr {
 	__u64 port;
 };
 
+/**
+ * struct landlock_namespace_attr - Namespace type definition
+ *
+ * Argument of sys_landlock_add_rule() with %LANDLOCK_RULE_NAMESPACE.
+ */
+struct landlock_namespace_attr {
+	/**
+	 * @perm: Must be set to %LANDLOCK_PERM_NAMESPACE_USE.
+	 */
+	__u64 perm;
+	/**
+	 * @allowed_namespace_types: Bitmask of namespace types (``CLONE_NEW*``
+	 * flags) to allow under this rule.  Unknown bits are silently ignored
+	 * for forward compatibility.
+	 */
+	__u64 allowed_namespace_types;
+	/**
+	 * @quiet_namespace_types: Bitmask of namespace types (``CLONE_NEW*``
+	 * flags) whose denial by this layer should not be logged, even if
+	 * logging would normally take place per landlock_restrict_self() flags.
+	 * Only denials attributed to this layer are suppressed (see `permission
+	 * flags`_).  Bits also set in @allowed_namespace_types have no effect,
+	 * since an allowed type is never denied.  Unknown bits are silently
+	 * ignored.
+	 *
+	 * At least one of @allowed_namespace_types or @quiet_namespace_types
+	 * must be non-zero, otherwise the call returns ``-ENOMSG``.  The
+	 * non-zero check runs on the raw input before unknown-bit masking, so a
+	 * rule that sets only bits unknown to the running kernel succeeds but
+	 * has no runtime effect.
+	 */
+	__u64 quiet_namespace_types;
+};
+
 /**
  * DOC: fs_access
  *
@@ -491,6 +538,37 @@ struct landlock_net_port_attr {
 /* clang-format off */
 #define LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET		(1ULL << 0)
 #define LANDLOCK_SCOPE_SIGNAL		                (1ULL << 1)
-/* clang-format on*/
+/* clang-format on */
+
+/**
+ * DOC: perm
+ *
+ * Permission flags
+ * ~~~~~~~~~~~~~~~~
+ *
+ * These flags restrict per-category operations gated by enums (CLONE_NEW* for
+ * namespace types, CAP_* for capabilities).  Each flag covers every kernel path
+ * that exercises a member of the category.  Handled permissions that are not
+ * explicitly allowed by a rule are denied by default.  Rule values reference
+ * constants from other kernel subsystems; unknown values are silently accepted
+ * for forward compatibility since the allow-list denies them by default.  See
+ * Documentation/security/landlock.rst for design details.
+ *
+ * When a ruleset handles multiple permissions whose operations overlap (e.g. a
+ * non-user namespace needs both its namespace type and CAP_SYS_ADMIN), the
+ * operation is allowed only if each handled permission independently allows it.
+ * See Documentation/userspace-api/landlock.rst.
+ *
+ * - %LANDLOCK_PERM_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)`).  A
+ *   process in a Landlock domain that handles this permission is denied
+ *   from using namespace types that are not explicitly allowed by a
+ *   %LANDLOCK_RULE_NAMESPACE rule.
+ */
+/* clang-format off */
+#define LANDLOCK_PERM_NAMESPACE_USE			(1ULL << 0)
+/* clang-format on */
 
 #endif /* _UAPI_LINUX_LANDLOCK_H */
security/landlock/Makefile +2 -1
index ffa7646d99f3..cacfba075dec 100644
@@ -8,7 +8,8 @@ landlock-y := \
 	cred.o \
 	task.o \
 	fs.o \
-	tsync.o
+	tsync.o \
+	ns.o
 
 landlock-$(CONFIG_INET) += net.o
 
security/landlock/access.h +37 -2
index b4f79508729e..9dbacccc9b99 100644
@@ -42,6 +42,8 @@ static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_ACCESS_FS);
 static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_ACCESS_NET);
 /* Makes sure all scoped rights can be stored. */
 static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_SCOPE);
+/* Makes sure all permission types can be stored. */
+static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_PERM);
 /* Makes sure for_each_set_bit() and for_each_clear_bit() calls are OK. */
 static_assert(sizeof(unsigned long) >= sizeof(access_mask_t));
 
@@ -50,6 +52,7 @@ struct access_masks {
 	access_mask_t fs : LANDLOCK_NUM_ACCESS_FS;
 	access_mask_t net : LANDLOCK_NUM_ACCESS_NET;
 	access_mask_t scope : LANDLOCK_NUM_SCOPE;
+	access_mask_t perm : LANDLOCK_NUM_PERM;
 } __packed __aligned(sizeof(u32));
 
 union access_masks_all {
@@ -61,13 +64,45 @@ union access_masks_all {
 static_assert(sizeof(typeof_member(union access_masks_all, masks)) ==
 	      sizeof(typeof_member(union access_masks_all, all)));
 
+/**
+ * struct perm_masks - Per-layer allowed bitmasks for permission types
+ *
+ * Compact bitfield struct holding the allowed bitmasks for permission types
+ * that use flat (non-tree) per-layer storage.  All fields share a single 64-bit
+ * storage unit.
+ */
+struct perm_masks {
+	/**
+	 * @ns: Allowed namespace types.  Each bit corresponds to a sequential
+	 * index assigned by the ``_LANDLOCK_NS_*`` enum (derived from
+	 * ``FOR_EACH_NS_TYPE``).  Bits are converted from ``CLONE_NEW*`` flags
+	 * at rule-add time via ``landlock_ns_types_to_bits()`` and at
+	 * enforcement time via ``landlock_ns_type_to_bit()``.
+	 */
+	u64 ns : LANDLOCK_NUM_PERM_NS;
+} __packed __aligned(sizeof(u64));
+
+static_assert(sizeof(struct perm_masks) == sizeof(u64));
+
 /**
  * struct layer_config - Per-layer access configuration
  *
- * Wraps the per-layer handled-access bitfields.  This is the element type of
- * the &struct landlock_ruleset.layers FAM.
+ * Wraps the handled-access bitfields together with per-layer allowed bitmasks.
+ * This is the element type of the &struct landlock_ruleset.layers FAM.
+ *
+ * Unlike filesystem and network access rights, which are tracked per-object in
+ * red-black trees, namespace types use a flat bitmask because their keyspace is
+ * small and bounded (~8 namespace types).  A single rule adds to the allowed
+ * set via bitwise OR; at enforcement time each layer is checked directly (no
+ * tree lookup needed).
  */
 struct layer_config {
+	/**
+	 * @allowed: Per-layer allowed bitmasks for permission types.  Placed
+	 * before @handled so the wider, more-aligned member comes first,
+	 * avoiding internal padding.
+	 */
+	struct perm_masks allowed;
 	/**
 	 * @handled: Bitmask of access rights handled (i.e. restricted) by this
 	 * layer.
security/landlock/audit.c +17 -0
index 4f357a7f8532..dc4716635942 100644
@@ -18,6 +18,7 @@
 #include "cred.h"
 #include "domain.h"
 #include "limits.h"
+#include "ns.h"
 #include "ruleset.h"
 
 static const char *const fs_access_strings[] = {
@@ -82,6 +83,10 @@ get_blocker(const enum landlock_request_type type,
 	case LANDLOCK_REQUEST_SCOPE_SIGNAL:
 		WARN_ON_ONCE(access_bit != -1);
 		return "scope.signal";
+
+	case LANDLOCK_REQUEST_NAMESPACE:
+		WARN_ON_ONCE(access_bit != -1);
+		return "perm.namespace_use";
 	}
 
 	WARN_ON_ONCE(1);
@@ -646,6 +651,18 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
 				!!(quiet_mask &
 				   LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET);
 			break;
+		/*
+		 * Capability and namespace denials are per-member (single
+		 * axis): the denied member is quiet when its bit is set in the
+		 * denying layer's quiet_perm mask.  The member is recovered
+		 * from the audit data recorded by the hook.
+		 */
+		case LANDLOCK_REQUEST_NAMESPACE:
+			quiet_applicable_to_access =
+				!!(youngest_denied->quiet_perm.ns &
+				   landlock_ns_type_to_bit(
+					   request->audit.u.ns.ns_type));
+			break;
 		/*
 		 * Leave LANDLOCK_REQUEST_PTRACE and
 		 * LANDLOCK_REQUEST_FS_CHANGE_TOPOLOGY unhandled for now - they
security/landlock/audit.h +1 -0
index 620f8a24291d..9dd522b62448 100644
@@ -21,6 +21,7 @@ enum landlock_request_type {
 	LANDLOCK_REQUEST_NET_ACCESS,
 	LANDLOCK_REQUEST_SCOPE_ABSTRACT_UNIX_SOCKET,
 	LANDLOCK_REQUEST_SCOPE_SIGNAL,
+	LANDLOCK_REQUEST_NAMESPACE,
 };
 
 /*
security/landlock/cred.h +50 -0

56 lines not on this page · raw message

security/landlock/domain.h +6 -0
index 56cceed5f50c..c2b72795b0d6 100644
@@ -116,6 +116,12 @@ struct landlock_hierarchy {
 	 * logged) if the related object is marked as quiet.
 	 */
 	struct access_masks quiet_access;
+	/**
+	 * @quiet_perm: Per-member quiet bitmasks for permission types
+	 * (capabilities and namespace types).  A member denied by this layer is
+	 * not logged when its bit is set here.
+	 */
+	struct perm_masks quiet_perm;
 #endif /* CONFIG_AUDIT */
 };
 
security/landlock/limits.h +7 -0
index 08d5f2f6d321..b7209188fd50 100644
@@ -12,6 +12,7 @@
 
 #include <linux/bitops.h>
 #include <linux/limits.h>
+#include <linux/ns/ns_common_types.h>
 #include <uapi/linux/landlock.h>
 
 /* clang-format off */
@@ -31,6 +32,12 @@
 #define LANDLOCK_MASK_SCOPE		((LANDLOCK_LAST_SCOPE << 1) - 1)
 #define LANDLOCK_NUM_SCOPE		__const_hweight64(LANDLOCK_MASK_SCOPE)
 
+#define LANDLOCK_LAST_PERM		LANDLOCK_PERM_NAMESPACE_USE
+#define LANDLOCK_MASK_PERM		((LANDLOCK_LAST_PERM << 1) - 1)
+#define LANDLOCK_NUM_PERM		__const_hweight64(LANDLOCK_MASK_PERM)
+
+#define LANDLOCK_NUM_PERM_NS		__const_hweight64((u64)(CLONE_NS_ALL))
+
 #define LANDLOCK_NUM_ACCESS_MAX \
 	MAX(MAX(LANDLOCK_NUM_ACCESS_FS, LANDLOCK_NUM_ACCESS_NET), LANDLOCK_NUM_SCOPE)
 
security/landlock/ns.c new file +156 -0

156 lines not on this page · raw message

security/landlock/ns.h new file +74 -0

74 lines not on this page · raw message

security/landlock/ruleset.c +14 -5
index b6552415f3be..45687f348bc5 100644
@@ -54,15 +54,14 @@ static struct landlock_ruleset *create_ruleset(const u32 num_layers)
 	return new_ruleset;
 }
 
-struct landlock_ruleset *
-landlock_create_ruleset(const access_mask_t fs_access_mask,
-			const access_mask_t net_access_mask,
-			const access_mask_t scope_mask)
+struct landlock_ruleset *landlock_create_ruleset(
+	const access_mask_t fs_access_mask, const access_mask_t net_access_mask,
+	const access_mask_t scope_mask, const access_mask_t perm_mask)
 {
 	struct landlock_ruleset *new_ruleset;
 
 	/* Informs about useless ruleset. */
-	if (!fs_access_mask && !net_access_mask && !scope_mask)
+	if (!fs_access_mask && !net_access_mask && !scope_mask && !perm_mask)
 		return ERR_PTR(-ENOMSG);
 	new_ruleset = create_ruleset(1);
 	if (IS_ERR(new_ruleset))
@@ -73,6 +72,8 @@ landlock_create_ruleset(const access_mask_t fs_access_mask,
 		landlock_add_net_access_mask(new_ruleset, net_access_mask, 0);
 	if (scope_mask)
 		landlock_add_scope_mask(new_ruleset, scope_mask, 0);
+	if (perm_mask)
+		landlock_add_perm_mask(new_ruleset, perm_mask, 0);
 	return new_ruleset;
 }
 
@@ -404,6 +405,14 @@ static int merge_ruleset(struct landlock_ruleset *const dst,
 
 #ifdef CONFIG_AUDIT
 	dst->hierarchy->quiet_access = src->quiet_access;
+	/*
+	 * quiet_perm is accumulated per rule by landlock_add_rule() under
+	 * ruleset->lock, so it must be snapshotted here, in the same critical
+	 * section as the allowed mask; a later, separate copy would race
+	 * landlock_add_rule() and split the snapshot.  The immutable
+	 * quiet_access above shares this site for consistency.
+	 */
+	dst->hierarchy->quiet_perm = src->quiet_perm;
 #endif /* CONFIG_AUDIT */
 
 out_unlock:
security/landlock/ruleset.h +41 -13

78 lines not on this page · raw message

security/landlock/setup.c +2 -0
index 47dac1736f10..a7ed776b41b4 100644
@@ -17,6 +17,7 @@
 #include "fs.h"
 #include "id.h"
 #include "net.h"
+#include "ns.h"
 #include "setup.h"
 #include "task.h"
 
@@ -68,6 +69,7 @@ static int __init landlock_init(void)
 	landlock_add_task_hooks();
 	landlock_add_fs_hooks();
 	landlock_add_net_hooks();
+	landlock_add_ns_hooks();
 	landlock_init_id();
 	landlock_initialized = true;
 	pr_info("Up and running.\n");
security/landlock/syscalls.c +88 -4

157 lines not on this page · raw message

tools/testing/selftests/landlock/base_test.c +1 -1
index cbd3c1669951..b8b5fa1042ba 100644
@@ -76,7 +76,7 @@ TEST(abi_version)
 	const struct landlock_ruleset_attr ruleset_attr = {
 		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
 	};
-	ASSERT_EQ(10, landlock_create_ruleset(NULL, 0,
+	ASSERT_EQ(11, landlock_create_ruleset(NULL, 0,
 					      LANDLOCK_CREATE_RULESET_VERSION));
 
 	ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, 0,
Signature · 1 line
2.54.0
Reviewed-by on v3 7/12
#18 lore raw

Re: [PATCH v3 07/12] landlock: Enforce namespace use restrictions

Quoted 26 lines · Mickaël Salaün

Add Landlock enforcement for namespace use via the LSM namespace_init and namespace_install hooks. This lets a sandboxed process restrict which namespace types it can acquire, using LANDLOCK_PERM_NAMESPACE_USE and per-type rules.

Introduce the handled_perm field in struct landlock_ruleset_attr for per-category permissions: each permission gates all uses of a kernel-defined category (CLONE_NEW* for namespace types, CAP_* for capabilities) and provides complete deny-by-default coverage of category members. Rule values reference constants from other kernel subsystems (CLONE_NEW* for namespaces); unknown values are silently accepted because the allow-list denies them by default. See the "Ruleset restriction models" section in the kernel documentation for the full design rationale.

The new permissions extend the UAPI, so this bumps the Landlock ABI version to 11.

Both hooks share check_ns_type(): if the namespace's CLONE_NEW* type is not in the layer's allowed set, the operation is denied. No domain ancestry bypass, no namespace creator tracking, just a flat per-layer allowed-types bitmask.

- hook_namespace_init() fires during unshare(CLONE_NEW*) and clone(CLONE_NEW*) via __ns_common_init().

Quoted 8 lines

- hook_namespace_install() fires during setns() via validate_ns().

Both record namespace_type and ns_id in the audit data; ns_id is zero at namespace creation.

struct perm_masks is __packed __aligned(sizeof(u64)) because on m68k GCC packs bitfields at byte granularity, so without it a u64 bitfield struct can be smaller than sizeof(u64).

(The reason for forcing u64 is not obvious just from this patch alone, but it makes sense after adding 40 capability bits in the patch following)

Quoted 16 lines

The rule's perm selector must be LANDLOCK_PERM_NAMESPACE_USE and reserves room for future per-rule-type sub-permissions. allowed_namespace_types lists the allowed CLONE_NEW* flags; unknown bits are accepted for forward compatibility and have no effect since the allow-list denies by default.

The rule also carries a quiet_namespace_types bitmask that silences the audit records of specific denied members without granting them. A sandbox that knowingly runs a caller probing a namespace type or capability it will never be granted (e.g. an old runtime kept for compatibility) would otherwise flood the audit log and drown the surprising denials that matter. Quiet is per-member rather than a coarse per-category ruleset bit so a sandbox can silence one member (CLONE_NEWNET) while still auditing another (CLONE_NEWUTS). Making quiet the complement of the allowed set would be broad, could not audit

Quoted 8 lines

a member that is neither allowed nor explicitly quieted, and would auto-hide members added by future kernels. For the same reason a sandbox should quiet only specific members known to be requested but expected to be denied, never a blanket set, which follows the running kernel's known members and hides surprising or future denials. A bit set in both allowed_namespace_types and quiet_namespace_types has no effect, since an allowed member is never denied and its layer can never become the youngest denying layer for that member.

I agree this uAPI makes more sense, having a quiet_perm is a bit wasteful given that the quiet configuration for perms can be determined solely via the struct landlock_namespace_attr.

Quoted 34 lines

The merged filesystem and network quiet feature marks unbounded rb-tree objects (paths, ports) quiet through the LANDLOCK_ADD_RULE_QUIET flag and the ruleset quiet_access_* masks. Capabilities and namespace types are instead a small, bounded, kernel-defined member set, so their quiet list is a per-rule bitmask sibling to the allowed bitmask, and the shared flag is rejected for these rule types. A single add_rule call can allow some members and quiet others independently, and a quiet-only rule (empty allowed set) is valid. Only the youngest denying layer's quiet mask decides, so a parent cannot silence a denial made by a deeper layer.

[...]

include/uapi/linux/landlock.h +17 -0
@@ -268,6 +281,40 @@ struct landlock_net_port_attr {
 	__u64 port;
 };
 
+/**
+ * struct landlock_namespace_attr - Namespace type definition
+ *
+ * Argument of sys_landlock_add_rule() with %LANDLOCK_RULE_NAMESPACE.
+ */
+struct landlock_namespace_attr {
+	/**
+	 * @perm: Must be set to %LANDLOCK_PERM_NAMESPACE_USE.
+	 */
+	__u64 perm;
+	/**
+	 * @allowed_namespace_types: Bitmask of namespace types (``CLONE_NEW*``
+	 * flags) to allow under this rule.  Unknown bits are silently ignored
+	 * for forward compatibility.
+	 */
+	__u64 allowed_namespace_types;
+	/**

include/uapi/linux/landlock.h struct landlock_net_port_attr { · line 310

Quoted 10 lines
include/uapi/linux/landlock.h +10 -0
+	 * @quiet_namespace_types: Bitmask of namespace types (``CLONE_NEW*``
+	 * flags) whose denial by this layer should not be logged, even if
+	 * logging would normally take place per landlock_restrict_self() flags.
+	 * Only denials attributed to this layer are suppressed (see `permission
+	 * flags`_).  Bits also set in @allowed_namespace_types have no effect,
+	 * since an allowed type is never denied.  Unknown bits are silently
+	 * ignored.
+	 *
+	 * At least one of @allowed_namespace_types or @quiet_namespace_types
+	 * must be non-zero, otherwise the call returns ``-ENOMSG``.  The

Worth noting here that if a layer does not want to allow nor quiet any bits it should just not do the landlock_add_rule.

Quoted 16 lines
include/uapi/linux/landlock.h +7 -0
+	 * non-zero check runs on the raw input before unknown-bit masking, so a
+	 * rule that sets only bits unknown to the running kernel succeeds but
+	 * has no runtime effect.
+	 */
+	__u64 quiet_namespace_types;
+};
+
 /**
  * DOC: fs_access
  *
[...]
security/landlock/domain.h +0 -0
index 56cceed5f50c..c2b72795b0d6 100644

security/landlock/domain.h struct landlock_hierarchy { · line 118

Quoted 3 lines
security/landlock/domain.h +0 -0
@@ -116,6 +116,12 @@ struct landlock_hierarchy {
 	 * logged) if the related object is marked as quiet.
 	 */
 	struct access_masks quiet_access;

I'm not sure if this is worth adjusting or mentioning in a comment but basically quiet_access.perm is unused.

security/landlock/domain.h struct landlock_hierarchy { · line 127

Quoted 10 lines
security/landlock/domain.h +6 -0
+	/**
+	 * @quiet_perm: Per-member quiet bitmasks for permission types
+	 * (capabilities and namespace types).  A member denied by this layer is
+	 * not logged when its bit is set here.
+	 */
+	struct perm_masks quiet_perm;
 #endif /* CONFIG_AUDIT */
 };
 
[...]
author maintainer
#19 lore raw

PATCH v3 8/12 landlock: Enforce capability restrictions

In reply to Mickaël Salaün

Add Landlock enforcement for capability use via the LSM capable hook. This lets a sandboxed process restrict which Linux capabilities it can exercise, using LANDLOCK_PERM_CAPABILITY_USE and per-capability rules.

The capable hook is purely restrictive: commoncap is registered with LSM_ORDER_FIRST so cap_capable() always runs first, which means Landlock can deny capabilities that commoncap would allow but never grant capabilities that commoncap denied.

Add hook_capable() that uses landlock_perm_is_denied() to perform a pure bitmask check: if the capability is not in the layer's allowed set, the check is denied. No domain ancestry bypass, no cross-namespace discriminant, just a flat per-layer allowed-caps bitmask, matching the same pattern used by LANDLOCK_PERM_NAMESPACE_USE.

The capability rule attribute mirrors the namespace one: perm selects LANDLOCK_PERM_CAPABILITY_USE, allowed_capabilities lists the allowed CAP_* bits, and quiet_capabilities silences the audit records of specific denied capabilities without granting them. A bit set in both has no effect, since an allowed capability is never denied. The per-member quiet mechanism and its narrow-usage guidance are described in the previous commit, which introduces the shared quiet member mask; here landlock_log_denial() consults the denying layer's mask for the capability recovered from the audit data, and LANDLOCK_ADD_RULE_QUIET stays rejected for this rule type.

The two-permission interaction for non-user namespaces (both LANDLOCK_PERM_NAMESPACE_USE and LANDLOCK_PERM_CAPABILITY_USE must allow) is described in the previous commit.

The enforcement is purely at exercise time via the capable hook, not by modifying the credential's capability sets. Stripping denied capabilities would give processes an accurate capget(2) view of their usable capabilities, but no LSM other than commoncap modifies capability sets; Landlock follows this convention and restricts use without altering what the process holds. A sandboxed process inside a user namespace will see all capabilities via capget(2) but will receive -EPERM when attempting to use any denied capability.

An earlier design tried instead to keep namespace creation independent of capability restriction by bypassing this hook for namespace management operations, via a domain-ancestry comparison against the namespace creator's domain stored in the LSM blob. It was dropped because a Landlock decision should turn on Landlock properties (domain relationships), not on kernel namespace state, and the cross-namespace heuristic (ns != cred->user_ns) did not accurately identify namespace-management operations. With the resulting flat, namespace-agnostic check, capability and namespace restrictions are enforced independently at their own hooks; consequently, creating a non-user namespace needs an allowed CAP_SYS_ADMIN even when combined with CLONE_NEWUSER in a single unshare().

Cc Christian Brauner <[email protected]>
Cc Günther Noack <[email protected]>
Cc Paul Moore <[email protected]>
Cc Serge E. Hallyn <[email protected]>

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Rename the capability rule attribute fields (allowed_perm to perm, capabilities to allowed_capabilities) and add a quiet_capabilities bitmask that suppresses the audit records of specific denied capabilities, consuming the shared per-layer quiet member mask in landlock_log_denial(); the rule attribute grows from 16 to 24 bytes.
- Dropped Reviewed-by: Günther Noack and Tingmao Wang, as this version adds the quiet member mask described above, which their v1 review did not cover. Fresh review welcome.

Changes since v1:
https://patch.msgid.link/[email protected]
- Add Reviewed-by: Tingmao Wang.
- Rename internal struct perm_rules to perm_masks (companion change to the preceding commit).
- Rename LANDLOCK_PERM_NAMESPACE_ENTER references to LANDLOCK_PERM_NAMESPACE_USE (companion change to the introducing commit).
- Rename struct layer_rights to struct layer_config (companion change to the introducing commit).
- Clarify in the commit body and hook_capable() kdoc that commoncap (not Landlock) is registered with LSM_ORDER_FIRST.
- Surface the empty-check semantics in the landlock_capability_attr.capabilities kdoc: a rule that sets only bits unknown to the running kernel (above CAP_LAST_CAP) succeeds but has no runtime effect.
- Add explicit static_assert that LANDLOCK_NUM_PERM_CAP + LANDLOCK_NUM_PERM_NS fits in a u64, complementing the existing implicit sizeof guard on struct perm_masks.
- Add Reviewed-by: Günther Noack.

---
 include/uapi/linux/landlock.h |  47 ++++++++++++
 security/landlock/Makefile    |   3 +-
 security/landlock/access.h    |  18 ++++-
 security/landlock/audit.c     |  10 +++
 security/landlock/audit.h     |   1 +
 security/landlock/cap.c       | 137 ++++++++++++++++++++++++++++++++++
 security/landlock/cap.h       |  50 +++++++++++++
 security/landlock/cred.h      |   3 +
 security/landlock/limits.h    |   4 +-
 security/landlock/setup.c     |   2 +
 security/landlock/syscalls.c  |  80 +++++++++++++++++++-
 11 files changed, 346 insertions(+), 9 deletions(-)
 create mode 100644 security/landlock/cap.c
 create mode 100644 security/landlock/cap.h
include/uapi/linux/landlock.h +47 -0
index 343cb4e0f51a..393dd62fcde1 100644
@@ -228,6 +228,11 @@ enum landlock_rule_type {
 	 * @LANDLOCK_RULE_NAMESPACE: Type of a &struct landlock_namespace_attr .
 	 */
 	LANDLOCK_RULE_NAMESPACE,
+	/**
+	 * @LANDLOCK_RULE_CAPABILITY: Type of a &struct
+	 * landlock_capability_attr .
+	 */
+	LANDLOCK_RULE_CAPABILITY,
 };
 
 /**
@@ -315,6 +320,40 @@ struct landlock_namespace_attr {
 	__u64 quiet_namespace_types;
 };
 
+/**
+ * struct landlock_capability_attr - Capability definition
+ *
+ * Argument of sys_landlock_add_rule() with %LANDLOCK_RULE_CAPABILITY.
+ */
+struct landlock_capability_attr {
+	/**
+	 * @perm: Must be set to %LANDLOCK_PERM_CAPABILITY_USE.
+	 */
+	__u64 perm;
+	/**
+	 * @allowed_capabilities: Bitmask of capabilities (``1ULL << CAP_*``) to
+	 * allow under this rule.  Bits above ``CAP_LAST_CAP`` are silently
+	 * ignored for forward compatibility.
+	 */
+	__u64 allowed_capabilities;
+	/**
+	 * @quiet_capabilities: Bitmask of capabilities (``1ULL << CAP_*``)
+	 * whose denial by this layer should not be logged, even if logging
+	 * would normally take place per landlock_restrict_self() flags.  Only
+	 * denials attributed to this layer are suppressed (see `permission
+	 * flags`_).  Bits also set in @allowed_capabilities have no effect,
+	 * since an allowed capability is never denied.  Bits above
+	 * ``CAP_LAST_CAP`` are silently ignored.
+	 *
+	 * At least one of @allowed_capabilities or @quiet_capabilities must be
+	 * non-zero, otherwise the call returns ``-ENOMSG``.  The non-zero check
+	 * runs on the raw input before unknown-bit masking, so a rule that sets
+	 * only bits unknown to the running kernel (above ``CAP_LAST_CAP``)
+	 * succeeds but has no runtime effect.
+	 */
+	__u64 quiet_capabilities;
+};
+
 /**
  * DOC: fs_access
  *
@@ -566,9 +605,17 @@ struct landlock_namespace_attr {
  *   process in a Landlock domain that handles this permission is denied
  *   from using namespace types that are not explicitly allowed by a
  *   %LANDLOCK_RULE_NAMESPACE rule.
+ * - %LANDLOCK_PERM_CAPABILITY_USE: Restrict the use of specific Linux
+ *   capabilities.  A process in a Landlock domain that handles this
+ *   permission is denied from exercising capabilities that are not
+ *   explicitly allowed by a %LANDLOCK_RULE_CAPABILITY rule.  This hook
+ *   is purely restrictive: it can deny capabilities that the kernel
+ *   would otherwise grant, but it can never grant capabilities that the
+ *   kernel already denied.
  */
 /* clang-format off */
 #define LANDLOCK_PERM_NAMESPACE_USE			(1ULL << 0)
+#define LANDLOCK_PERM_CAPABILITY_USE			(1ULL << 1)
 /* clang-format on */
 
 #endif /* _UAPI_LINUX_LANDLOCK_H */
security/landlock/Makefile +2 -1
index cacfba075dec..1927b81fea93 100644
@@ -9,7 +9,8 @@ landlock-y := \
 	task.o \
 	fs.o \
 	tsync.o \
-	ns.o
+	ns.o \
+	cap.o
 
 landlock-$(CONFIG_INET) += net.o
 
security/landlock/access.h +14 -4
index 9dbacccc9b99..cb456eee8c32 100644
@@ -72,6 +72,13 @@ static_assert(sizeof(typeof_member(union access_masks_all, masks)) ==
  * storage unit.
  */
 struct perm_masks {
+	/**
+	 * @caps: Allowed capabilities.  Each bit corresponds to a ``CAP_*``
+	 * value (e.g. ``CAP_NET_RAW`` = bit 13).  Bits are stored directly
+	 * (sequential mapping) and masked with ``CAP_VALID_MASK`` at rule-add
+	 * time.
+	 */
+	u64 caps : LANDLOCK_NUM_PERM_CAP;
 	/**
 	 * @ns: Allowed namespace types.  Each bit corresponds to a sequential
 	 * index assigned by the ``_LANDLOCK_NS_*`` enum (derived from
@@ -83,6 +90,9 @@ struct perm_masks {
 } __packed __aligned(sizeof(u64));
 
 static_assert(sizeof(struct perm_masks) == sizeof(u64));
+/* All perm_masks bitfields must fit in a single u64. */
+static_assert(LANDLOCK_NUM_PERM_CAP + LANDLOCK_NUM_PERM_NS <=
+	      BITS_PER_TYPE(u64));
 
 /**
  * struct layer_config - Per-layer access configuration
@@ -91,10 +101,10 @@ static_assert(sizeof(struct perm_masks) == sizeof(u64));
  * This is the element type of the &struct landlock_ruleset.layers FAM.
  *
  * Unlike filesystem and network access rights, which are tracked per-object in
- * red-black trees, namespace types use a flat bitmask because their keyspace is
- * small and bounded (~8 namespace types).  A single rule adds to the allowed
- * set via bitwise OR; at enforcement time each layer is checked directly (no
- * tree lookup needed).
+ * red-black trees, namespace types and capabilities use flat bitmasks because
+ * their keyspaces are small and bounded (~8 namespace types, 41 capabilities).
+ * A single rule adds to the allowed set via bitwise OR; at enforcement time
+ * each layer is checked directly (no tree lookup needed).
  */
 struct layer_config {
 	/**
security/landlock/audit.c +10 -0
index dc4716635942..19a8f462678f 100644
@@ -14,6 +14,7 @@
 
 #include "access.h"
 #include "audit.h"
+#include "cap.h"
 #include "common.h"
 #include "cred.h"
 #include "domain.h"
@@ -87,6 +88,10 @@ get_blocker(const enum landlock_request_type type,
 	case LANDLOCK_REQUEST_NAMESPACE:
 		WARN_ON_ONCE(access_bit != -1);
 		return "perm.namespace_use";
+
+	case LANDLOCK_REQUEST_CAPABILITY:
+		WARN_ON_ONCE(access_bit != -1);
+		return "perm.capability_use";
 	}
 
 	WARN_ON_ONCE(1);
@@ -657,6 +662,11 @@ void landlock_log_denial(const struct landlock_cred_security *const subject,
 		 * denying layer's quiet_perm mask.  The member is recovered
 		 * from the audit data recorded by the hook.
 		 */
+		case LANDLOCK_REQUEST_CAPABILITY:
+			quiet_applicable_to_access =
+				!!(youngest_denied->quiet_perm.caps &
+				   landlock_cap_to_bit(request->audit.u.cap));
+			break;
 		case LANDLOCK_REQUEST_NAMESPACE:
 			quiet_applicable_to_access =
 				!!(youngest_denied->quiet_perm.ns &
security/landlock/audit.h +1 -0
index 9dd522b62448..1e00b12d08a7 100644
@@ -22,6 +22,7 @@ enum landlock_request_type {
 	LANDLOCK_REQUEST_SCOPE_ABSTRACT_UNIX_SOCKET,
 	LANDLOCK_REQUEST_SCOPE_SIGNAL,
 	LANDLOCK_REQUEST_NAMESPACE,
+	LANDLOCK_REQUEST_CAPABILITY,
 };
 
 /*
security/landlock/cap.c new file +137 -0

137 lines not on this page · raw message

security/landlock/cap.h new file +50 -0

50 lines not on this page · raw message

security/landlock/cred.h +3 -0
index d6f909b90403..35d6bfac8899 100644
@@ -191,6 +191,9 @@ landlock_perm_is_denied(const struct landlock_ruleset *const domain,
 		case LANDLOCK_PERM_NAMESPACE_USE:
 			allowed = domain->layers[layer].allowed.ns;
 			break;
+		case LANDLOCK_PERM_CAPABILITY_USE:
+			allowed = domain->layers[layer].allowed.caps;
+			break;
 		default:
 			WARN_ONCE(1, "Unknown permission %u\n",
 				  (unsigned int)perm_bit);
security/landlock/limits.h +3 -1
index b7209188fd50..6cdd649005f4 100644
@@ -11,6 +11,7 @@
 #define _SECURITY_LANDLOCK_LIMITS_H
 
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/limits.h>
 #include <linux/ns/ns_common_types.h>
 #include <uapi/linux/landlock.h>
@@ -32,11 +33,12 @@
 #define LANDLOCK_MASK_SCOPE		((LANDLOCK_LAST_SCOPE << 1) - 1)
 #define LANDLOCK_NUM_SCOPE		__const_hweight64(LANDLOCK_MASK_SCOPE)
 
-#define LANDLOCK_LAST_PERM		LANDLOCK_PERM_NAMESPACE_USE
+#define LANDLOCK_LAST_PERM		LANDLOCK_PERM_CAPABILITY_USE
 #define LANDLOCK_MASK_PERM		((LANDLOCK_LAST_PERM << 1) - 1)
 #define LANDLOCK_NUM_PERM		__const_hweight64(LANDLOCK_MASK_PERM)
 
 #define LANDLOCK_NUM_PERM_NS		__const_hweight64((u64)(CLONE_NS_ALL))
+#define LANDLOCK_NUM_PERM_CAP		(CAP_LAST_CAP + 1)
 
 #define LANDLOCK_NUM_ACCESS_MAX \
 	MAX(MAX(LANDLOCK_NUM_ACCESS_FS, LANDLOCK_NUM_ACCESS_NET), LANDLOCK_NUM_SCOPE)
security/landlock/setup.c +2 -0
index a7ed776b41b4..971419d663bb 100644
@@ -11,6 +11,7 @@
 #include <linux/lsm_hooks.h>
 #include <uapi/linux/lsm.h>
 
+#include "cap.h"
 #include "common.h"
 #include "cred.h"
 #include "errata.h"
@@ -70,6 +71,7 @@ static int __init landlock_init(void)
 	landlock_add_fs_hooks();
 	landlock_add_net_hooks();
 	landlock_add_ns_hooks();
+	landlock_add_cap_hooks();
 	landlock_init_id();
 	landlock_initialized = true;
 	pr_info("Up and running.\n");
security/landlock/syscalls.c +77 -3

117 lines not on this page · raw message

Signature · 1 line
2.54.0
author maintainer
#21 lore raw

PATCH v3 9/12 selftests/landlock: Add namespace restriction tests

In reply to Mickaël Salaün

Add tests covering the two namespace-related Landlock permission types:
LANDLOCK_PERM_NAMESPACE_USE (namespace creation via unshare/clone and namespace entry via setns) and its interaction with LANDLOCK_PERM_CAPABILITY_USE.

Rule validation tests verify that the kernel correctly accepts known CLONE_NEW* types, silently accepts unknown bits (including holes, upper-range bits, and bit 63) for forward compatibility, and rejects an empty namespace_types bitmask. Invalid allowed_perm combinations and non-zero flags are also covered. A dedicated test asserts that a rule listing only unknown bits is accepted at rule-add time but has no runtime effect: an actual CLONE_NEW* operation is still denied by deny-by-default once the domain is enforced.

Namespace creation tests use FIXTURE_VARIANT to exercise all eight namespace types (user, UTS, IPC, mount, cgroup, PID, network, time) across allowed/denied and privileged/unprivileged combinations. This verifies that security_namespace_init() is correctly called for every type. Layer stacking tests verify that any-layer-denies semantics work correctly across the three combinations of per-layer allow/deny that exercise distinct walker paths (allow/deny, allow/allow, deny/allow). A combined test exercises both LANDLOCK_PERM_CAPABILITY_USE and LANDLOCK_PERM_NAMESPACE_USE in a single domain.

Namespace entry tests verify that setns is subject to the same type-based LANDLOCK_PERM_NAMESPACE_USE check via security_namespace_install(), including cross-process setns denial and the two-permission interaction where both LANDLOCK_PERM_NAMESPACE_USE and LANDLOCK_PERM_CAPABILITY_USE must allow the operation for non-user namespaces.

Mount-namespace fd-acquisition tests cover the four open_tree(2) and fsmount(2) variants that create a mount namespace:
open_tree(OPEN_TREE_CLONE) and fsmount(FSMOUNT_CLOEXEC) for anonymous namespaces, and open_tree(OPEN_TREE_NAMESPACE) and fsmount(FSMOUNT_NAMESPACE) for new non-anonymous namespaces. All four converge in security_namespace_init() with CLONE_NEWNS and exercise different code paths through alloc_mnt_ns().

A multi-flag unshare test exercises a combined unshare with CLONE_NEWUSER | CLONE_NEWUTS under partial-allow rules, documenting the kernel's atomic behavior: namespace creation is sequential, and a Landlock denial on any type rolls back the whole syscall with EPERM.

Audit tests verify that denied namespace creation, denied setns entry, and allowed operations produce the expected audit records (or none).

Cc Christian Brauner <[email protected]>
Cc Günther Noack <[email protected]>
Cc Paul Moore <[email protected]>
Cc Serge E. Hallyn <[email protected]>

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Rebased for ABI 11 and the renamed namespace rule attribute (perm plus allowed_namespace_types/quiet_namespace_types).
- Add per-member quiet audit tests for the namespace permission:
create_quieted, quiet_is_per_member, allow_and_quiet, allow_and_quiet_same_member (quiet on an allowed member is inert), quiet_youngest_layer_wins, and quiet_parent_only_denying_layer, plus a quiet-only-rule leg in add_rule_bad_attr and the add_ns_rule_full helper.
- Add a positive both-caps mount setns leg (two_perm_mnt_setns_allowed) and the both-perms inverse test two_perm_ns_denied (the capability is allowed but the namespace type is not, so the namespace hook denies).
- Add two_perm_combined_unshare_denied and two_perm_combined_unshare_allowed: combining CLONE_NEWUSER with another type in a single unshare(2) does not exempt the non-user namespace from the capability check, so it still requires an allowed CAP_SYS_ADMIN when the domain handles LANDLOCK_PERM_CAPABILITY_USE.
- Add add_rule_unknown_no_runtime_effect_setns, the install-hook mirror of the creation-hook unknown-bit test.
- Add ns_audit.setns_quieted (a quieted setns denial is still EPERM but unlogged) and ns_audit.quiet_unknown_bit_no_effect (an unknown quiet bit does not suppress a known denial).
- Trim ns_proc_open to two representative types (user and mnt): opening /proc/self/ns/* never reaches a Landlock hook and the path is namespace-type-agnostic, so the other per-type variants added no coverage.

Changes since v1:
https://patch.msgid.link/[email protected]
- Update audit test patterns: namespace_inum replaced by namespace_id.
- Fix user_denied.setns expected error: security_namespace_install() now runs before userns_install(), so Landlock returns EPERM before userns_install() returns EINVAL.
- Rename LANDLOCK_PERM_NAMESPACE_ENTER references to LANDLOCK_PERM_NAMESPACE_USE (companion change to the introducing commit).
- Add ns_proc_open fixture covering all 8 namespace types: verify that open("/proc/self/ns/<type>", O_RDONLY) does not trigger Landlock denial under LANDLOCK_PERM_NAMESPACE_USE. Defensive boundary documentation that the procfs ns/<type> open path is outside the per-category permission's scope; catches future regressions if a hook is misplaced.
- Add ns_mount_fd fixture covering open_tree(OPEN_TREE_CLONE), open_tree(OPEN_TREE_NAMESPACE), fsmount(FSMOUNT_CLOEXEC), and fsmount(FSMOUNT_NAMESPACE) with denied/allowed/unsandboxed variants. All four converge in security_namespace_init() with CLONE_NEWNS but exercise different code paths through alloc_mnt_ns().
- Add ns_create_multi_flag fixture covering a combined unshare with CLONE_NEWUSER | CLONE_NEWUTS under partial-allow rules: documents that any Landlock denial in the sequential namespace creation rolls back the entire syscall with EPERM.
- Reshape setns_cross_process variants: rename allowed to sandboxed_allowed and add an unsandboxed variant, so the fixture now covers denied, sandboxed_allowed, and unsandboxed.
- Add sys_open_tree, sys_fsopen, sys_fsconfig, sys_fsmount syscall wrappers in wrappers.h, and update fs_test.c to use sys_open_tree instead of its local open_tree wrapper.
- Rename comments referencing security_namespace_alloc() and hook_namespace_alloc() to security_namespace_init() and hook_namespace_init() (companion change to the LSM hook rename in the introducing commit).
- Document that setns_cross_process exercises only CLONE_NEWUTS:
the same enforcement applies to every namespace type via the unified hook_namespace_install() helper.
- Add add_rule_unknown_no_runtime_effect: assert that a rule listing only unknown namespace bits is accepted at rule-add time but has no runtime effect, so an actual CLONE_NEW* operation is still denied by deny-by-default once the domain is enforced.
- Add ns_stacking parent_denies variant covering the inverse direction of stacking: layer 1 denies, layer 2 allows, operation still denied. Completes the per-layer walker direction coverage.

---
 tools/testing/selftests/landlock/common.h   |   23 +
 tools/testing/selftests/landlock/config     |    5 +
 tools/testing/selftests/landlock/fs_test.c  |   13 +-
 tools/testing/selftests/landlock/ns_test.c  | 2380 +++++++++++++++++++
 tools/testing/selftests/landlock/wrappers.h |   29 +
 5 files changed, 2440 insertions(+), 10 deletions(-)
 create mode 100644 tools/testing/selftests/landlock/ns_test.c
tools/testing/selftests/landlock/common.h +23 -0
index 7206d5105d66..88c23c1089f8 100644
@@ -130,6 +130,29 @@ static void __maybe_unused clear_ambient_cap(
 	EXPECT_EQ(0, cap_get_ambient(cap));
 }
 
+/*
+ * Returns true if the current process is in the initial user namespace.
+ * Compares the readlink targets of /proc/self/ns/user and /proc/1/ns/user.
+ */
+static bool __maybe_unused is_in_init_user_ns(void)
+{
+	char self_buf[64], init_buf[64];
+	ssize_t self_len, init_len;
+
+	self_len = readlink("/proc/self/ns/user", self_buf, sizeof(self_buf));
+	if (self_len <= 0 || self_len >= (ssize_t)sizeof(self_buf))
+		return false;
+
+	init_len = readlink("/proc/1/ns/user", init_buf, sizeof(init_buf));
+	if (init_len <= 0 || init_len >= (ssize_t)sizeof(init_buf))
+		return false;
+
+	if (self_len != init_len)
+		return false;
+
+	return memcmp(self_buf, init_buf, self_len) == 0;
+}
+
 /* Receives an FD from a UNIX socket. Returns the received FD, or -errno. */
 static int __maybe_unused recv_fd(int usock)
 {
tools/testing/selftests/landlock/config +5 -0
index 8fe9b461b1fd..d09b637bf6ca 100644
@@ -3,6 +3,7 @@ CONFIG_AUDIT=y
 CONFIG_CGROUPS=y
 CONFIG_CGROUP_SCHED=y
 CONFIG_INET=y
+CONFIG_IPC_NS=y
 CONFIG_IPV6=y
 CONFIG_KEYS=y
 CONFIG_MPTCP=y
@@ -10,10 +11,14 @@ CONFIG_MPTCP_IPV6=y
 CONFIG_NET=y
 CONFIG_NET_NS=y
 CONFIG_OVERLAY_FS=y
+CONFIG_PID_NS=y
 CONFIG_PROC_FS=y
 CONFIG_SECURITY=y
 CONFIG_SECURITY_LANDLOCK=y
 CONFIG_SHMEM=y
 CONFIG_SYSFS=y
+CONFIG_TIME_NS=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_XATTR=y
+CONFIG_USER_NS=y
+CONFIG_UTS_NS=y
tools/testing/selftests/landlock/fs_test.c +3 -10
index 86e08aa6e0a7..5f7023658a79 100644
@@ -54,13 +54,6 @@ int renameat2(int olddirfd, const char *oldpath, int newdirfd,
 }
 #endif
 
-#ifndef open_tree
-int open_tree(int dfd, const char *filename, unsigned int flags)
-{
-	return syscall(__NR_open_tree, dfd, filename, flags);
-}
-#endif
-
 static int sys_execveat(int dirfd, const char *pathname, char *const argv[],
 			char *const envp[], int flags)
 {
@@ -2454,9 +2447,9 @@ TEST_F_FORK(layout1, refer_mount_root_deny)
 
 	/* Creates a mount object from a non-mount point. */
 	set_cap(_metadata, CAP_SYS_ADMIN);
-	root_fd =
-		open_tree(AT_FDCWD, dir_s1d1,
-			  AT_EMPTY_PATH | OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	root_fd = sys_open_tree(AT_FDCWD, dir_s1d1,
+				AT_EMPTY_PATH | OPEN_TREE_CLONE |
+					OPEN_TREE_CLOEXEC);
 	clear_cap(_metadata, CAP_SYS_ADMIN);
 	ASSERT_LE(0, root_fd);
 
tools/testing/selftests/landlock/ns_test.c new file +2380 -0

2,380 lines not on this page · raw message

tools/testing/selftests/landlock/wrappers.h +29 -0
index 65548323e45d..e6fe46b7c2cc 100644
@@ -9,6 +9,7 @@
 
 #define _GNU_SOURCE
 #include <linux/landlock.h>
+#include <linux/sched.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -45,3 +46,31 @@ static inline pid_t sys_gettid(void)
 {
 	return syscall(__NR_gettid);
 }
+
+static inline pid_t sys_clone3(struct clone_args *args, size_t size)
+{
+	return syscall(__NR_clone3, args, size);
+}
+
+static inline int sys_open_tree(int dfd, const char *filename,
+				unsigned int flags)
+{
+	return syscall(__NR_open_tree, dfd, filename, flags);
+}
+
+static inline int sys_fsopen(const char *fsname, unsigned int flags)
+{
+	return syscall(__NR_fsopen, fsname, flags);
+}
+
+static inline int sys_fsconfig(int fs_fd, unsigned int cmd, const char *key,
+			       const void *value, int aux)
+{
+	return syscall(__NR_fsconfig, fs_fd, cmd, key, value, aux);
+}
+
+static inline int sys_fsmount(int fs_fd, unsigned int flags,
+			      unsigned int attr_flags)
+{
+	return syscall(__NR_fsmount, fs_fd, flags, attr_flags);
+}
Signature · 1 line
2.54.0
author maintainer
#22 lore raw

PATCH v3 10/12 selftests/landlock: Add capability restriction tests

In reply to Mickaël Salaün

Add tests to exercise LANDLOCK_PERM_CAPABILITY_USE enforcement. A sandboxed process is denied a handled capability when no rule grants it, and an explicit rule restores the capability. Unknown capability values above CAP_LAST_CAP are silently accepted at rule-add time but have no runtime effect, so deny-by-default still applies once the domain is enforced. Stacking variants cover the three per-layer combinations that exercise distinct walker paths (allow/deny, allow/allow, deny/allow) plus a mixed-layer case where one layer does not handle LANDLOCK_PERM_CAPABILITY_USE, forcing the walker to skip it. Invalid rule attributes (unknown flags, out-of-range values) return the expected errors.

Two tests exercise non-standard capability gain paths. The first enforces a domain via CAP_SYS_ADMIN (no_new_privs is not set) and verifies that denied capabilities are blocked even when still in the effective set. The second creates a user namespace under a Landlock domain to verify that capabilities gained through the kernel's user namespace ownership bypass (cap_capable_helper) are still restricted by the domain's rules.

Audit tests verify that a denied capability produces the expected audit record with the capability number, and that an allowed capability generates no denial record.

Test coverage for security/landlock is 92.1% of 2543 lines according to LLVM 22.

Cc Christian Brauner <[email protected]>
Cc Günther Noack <[email protected]>
Cc Paul Moore <[email protected]>
Cc Serge E. Hallyn <[email protected]>

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Rebased for ABI 11 and the renamed capability rule attribute (perm plus allowed_capabilities/quiet_capabilities).
- Add per-member quiet audit tests for the capability permission:
cap_audit.quieted, plus quiet-only and allow+quiet legs in add_rule_bad_attr and the add_cap_rule_full helper.
- add_rule_bad_attr: drop the dead quiet_capabilities reset after the allow+quiet rule and reset it explicitly where the following rule needs an allow-only attr, clarifying intent.
- Strengthen the audit tests with positive controls: cap_audit.quieted and cap_audit.noaudit_probe_not_logged now also assert that a normal (non-quiet, non-noaudit) capability denial in the same domain IS logged, proving suppression is not global. cap_audit.quieted also asserts the quieted capability is still denied (EPERM), not merely unlogged.
- Add cap_audit.quiet_unknown_bit_no_effect (an unknown quiet bit does not suppress a known capability denial).

Changes since v1:
https://patch.msgid.link/[email protected]
- Reflow comments after check-linux.sh comment fixes.
- Rename LANDLOCK_PERM_NAMESPACE_ENTER references to LANDLOCK_PERM_NAMESPACE_USE and bump the abi_version expectation to 11 (companion changes to the introducing commit).
- Add add_rule_unknown_no_runtime_effect: assert that a rule listing only unknown capability bits is accepted at rule-add time but has no runtime effect, so an actual CAP_* exercise (sethostname with CAP_SYS_ADMIN) is still denied by deny-by-default once the domain is enforced.
- Add cap_stacking parent_denies variant covering the inverse direction of stacking: layer 1 denies CAP_SYS_ADMIN, layer 2 allows, capability still denied. Completes the per-layer walker direction coverage.
- Assert records.domain == 0 in cap_audit.allowed so the test also checks that no domain-allocation record is emitted when nothing is denied.

---
 tools/testing/selftests/landlock/base_test.c |  18 +
 tools/testing/selftests/landlock/cap_test.c  | 889 +++++++++++++++++++
 2 files changed, 907 insertions(+)
 create mode 100644 tools/testing/selftests/landlock/cap_test.c
tools/testing/selftests/landlock/base_test.c +18 -0
index b8b5fa1042ba..bcb5bdafd9ed 100644
@@ -142,6 +142,24 @@ TEST(errata)
 	ASSERT_EQ(EINVAL, errno);
 }
 
+#define PERM_LAST LANDLOCK_PERM_CAPABILITY_USE
+
+TEST(ruleset_with_unknown_perm)
+{
+	__u64 perm_mask;
+
+	for (perm_mask = 1ULL << 63; perm_mask != PERM_LAST; perm_mask >>= 1) {
+		struct landlock_ruleset_attr ruleset_attr = {
+			.handled_perm = perm_mask,
+		};
+
+		/* Unknown handled_perm values must be rejected. */
+		ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr,
+						      sizeof(ruleset_attr), 0));
+		ASSERT_EQ(EINVAL, errno);
+	}
+}
+
 /* Tests ordering of syscall argument checks. */
 TEST(create_ruleset_checks_ordering)
 {
tools/testing/selftests/landlock/cap_test.c new file +889 -0

889 lines not on this page · raw message

Signature · 1 line
2.54.0
author maintainer
#23 lore raw

PATCH v3 11/12 samples/landlock: Add capability and namespace restriction support

In reply to Mickaël Salaün

Extend the sandboxer sample to demonstrate the new Landlock capability and namespace restriction features. The LL_CAP environment variable takes a colon-delimited list of allowed capabilities, parsed with cap_from_name(3) from libcap. Names (e.g. "cap_sys_chroot", "CAP_SYS_ADMIN") are accepted; numeric strings (e.g. "18") work too via cap_from_name's internal numeric fallback. The LL_NS variable takes a colon-delimited list of allowed namespace types by short name (e.g. "user:uts:net"). Add best-effort degradation for older kernels that predate the LANDLOCK_PERM_* features.

Allow creating user and UTS namespaces but deny network namespaces (works as an unprivileged user). All capabilities are available (LL_CAP is not set), but namespace creation is still restricted to the types listed in LL_NS. The first command succeeds because user and UTS types are in the allowed set, and sets the hostname inside the new UTS namespace. The second command fails because the network namespace type is not allowed by the LANDLOCK_PERM_NAMESPACE_USE rule:

  LL_FS_RO=/ LL_FS_RW=/proc LL_NS="user:uts" \
    ./sandboxer /bin/sh -c \
    "unshare --user --uts --map-root-user hostname sandbox \
    && ! unshare --user --net true"

Allow only user namespace creation and CAP_SYS_CHROOT, denying all other capabilities and namespace types (works as an unprivileged user). An unprivileged process creates a user namespace (no capability required) and calls chroot inside it using the CAP_SYS_CHROOT granted within the new namespace:

  LL_FS_RO=/ LL_FS_RW="" LL_NS="user" LL_CAP="cap_sys_chroot" \
    ./sandboxer /bin/sh -c \
    "unshare --user --keep-caps chroot / true"

Allow user namespace creation but deny network namespaces, and quiet the network-namespace denials with LL_NS_QUIET so the denied creation is not logged (works as an unprivileged user). Creating the user namespace succeeds while creating the network namespace is denied, so the negated second command makes the whole line succeed:

  LL_FS_RO=/ LL_FS_RW=/proc LL_NS="user" LL_NS_QUIET="net" \
    ./sandboxer /bin/sh -c \
    "unshare --user --map-root-user true && ! unshare --user --net true"
Cc Christian Brauner <[email protected]>
Cc Günther Noack <[email protected]>
Cc Paul Moore <[email protected]>
Cc Serge E. Hallyn <[email protected]>
Cc Tingmao Wang <[email protected]>

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Rebased for ABI 11: bump LANDLOCK_ABI_LAST to 11 and extend the ABI back-compat fall-through with a new case stripping the LANDLOCK_PERM_* handled bits for ABI < 11.
- Adopt the renamed capability and namespace rule attributes: the rule bodies use perm plus allowed_capabilities / allowed_namespace_types (matching the per-member quiet restructuring in the enforcement patches).
- Add LL_CAP_QUIET and LL_NS_QUIET to quiet capability and namespace-type denials (per-member, merged into the allowed rule).

Changes since v1:
https://patch.msgid.link/[email protected]
- Rename LANDLOCK_PERM_NAMESPACE_ENTER references to LANDLOCK_PERM_NAMESPACE_USE (companion change to the introducing commit).
- Replace handled_perm = 0 with a per-bit mask in the ABI compat fall-through, mirroring the doc example so future ABI extensions adding new LANDLOCK_PERM_* bits do not get stripped.
- Parse LL_CAP values with cap_from_name(3) from libcap so users can pass capability names (e.g. "cap_sys_chroot") in addition to numbers. cap_from_name accepts both: the canonical name lookup is case-insensitive, and a numeric-string fallback maps "18" to CAP_SYS_CHROOT identically to the previous numeric-only path. Drop the BITS_PER_TYPE workaround and the manual numeric bound check (cap_from_name does the right thing in both cases). Link the sandboxer against libcap by adding userldlibs += -lcap in samples/landlock/Makefile. Update help text and example command to show capability names (suggested by Günther Noack).
- Rename the LL_CAPS env var to LL_CAP for consistency with the singular form of all other sandboxer env vars (LL_NS, LL_FS_RO, LL_FS_RW, LL_TCP_BIND, LL_TCP_CONNECT, LL_SCOPED, LL_FORCE_LOG). Internal symbols renamed accordingly: ENV_CAPS_NAME -> ENV_CAP_NAME, populate_ruleset_caps() -> populate_ruleset_cap().
- Tingmao Wang's v1 Reviewed-by is not carried forward to v2: the cap_from_name() / libcap migration is a material implementation change requested by Günther Noack that was not part of his review. Cc'd instead.

---
 samples/landlock/Makefile    |   1 +
 samples/landlock/sandboxer.c | 200 ++++++++++++++++++++++++++++++++++-
 2 files changed, 198 insertions(+), 3 deletions(-)
samples/landlock/Makefile +1 -0
index 5d601e51c2eb..b30239c8a281 100644
@@ -3,6 +3,7 @@
 userprogs-always-y := sandboxer
 
 userccflags += -I usr/include
+userldlibs += -lcap
 
 .PHONY: all clean
 
samples/landlock/sandboxer.c +197 -3

268 lines not on this page · raw message

Signature · 1 line
2.54.0
author maintainer
#24 lore raw

PATCH v3 12/12 landlock: Add documentation for capability and namespace restrictions

In reply to Mickaël Salaün

Document the two new Landlock permission categories in the userspace API guide, admin guide, and kernel security documentation.

The userspace API guide adds sections on capability restriction (LANDLOCK_PERM_CAPABILITY_USE with LANDLOCK_RULE_CAPABILITY) and namespace restriction (LANDLOCK_PERM_NAMESPACE_USE with LANDLOCK_RULE_NAMESPACE, covering creation, entry, and fd-reference acquisition), the backward-compatible degradation pattern for Landlock ABI < 11, and the per-namespace-type capability requirements.

The admin guide adds the new perm.namespace_use and perm.capability_use audit blocker names with their object identification fields (namespace_type, namespace_id, capability).

The kernel security documentation adds a "Ruleset restriction models" section defining the three models (handled_access_*, handled_perm, scoped), their coverage and compatibility properties, and the criteria for choosing between them for future features. It also documents composability with user namespaces and adds kernel-doc references for the new capability and namespace headers.

Cc Christian Brauner <[email protected]>
Cc Günther Noack <[email protected]>
Cc Paul Moore <[email protected]>
Cc Serge E. Hallyn <[email protected]>

---

Changes since v2:
https://patch.msgid.link/[email protected]
- Fix the CAP_BPF forward-compatibility example in Documentation/security/landlock.rst: rules allow-list, so describe a rule *allowing* CAP_SYS_ADMIN continuing to allow operations now gated by CAP_SYS_ADMIN || CAP_BPF (was worded as a rule "denying"; suggested by Günther Noack).
- Drop the "category" jargon from the Capability rules and Namespace rules summaries in Documentation/userspace-api/landlock.rst and add capabilities(7) / namespaces(7) cross-references there, in the rule examples, and in the ABI restriction sections (suggested by Günther Noack).
- Reword LANDLOCK_PERM_NAMESPACE_USE as gating "acquisition of access to namespaces" (was "acquisition of namespace associations") and "allow using" (was "allow entering") specific namespace types, to match the _USE semantics covering creation, entry, and fd-reference (suggested by Günther Noack).
- Document the per-member audit quieting for the new permissions in the Capability and namespace restrictions section: the quiet_capabilities and quiet_namespace_types rule fields suppress the audit records of specific denied members (independently of the allowed members), require the permission to be handled, are member-granular, and should quiet only known-expected members, never a blanket set.
- Documentation/security/landlock.rst prose polish (suggested by Günther Noack):
hyphenate "user-namespace-based"; reword the design-philosophy operation-set sentence; add an introductory paragraph to "Ruleset restriction models" (the ruleset denies by default, rules allow-list exceptions); split the per-object and per-category sections into shorter paragraphs and lead the per-category one with "Each LANDLOCK_PERM_* flag maps to its own rule type"; reframe the per-object new-operation/new-object-type text around object type (was "rule type") and tighten it.
- State the combined deny-by-default explicitly in Documentation/userspace-api/landlock.rst: when a domain handles both permissions, an operation is allowed only if each independently allows it (e.g. unshare(CLONE_NEWNET) needs both CLONE_NEWNET and CAP_SYS_ADMIN allowed).
- Note that the open_tree(OPEN_TREE_CLONE) / move_mount anonymous-mount bypass path requires CAP_SYS_ADMIN (typically obtained by first creating a user namespace).
- Add a concrete downstream-operations example to the per-category model in Documentation/security/landlock.rst (denying CAP_SYS_ADMIN blocks all admin operations such as mounts).
- Document that creating a non-user namespace always requires CAP_SYS_ADMIN, so when the domain handles LANDLOCK_PERM_CAPABILITY_USE a rule allowing CAP_SYS_ADMIN is needed even when CLONE_NEWUSER is combined in the same unshare() call; only user namespace creation needs no capability rule.

Changes since v1:
https://patch.msgid.link/[email protected]

The userspace API and security guides were revamped to match the v2 permission model: the previous chokepoints/gateways prose is replaced with the per-object (handled_access_*) versus per-category (handled_perm) framing, and a new Design philosophy section in the security guide states Landlock's principle (data, processes, kernel resources).

- Rename namespace_inum to namespace_id in audit field documentation to match the renamed audit field.
- Rename LANDLOCK_PERM_NAMESPACE_ENTER references to LANDLOCK_PERM_NAMESPACE_USE (companion change to the introducing commit), and enumerate the seven kernel paths it gates in the userspace API guide (membership via unshare/clone/clone3/setns; fd reference via open_tree/fsmount).
- Clarify that LANDLOCK_PERM_NAMESPACE_USE gates *acquisition* of namespace associations only (namespaces the process is already a member of when the domain is enforced are implicitly allowed) and that LANDLOCK_PERM_CAPABILITY_USE gates every exercise of a capability after the domain is enforced, regardless of how the capability was obtained.
- Document the rationale for accepting (rather than rejecting) unknown category member values in rule bodies: rejection would tie Landlock policy semantics to the running kernel's category-member set, making cross-kernel policies brittle. Acceptance is fail-safe in both directions and lets a policy activate as written when a value becomes real on a future kernel.
- Replace handled_perm = 0 with a per-bit mask in the userspace API guide's ABI compat fall-through, so future ABI extensions adding new LANDLOCK_PERM_* bits do not get stripped on the path that drops the v10 bits.
- Add a bridging sentence in the per-category permissions section of Documentation/security/landlock.rst contrasting per-category permissions with per-object access rights: per-category gates the prerequisite operation itself rather than restricting specific operations on a single resource instance (suggested by Günther Noack).
- Disambiguate the orthogonality invariant in Documentation/security/landlock.rst from the UAPI scoped field ("all new scoped features" -> "all Landlock access controls"; suggested by Justin Suess).
- Add an introductory paragraph in Documentation/userspace-api/landlock.rst contrasting LANDLOCK_PERM_CAPABILITY_USE with PR_SET_NO_NEW_PRIVS: NNP is the broader mechanism that blocks privilege acquisition via execve(2), while CAPABILITY_USE restricts the exercise of capabilities the process already holds (including those gained via CLONE_NEWUSER, which NNP does not block); sandboxes typically set both (suggested by Justin Suess).
- Disambiguate "category": object-side uses "object type" / "resource kind"; "category" stays for the per-category permissions model.

---
 Documentation/admin-guide/LSM/landlock.rst |  19 +-
 Documentation/security/landlock.rst        | 173 ++++++++++++++-
 Documentation/userspace-api/landlock.rst   | 236 +++++++++++++++++++--
 3 files changed, 410 insertions(+), 18 deletions(-)
Documentation/admin-guide/LSM/landlock.rst +15 -4
index 314052bbeb0a..8d3b20a72f20 100644
@@ -6,7 +6,7 @@ Landlock: system-wide management
 ================================
 
 :Author: Mickaël Salaün
-:Date: June 2026
+:Date: July 2026
 
 Landlock can leverage the audit framework to log events.
 
@@ -63,14 +63,25 @@ AUDIT_LANDLOCK_ACCESS
         - scope.abstract_unix_socket - Abstract UNIX socket connection denied
         - scope.signal - Signal sending denied
 
+    **perm.*** - Permission restrictions (ABI 11+):
+        - perm.namespace_use - Namespace entry was denied (creation via
+          :manpage:`unshare(2)` / :manpage:`clone(2)` or joining via
+          :manpage:`setns(2)`);
+          ``namespace_type`` indicates the type (hex CLONE_NEW* bitmask),
+          ``namespace_id`` identifies the target namespace for
+          :manpage:`setns(2)` operations
+        - perm.capability_use - Capability use was denied;
+          ``capability`` indicates the capability number
+
     Multiple blockers can appear in a single event (comma-separated) when
     multiple access rights are missing. For example, creating a regular file
     in a directory that lacks both ``make_reg`` and ``refer`` rights would show
     ``blockers=fs.make_reg,fs.refer``.
 
-    The object identification fields (path, dev, ino for filesystem; opid,
-    ocomm for signals) depend on the type of access being blocked and provide
-    context about what resource was involved in the denial.
+    The object identification fields depend on the type of access being blocked:
+    ``path``, ``dev``, ``ino`` for filesystem; ``opid``, ``ocomm`` for signals;
+    ``namespace_type`` and ``namespace_id`` for namespace operations;
+    ``capability`` for capability use.
 
 
 AUDIT_LANDLOCK_DOMAIN
Documentation/security/landlock.rst +172 -1

191 lines not on this page · raw message

Documentation/userspace-api/landlock.rst +223 -13

298 lines not on this page · raw message

Signature · 1 line
2.54.0