@@ -8,7 +8,7 @@ Landlock: unprivileged access control
88=====================================
99
1010:Author: Mickaël Salaün
11- :Date: March 2025
11+ :Date: January 2026
1212
1313The goal of Landlock is to enable restriction of ambient rights (e.g. global
1414filesystem or network access) for a set of processes. Because Landlock
@@ -142,11 +142,11 @@ This enables the creation of an inclusive ruleset that will contain our rules.
142142 }
143143
144144 We can now add a new rule to this ruleset thanks to the returned file
145- descriptor referring to this ruleset. The rule will only allow reading the
146- file hierarchy ``/usr ``. Without another rule, write actions would then be
147- denied by the ruleset. To add ``/usr `` to the ruleset, we open it with the
148- ``O_PATH `` flag and fill the &struct landlock_path_beneath_attr with this file
149- descriptor.
145+ descriptor referring to this ruleset. The rule will allow reading and
146+ executing the file hierarchy ``/usr ``. Without another rule, write actions
147+ would then be denied by the ruleset. To add ``/usr `` to the ruleset, we open
148+ it with the ``O_PATH `` flag and fill the &struct landlock_path_beneath_attr with
149+ this file descriptor.
150150
151151.. code-block :: c
152152
@@ -191,10 +191,24 @@ number for a specific action: HTTPS connections.
191191 err = landlock_add_rule(ruleset_fd, LANDLOCK_RULE_NET_PORT,
192192 &net_port, 0);
193193
194+ When passing a non-zero ``flags `` argument to ``landlock_restrict_self() ``, a
195+ similar backwards compatibility check is needed for the restrict flags
196+ (see sys_landlock_restrict_self() documentation for available flags):
197+
198+ .. code-block :: c
199+
200+ __u32 restrict_flags = LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;
201+ if (abi < 7) {
202+ /* Clear logging flags unsupported before ABI 7. */
203+ restrict_flags &= ~(LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF |
204+ LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |
205+ LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF);
206+ }
207+
194208 The next step is to restrict the current thread from gaining more privileges
195209(e.g. through a SUID binary). We now have a ruleset with the first rule
196- allowing read access to ``/usr `` while denying all other handled accesses for
197- the filesystem, and a second rule allowing HTTPS connections.
210+ allowing read and execute access to ``/usr `` while denying all other handled
211+ accesses for the filesystem, and a second rule allowing HTTPS connections.
198212
199213.. code-block :: c
200214
@@ -208,7 +222,7 @@ The current thread is now ready to sandbox itself with the ruleset.
208222
209223.. code-block :: c
210224
211- if (landlock_restrict_self(ruleset_fd, 0 )) {
225+ if (landlock_restrict_self(ruleset_fd, restrict_flags )) {
212226 perror("Failed to enforce ruleset");
213227 close(ruleset_fd);
214228 return 1;
@@ -431,9 +445,68 @@ system call:
431445 printf("Landlock supports LANDLOCK_ACCESS_FS_REFER.\n");
432446 }
433447
434- The following kernel interfaces are implicitly supported by the first ABI
435- version. Features only supported from a specific version are explicitly marked
436- as such.
448+ All Landlock kernel interfaces are supported by the first ABI version unless
449+ explicitly noted in their documentation.
450+
451+ Landlock errata
452+ ---------------
453+
454+ In addition to ABI versions, Landlock provides an errata mechanism to track
455+ fixes for issues that may affect backwards compatibility or require userspace
456+ awareness. The errata bitmask can be queried using:
457+
458+ .. code-block :: c
459+
460+ int errata;
461+
462+ errata = landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_ERRATA);
463+ if (errata < 0) {
464+ /* Landlock not available or disabled */
465+ return 0;
466+ }
467+
468+ The returned value is a bitmask where each bit represents a specific erratum.
469+ If bit N is set (``errata & (1 << (N - 1)) ``), then erratum N has been fixed
470+ in the running kernel.
471+
472+ .. warning ::
473+
474+ **Most applications should NOT check errata. ** In 99.9% of cases, checking
475+ errata is unnecessary, increases code complexity, and can potentially
476+ decrease protection if misused. For example, disabling the sandbox when an
477+ erratum is not fixed could leave the system less secure than using
478+ Landlock's best-effort protection. When in doubt, ignore errata.
479+
480+ .. kernel-doc :: security/landlock/errata/abi-4.h
481+ :doc: erratum_1
482+
483+ .. kernel-doc :: security/landlock/errata/abi-6.h
484+ :doc: erratum_2
485+
486+ .. kernel-doc :: security/landlock/errata/abi-1.h
487+ :doc: erratum_3
488+
489+ How to check for errata
490+ ~~~~~~~~~~~~~~~~~~~~~~~
491+
492+ If you determine that your application needs to check for specific errata,
493+ use this pattern:
494+
495+ .. code-block :: c
496+
497+ int errata = landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_ERRATA);
498+ if (errata >= 0) {
499+ /* Check for specific erratum (1-indexed) */
500+ if (errata & (1 << (erratum_number - 1))) {
501+ /* Erratum N is fixed in this kernel */
502+ } else {
503+ /* Erratum N is NOT fixed - consider implications for your use case */
504+ }
505+ }
506+
507+ **Important: ** Only check errata if your application specifically relies on
508+ behavior that changed due to the fix. The fixes generally make Landlock less
509+ restrictive or more correct, not more restrictive.
437510
438511Kernel interface
439512================
@@ -604,6 +677,14 @@ Landlock audit events with the ``LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF``,
604677sys_landlock_restrict_self(). See Documentation/admin-guide/LSM/landlock.rst
605678for more details on audit.
606679
680+ Thread synchronization (ABI < 8)
681+ --------------------------------
682+
683+ Starting with the Landlock ABI version 8, it is now possible to
684+ enforce Landlock rulesets across all threads of the calling process
685+ using the ``LANDLOCK_RESTRICT_SELF_TSYNC `` flag passed to
686+ sys_landlock_restrict_self().
687+
607688.. _kernel_support :
608689
609690Kernel support
0 commit comments