summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:11:11 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:11:11 -0800
commiteef2bc5a82c25d25c3082f5d86d97a300caeb678 (patch)
tree5447c7107ee4e05eeaeb29bc4465ccecb5f222de /include
parentf802b6558eb81bd5888d761a0cdc8afe5fd8c941 (diff)
parent4feb6879b9ab42cacb905f27a44160b7f1f49d85 (diff)
Merge tag 'landlock-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux
Pull Landlock fixes from Mickaël Salaün: - prevent composed rulesets from denying link and rename operations that each ruleset allows separately; - close capability-mediation gaps for low-address mappings, inheritable capabilities, the admin memory reserve, and PR_SET_SECUREBITS, so LSM capability denials apply consistently; - distinguish namespace creation from entry in denial records and expose the checked capability context to BPF tracepoint consumers, so they can interpret denials correctly. * tag 'landlock-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux: landlock: Add missing EINVAL case in the doc for landlock_add_rule clang-format: Fix formatting of guard() landlock: Document namespace denial operations selftests/landlock: Test namespace denial operations landlock: Add capability objects to denial tracing landlock: Distinguish namespace creation and entry denials selftests/landlock: Test PR_SET_SECUREBITS mediation capabilities: Check PR_SET_SECUREBITS with ns_capable() landlock: Fix capability restriction documentation selftests/landlock: Test capability checks outside the capable hook landlock: Mediate CAP_SYS_ADMIN for the admin memory reserve landlock: Mediate CAP_SETPCAP for inheritable capabilities landlock: Mediate CAP_SYS_RAWIO for mappings below mmap_min_addr landlock: Factor out capability denial checks landlock: Clarify implicit handling of LANDLOCK_ACCESS_FS_REFER landlock: Simplify landlock_get_fs_access_mask() selftests/landlock: Test that layering does not break refer landlock: Add KUnit test for landlock_get_fs_access_mask() landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER
Diffstat (limited to 'include')
-rw-r--r--include/trace/events/landlock.h36
-rw-r--r--include/uapi/linux/landlock.h24
2 files changed, 37 insertions, 23 deletions
diff --git a/include/trace/events/landlock.h b/include/trace/events/landlock.h
index b6fdc6e2eef8..09e90e4a9cd7 100644
--- a/include/trace/events/landlock.h
+++ b/include/trace/events/landlock.h
@@ -21,6 +21,7 @@
#include <net/af_unix.h>
enum landlock_request_type;
+struct cred;
struct dentry;
struct landlock_blockers;
struct landlock_domain;
@@ -30,13 +31,15 @@ struct landlock_ruleset;
struct path;
struct sock;
struct task_struct;
+struct user_namespace;
static_assert(sizeof(access_mask_t) <= sizeof(u64));
TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_FS_CHANGE_TOPOLOGY);
TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_FS_ACCESS);
TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_NET_ACCESS);
-TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_NAMESPACE);
+TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_NAMESPACE_CREATE);
+TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_NAMESPACE_ENTER);
TRACE_DEFINE_ENUM(LANDLOCK_REQUEST_CAPABILITY);
#ifdef CREATE_TRACE_POINTS
@@ -990,7 +993,8 @@ TRACE_EVENT(landlock_deny_access_net,
* @namespace_id: Namespace ID, not directly visible from user space when
* creation was denied.
*
- * Emitted when a Landlock domain denies namespace use.
+ * Emitted when a Landlock domain denies namespace creation or entry. The
+ * namespace_op field distinguishes these operations.
*/
TRACE_EVENT(landlock_deny_permission_namespace,
@@ -1021,13 +1025,18 @@ TRACE_EVENT(landlock_deny_permission_namespace,
__entry->namespace_id = namespace_id;
),
- TP_printk("domain=%llx same_exec=%d logged=%d blockers=%s namespace_type=0x%x namespace_id=%llu",
- __entry->domain_id, __entry->same_exec, __entry->logged,
- __entry->blockers_type == LANDLOCK_REQUEST_NAMESPACE ?
- __print_flags(__entry->blockers_access, "|",
- _LANDLOCK_PERMISSION_BLOCKER_NAMES) :
- "unknown",
- __entry->namespace_type, __entry->namespace_id)
+ TP_printk("domain=%llx same_exec=%d logged=%d blockers=%s namespace_op=%s namespace_type=0x%x namespace_id=%llu",
+ __entry->domain_id, __entry->same_exec, __entry->logged,
+ (__entry->blockers_type == LANDLOCK_REQUEST_NAMESPACE_CREATE ||
+ __entry->blockers_type == LANDLOCK_REQUEST_NAMESPACE_ENTER) ?
+ __print_flags(__entry->blockers_access, "|",
+ _LANDLOCK_PERMISSION_BLOCKER_NAMES) :
+ "unknown",
+ __entry->blockers_type == LANDLOCK_REQUEST_NAMESPACE_CREATE ?
+ "create" :
+ __entry->blockers_type == LANDLOCK_REQUEST_NAMESPACE_ENTER ?
+ "enter" : "unknown",
+ __entry->namespace_type, __entry->namespace_id)
);
/**
@@ -1039,6 +1048,9 @@ TRACE_EVENT(landlock_deny_permission_namespace,
* @logged: Whether this denial was selected for audit logging.
* @blockers: Request type and final missing permission subset (never NULL).
* @capability: CAP_* number that was denied.
+ * @cred: Credentials used by commoncap's capability check (never NULL).
+ * @user_ns: Target user namespace used by commoncap's capability check (never
+ * NULL).
*
* Emitted when a Landlock domain denies capability use, except for checks
* made with CAP_OPT_NOAUDIT, which are denied without emitting this event.
@@ -1047,9 +1059,11 @@ TRACE_EVENT(landlock_deny_permission_capability,
TP_PROTO(const struct landlock_hierarchy *hierarchy, bool same_exec,
bool logged, const struct landlock_blockers *blockers,
- int capability),
+ int capability, const struct cred *cred,
+ const struct user_namespace *user_ns),
- TP_ARGS(hierarchy, same_exec, logged, blockers, capability),
+ TP_ARGS(hierarchy, same_exec, logged, blockers, capability, cred,
+ user_ns),
TP_STRUCT__entry(
__field( u64, domain_id )
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index 24510e5d8479..8ce0406ba543 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h
@@ -22,10 +22,10 @@
* enacted. Vice versa, access rights that are not specifically listed here are
* not going to be denied by this ruleset when it is enacted.
*
- * For historical reasons, the %LANDLOCK_ACCESS_FS_REFER right is always denied
- * by default, even when its bit is not set in @handled_access_fs. In order to
- * add new rules with this access right, the bit must still be set explicitly
- * (cf. `Filesystem flags`_).
+ * For historical reasons, as soon as any filesystem access right is handled in
+ * @handled_access_fs, the %LANDLOCK_ACCESS_FS_REFER right is always denied as
+ * well. In order to add new rules with this access right, the bit must still
+ * be set explicitly (cf. `Filesystem flags`_).
*
* The explicit listing of *handled access rights* is required for backwards
* compatibility reasons. In most use cases, processes that use Landlock will
@@ -462,10 +462,11 @@ struct landlock_capability_attr {
* This access right is available since the second version of the Landlock
* ABI.
*
- * This is the only access right which is denied by default by any ruleset,
- * even if the right is not specified as handled at ruleset creation time.
- * The only way to make a ruleset grant this right is to explicitly allow it
- * for a specific directory by adding a matching rule to the ruleset.
+ * This is the only access right which is denied by default by any ruleset
+ * that handles filesystem access rights, even if the right is not specified
+ * as handled at ruleset creation time. The only way to make a ruleset grant
+ * this right is to explicitly allow it for a specific directory by adding a
+ * matching rule to the ruleset.
*
* In particular, when using the first Landlock ABI version, Landlock will
* always deny attempts to reparent files between different directories.
@@ -622,10 +623,9 @@ struct landlock_capability_attr {
* - %LANDLOCK_PERMISSION_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. Support added in
- * Landlock ABI version 12.
+ * %LANDLOCK_RULE_CAPABILITY rule. Landlock only reduces the capabilities
+ * that processes can use: it does not let them use capabilities that they
+ * would not have without Landlock. Support added in Landlock ABI version 12.
*/
#define LANDLOCK_PERMISSION_NAMESPACE_USE (1ULL << 0)
#define LANDLOCK_PERMISSION_CAPABILITY_USE (1ULL << 1)