Skip to content

Commit 5ce73a3

Browse files
committed
landlock: Document LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET
JIRA: https://issues.redhat.com/browse/RHEL-94688 Introduce LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET as an IPC scoping mechanism available since Landlock ABI version 6. Update ruleset_attr, Landlock ABI version, and access rights code blocks based on that. Signed-off-by: Tahera Fahimi <[email protected]> Link: https://lore.kernel.org/r/ac75151861724c19ed62b500cfe497612d9a6607.1725494372.git.fahimitahera@gmail.com [mic: Improve commit message and documentation, add a missing fallthrough, reformat to 80 columns, improve some wording] Signed-off-by: Mickaël Salaün <[email protected]> (cherry picked from commit dba40c7) Signed-off-by: Ryan Sullivan <[email protected]>
1 parent 1422dd6 commit 5ce73a3

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

Documentation/userspace-api/landlock.rst

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Landlock: unprivileged access control
88
=====================================
99

1010
:Author: Mickaël Salaün
11-
:Date: July 2024
11+
:Date: September 2024
1212

1313
The goal of Landlock is to enable to restrict ambient rights (e.g. global
1414
filesystem or network access) for a set of processes. Because Landlock
@@ -81,6 +81,8 @@ to be explicit about the denied-by-default access rights.
8181
.handled_access_net =
8282
LANDLOCK_ACCESS_NET_BIND_TCP |
8383
LANDLOCK_ACCESS_NET_CONNECT_TCP,
84+
.scoped =
85+
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET,
8486
};
8587
8688
Because we may not know on which kernel version an application will be
@@ -119,6 +121,10 @@ version, and only use the available subset of access rights:
119121
case 4:
120122
/* Removes LANDLOCK_ACCESS_FS_IOCTL_DEV for ABI < 5 */
121123
ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_IOCTL_DEV;
124+
__attribute__((fallthrough));
125+
case 5:
126+
/* Removes LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET for ABI < 6 */
127+
ruleset_attr.scoped &= ~LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET;
122128
}
123129
124130
This enables to create an inclusive ruleset that will contain our rules.
@@ -306,6 +312,33 @@ To be allowed to use :manpage:`ptrace(2)` and related syscalls on a target
306312
process, a sandboxed process should have a subset of the target process rules,
307313
which means the tracee must be in a sub-domain of the tracer.
308314

315+
IPC scoping
316+
-----------
317+
318+
Similar to the implicit `Ptrace restrictions`_, we may want to further restrict
319+
interactions between sandboxes. Each Landlock domain can be explicitly scoped
320+
for a set of actions by specifying it on a ruleset. For example, if a
321+
sandboxed process should not be able to :manpage:`connect(2)` to a
322+
non-sandboxed process through abstract :manpage:`unix(7)` sockets, we can
323+
specify such restriction with ``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET``.
324+
325+
A sandboxed process can connect to a non-sandboxed process when its domain is
326+
not scoped. If a process's domain is scoped, it can only connect to sockets
327+
created by processes in the same scope.
328+
329+
A connected datagram socket behaves like a stream socket when its domain is
330+
scoped, meaning if the domain is scoped after the socket is connected , it can
331+
still :manpage:`send(2)` data just like a stream socket. However, in the same
332+
scenario, a non-connected datagram socket cannot send data (with
333+
:manpage:`sendto(2)`) outside its scope.
334+
335+
A process with a scoped domain can inherit a socket created by a non-scoped
336+
process. The process cannot connect to this socket since it has a scoped
337+
domain.
338+
339+
IPC scoping does not support exceptions, so if a domain is scoped, no rules can
340+
be added to allow access to resources or processes outside of the scope.
341+
309342
Truncating files
310343
----------------
311344

@@ -404,7 +437,7 @@ Access rights
404437
-------------
405438

406439
.. kernel-doc:: include/uapi/linux/landlock.h
407-
:identifiers: fs_access net_access
440+
:identifiers: fs_access net_access scope
408441

409442
Creating a new ruleset
410443
----------------------
@@ -541,6 +574,13 @@ earlier ABI.
541574
Starting with the Landlock ABI version 5, it is possible to restrict the use of
542575
:manpage:`ioctl(2)` using the new ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right.
543576

577+
Abstract UNIX socket scoping (ABI < 6)
578+
--------------------------------------
579+
580+
Starting with the Landlock ABI version 6, it is possible to restrict
581+
connections to an abstract :manpage:`unix(7)` socket by setting
582+
``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET`` to the ``scoped`` ruleset attribute.
583+
544584
.. _kernel_support:
545585

546586
Kernel support

0 commit comments

Comments
 (0)