From: Justin Suess <utilityemal77@gmail.com>
To: gnoack3000@gmail.com, mic@digikod.net
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Justin Suess <utilityemal77@gmail.com>
Subject: [PATCH 0/6] landlock: Add scoped access bit for SysV message queues
Date: Thu, 21 May 2026 12:06:34 -0400 [thread overview]
Message-ID: <20260521160640.1716746-1-utilityemal77@gmail.com> (raw)
This series extends Landlock with a new scoped access right,
LANDLOCK_SCOPE_SYSV_MSG_QUEUE, allowing a sandboxed process to be
restricted from interacting with SysV message queues created outside
of its Landlock domain (or a nested domain).
While use of SysV message queues is less common than other IPC types,
they are commonly used in older applications which may be vulnerable
to exploitation, so they are a meaningful attack surface to restrict.
Background
==========
SysV message queues differ from the IPC mechanisms Landlock already
scopes (UNIX sockets and signals): they have no FD or process-local
handle. A msqid is valid IPC-namespace-wide and can be obtained
without calling msgget(), so simply hooking msgget() is insufficient.
Domain provenance has to be tracked on the queue itself and checked on
every operation against it.
Approach
========
A new credential blob is attached to each kern_ipc_perm at creation
time, recording the creating task's Landlock domain and a @kind
tag identifying the IPC object type. The @kind tag is required
because the LSM core allocates an IPC blob for every kern_ipc_perm
regardless of kind, and the generic ipc_permission hook fires for
semaphores and shared memory as well as message queues.
The enum also leaves room to extend scoping to sem/shm later
without changing the blob layout.
Enforcement is done from security_ipc_permission(), which is the
single choke point for msgget() on an existing queue, msgsnd(),
msgrcv(), and the msgctl() variants that go through ipcperms()
(IPC_STAT, MSG_STAT, MSG_STAT_ANY). msgctl_down() (IPC_RMID and
IPC_SET) bypasses ipcperms(), so the per-call msg_queue_msgctl
hook is kept for those cases. msg_queue_msgctl also covers the
IPC_INFO / MSG_INFO case where no specific queue exists.
Quirks
======
- Denials surface as -EACCES rather than -EPERM because the generic
ipcperms() path maps every LSM denial to -EACCES before returning
to userspace. This is documented and the selftests check for
-EACCES accordingly.
- Because there is no persistent handle, a msqid already obtained
by a process before it enforces this scope can become unusable
once the restriction is in place; this is intentional and
documented.
Patch layout
============
1. Add the kern_ipc_perm credential blob and @kind enum.
2. Implement LANDLOCK_SCOPE_SYSV_MSG_QUEUE, the ipc_permission
hook, and msg_queue_msgctl coverage for IPC_RMID/IPC_SET and
IPC_INFO/MSG_INFO.
3. Bump the Landlock ABI.
4. Selftests covering msgget plus a separate fixture for msgsnd,
msgrcv, and msgctl using a pre-created msqid.
5. sandboxer sample support for the new scope.
6. Documentation updates covering the new scope, the -EACCES
return code, and the implications of non-persistent handles.
Test coverage
=============
Selftests exercise denial and allow paths for msgget, msgsnd,
msgrcv, and msgctl(IPC_STAT) across domain boundaries, including
nested-domain inheritance. All existing and added tests are
passing.
Kind Regards,
Justin Suess
Justin Suess (6):
landlock: Add kern_ipc_perm credential blob structs
landlock: Add LANDLOCK_SCOPE_SYSV_MSG_QUEUE
landlock: Bump ABI for LANDLOCK_SCOPE_SYSV_MSG_QUEUE
selftests/landlock: Test LANDLOCK_SCOPE_SYSV_MSG_QUEUE
samples/landlock: Support LANDLOCK_SCOPE_SYSV_MSG_QUEUE in sandboxer
landlock: Document LANDLOCK_SCOPE_SYSV_MESSAGE_QUEUE
Documentation/admin-guide/LSM/landlock.rst | 1 +
Documentation/userspace-api/landlock.rst | 30 +-
include/uapi/linux/landlock.h | 3 +
samples/landlock/sandboxer.c | 20 +-
security/landlock/audit.c | 4 +
security/landlock/audit.h | 1 +
security/landlock/limits.h | 2 +-
security/landlock/setup.c | 1 +
security/landlock/syscalls.c | 2 +-
security/landlock/task.c | 137 ++++++++++
security/landlock/task.h | 50 ++++
tools/testing/selftests/landlock/base_test.c | 4 +-
.../landlock/scoped_sysv_msg_queue_test.c | 256 ++++++++++++++++++
.../testing/selftests/landlock/scoped_test.c | 2 +-
14 files changed, 503 insertions(+), 10 deletions(-)
create mode 100644 tools/testing/selftests/landlock/scoped_sysv_msg_queue_test.c
base-commit: 9c5b83756e7b7eab35335da0d5c02a8854bbf416
--
2.53.0
next reply other threads:[~2026-05-21 16:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 16:06 Justin Suess [this message]
2026-05-21 16:06 ` [PATCH 1/6] landlock: Add kern_ipc_perm credential blob structs Justin Suess
2026-05-21 16:06 ` [PATCH 2/6] landlock: Add LANDLOCK_SCOPE_SYSV_MSG_QUEUE Justin Suess
2026-05-21 16:06 ` [PATCH 3/6] landlock: Bump ABI for LANDLOCK_SCOPE_SYSV_MSG_QUEUE Justin Suess
2026-05-21 16:06 ` [PATCH 4/6] selftests/landlock: Test LANDLOCK_SCOPE_SYSV_MSG_QUEUE Justin Suess
2026-05-21 16:06 ` [PATCH 5/6] samples/landlock: Support LANDLOCK_SCOPE_SYSV_MSG_QUEUE in sandboxer Justin Suess
2026-05-21 16:06 ` [PATCH 6/6] landlock: Document LANDLOCK_SCOPE_SYSV_MESSAGE_QUEUE Justin Suess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260521160640.1716746-1-utilityemal77@gmail.com \
--to=utilityemal77@gmail.com \
--cc=gnoack3000@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox