[PATCH 6/6] landlock: Document POSIX message queue scoping
From: Oxana Kharitonova <hidden>
Date: 2026-07-22 12:30:12
Also in:
lkml
Subsystem:
documentation, landlock security module, the rest · Maintainers:
Jonathan Corbet, Mickaël Salaün, Linus Torvalds
Document LANDLOCK_SCOPE_POSIX_MSG_QUEUE in the userspace API and UAPI kernel-doc. Signed-off-by: Oxana Kharitonova <redacted> --- Documentation/admin-guide/LSM/landlock.rst | 6 ++++-- Documentation/userspace-api/landlock.rst | 11 ++++++++++- include/uapi/linux/landlock.h | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/Documentation/admin-guide/LSM/landlock.rst b/Documentation/admin-guide/LSM/landlock.rst
index 8eb85c9381ff..1ecb2017271b 100644
--- a/Documentation/admin-guide/LSM/landlock.rst
+++ b/Documentation/admin-guide/LSM/landlock.rst@@ -60,9 +60,11 @@ AUDIT_LANDLOCK_ACCESS - net.bind_udp - UDP port binding was denied - net.connect_send_udp - UDP connection and send was denied - **scope.*** - IPC scoping restrictions (ABI 6+): + **scope.*** - IPC scoping restrictions: - scope.abstract_unix_socket - Abstract UNIX socket connection denied - - scope.signal - Signal sending denied + (ABI 6+) + - scope.signal - Signal sending denied (ABI 6+) + - scope.posix_msg_queue - POSIX message queue opening denied (ABI 11+) Multiple blockers can appear in a single event (comma-separated) when multiple access rights are missing. For example, creating a regular file
diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst
index 5a63d4476c1c..c4fa84e6d281 100644
--- a/Documentation/userspace-api/landlock.rst
+++ b/Documentation/userspace-api/landlock.rst@@ -86,7 +86,8 @@ to be explicit about the denied-by-default access rights. LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP, .scoped = LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET | - LANDLOCK_SCOPE_SIGNAL, + LANDLOCK_SCOPE_SIGNAL | + LANDLOCK_SCOPE_POSIX_MSG_QUEUE, }; Because we may not know which kernel version an application will be executed
@@ -140,6 +141,10 @@ version, and only use the available subset of access rights: ruleset_attr.handled_access_net &= ~(LANDLOCK_ACCESS_NET_BIND_UDP | LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP); + __attribute__((fallthrough)); + case 10: + /* Removes LANDLOCK_SCOPE_POSIX_MSG_QUEUE for ABI < 11 */ + ruleset_attr.scoped &= ~LANDLOCK_SCOPE_POSIX_MSG_QUEUE; } This enables the creation of an inclusive ruleset that will contain our rules.
@@ -420,6 +425,10 @@ The operations which can be scoped are: A :manpage:`sendto(2)` on a socket which was previously connected will not be restricted. This works for both datagram and stream sockets. +``LANDLOCK_SCOPE_POSIX_MSG_QUEUE`` + This limits opening POSIX message queues to queues created by a process in + the same or a nested Landlock domain. + IPC scoping does not support exceptions via :manpage:`landlock_add_rule(2)`. If an operation is scoped within a domain, no rules can be added to allow access to resources or processes outside of the scope.
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index 96d0c3b423ac..21ba31ad4d4b 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h@@ -478,7 +478,9 @@ struct landlock_net_port_attr { * Setting a flag for a ruleset will isolate the Landlock domain to forbid * connections to resources outside the domain. * - * This is supported since Landlock ABI version 6. + * This is supported since Landlock ABI version 6. The + * %LANDLOCK_SCOPE_POSIX_MSG_QUEUE scope is supported since Landlock ABI version + * 11. * * Scopes: *
@@ -487,6 +489,8 @@ struct landlock_net_port_attr { * related Landlock domain (e.g., a parent domain or a non-sandboxed process). * - %LANDLOCK_SCOPE_SIGNAL: Restrict a sandboxed process from sending a signal * to another process outside the domain. + * - %LANDLOCK_SCOPE_POSIX_MSG_QUEUE: Restrict a sandboxed process from opening + * a POSIX message queue created outside the domain. */ /* clang-format off */ #define LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET (1ULL << 0)
--
2.50.1 (Apple Git-155)