Skip to content

Commit a238110

Browse files
n0toosel0kod
authored andcommitted
landlock: Expand restrict flags example for ABI version 8
Add LANDLOCK_RESTRICT_SELF_TSYNC to the backwards compatibility example for restrict flags. This introduces completeness, similar to that of the ruleset attributes example. However, as the new example can impact enforcement in certain cases, an appropriate warning is also included. Additionally, I modified the two comments of the example to make them more consistent with the ruleset attributes example's. Signed-off-by: Panagiotis "Ivory" Vasilopoulos <[email protected]> Co-developed-by: Dan Cojocaru <[email protected]> Signed-off-by: Dan Cojocaru <[email protected]> Reviewed-by: Günther Noack <[email protected]> Link: https://lore.kernel.org/r/20260304-landlock-docs-add-tsync-example-v4-1-819a276f05c5@n0toose.net [mic: Update date, improve comments consistency, fix newline issue] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent a54142d commit a238110

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

Documentation/userspace-api/landlock.rst

Lines changed: 19 additions & 4 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: January 2026
11+
:Date: March 2026
1212

1313
The goal of Landlock is to enable restriction of ambient rights (e.g. global
1414
filesystem or network access) for a set of processes. Because Landlock
@@ -197,12 +197,27 @@ similar backwards compatibility check is needed for the restrict flags
197197

198198
.. code-block:: c
199199
200-
__u32 restrict_flags = LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;
201-
if (abi < 7) {
202-
/* Clear logging flags unsupported before ABI 7. */
200+
__u32 restrict_flags =
201+
LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |
202+
LANDLOCK_RESTRICT_SELF_TSYNC;
203+
switch (abi) {
204+
case 1 ... 6:
205+
/* Removes logging flags for ABI < 7 */
203206
restrict_flags &= ~(LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF |
204207
LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |
205208
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF);
209+
__attribute__((fallthrough));
210+
case 7:
211+
/*
212+
* Removes multithreaded enforcement flag for ABI < 8
213+
*
214+
* WARNING: Without this flag, calling landlock_restrict_self(2) is
215+
* only equivalent if the calling process is single-threaded. Below
216+
* ABI v8 (and as of ABI v8, when not using this flag), a Landlock
217+
* policy would only be enforced for the calling thread and its
218+
* children (and not for all threads, including parents and siblings).
219+
*/
220+
restrict_flags &= ~LANDLOCK_RESTRICT_SELF_TSYNC;
206221
}
207222
208223
The next step is to restrict the current thread from gaining more privileges

0 commit comments

Comments
 (0)