Skip to content

Commit fe72ce6

Browse files
samasth-norwayl0kod
authored andcommitted
landlock: Add errata documentation section
Add errata section with code examples for querying errata and a warning that most applications should not check errata. Use kernel-doc directives to include errata descriptions from the header files instead of manual links. Also enhance existing DOC sections in security/landlock/errata/abi-*.h files with Impact sections, and update the code comment in syscalls.c to remind developers to update errata documentation when applicable. This addresses the gap where the kernel implements errata tracking but provides no user-facing documentation on how to use it, while improving the existing technical documentation in-place rather than duplicating it. Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com> Reviewed-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20260128031814.2945394-3-samasth.norway.ananda@oracle.com [mic: Cosmetic fix] Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 6100f29 commit fe72ce6

5 files changed

Lines changed: 90 additions & 4 deletions

File tree

Documentation/userspace-api/landlock.rst

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,68 @@ system call:
445445
printf("Landlock supports LANDLOCK_ACCESS_FS_REFER.\n");
446446
}
447447
448-
The following kernel interfaces are implicitly supported by the first ABI
449-
version. Features only supported from a specific version are explicitly marked
450-
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.
451510

452511
Kernel interface
453512
================

security/landlock/errata/abi-1.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@
1212
* hierarchy down to its filesystem root and those from the related mount point
1313
* hierarchy. This prevents access right widening through rename or link
1414
* actions.
15+
*
16+
* Impact:
17+
*
18+
* Without this fix, it was possible to widen access rights through rename or
19+
* link actions involving disconnected directories, potentially bypassing
20+
* ``LANDLOCK_ACCESS_FS_REFER`` restrictions. This could allow privilege
21+
* escalation in complex mount scenarios where directories become disconnected
22+
* from their original mount points.
1523
*/
1624
LANDLOCK_ERRATUM(3)

security/landlock/errata/abi-4.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
* :manpage:`bind(2)` and :manpage:`connect(2)` operations. This change ensures
1212
* that only TCP sockets are subject to TCP access rights, allowing other
1313
* protocols to operate without unnecessary restrictions.
14+
*
15+
* Impact:
16+
*
17+
* In kernels without this fix, using ``LANDLOCK_ACCESS_NET_BIND_TCP`` or
18+
* ``LANDLOCK_ACCESS_NET_CONNECT_TCP`` would incorrectly restrict non-TCP
19+
* stream protocols (SMC, MPTCP, SCTP), potentially breaking applications
20+
* that rely on these protocols while using Landlock network restrictions.
1421
*/
1522
LANDLOCK_ERRATUM(1)

security/landlock/errata/abi-6.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@
1515
* interaction between threads of the same process should always be allowed.
1616
* This change ensures that any thread is allowed to send signals to any other
1717
* thread within the same process, regardless of their domain.
18+
*
19+
* Impact:
20+
*
21+
* This problem only manifests when the userspace process is itself using
22+
* :manpage:`libpsx(3)` or an equivalent mechanism to enforce a Landlock policy
23+
* on multiple already-running threads at once. Programs which enforce a
24+
* Landlock policy at startup time and only then become multithreaded are not
25+
* affected. Without this fix, signal scoping could break multi-threaded
26+
* applications that expect threads within the same process to freely signal
27+
* each other.
1828
*/
1929
LANDLOCK_ERRATUM(2)

security/landlock/syscalls.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ static const struct file_operations ruleset_fops = {
158158
/*
159159
* The Landlock ABI version should be incremented for each new Landlock-related
160160
* user space visible change (e.g. Landlock syscalls). This version should
161-
* only be incremented once per Linux release, and the date in
161+
* only be incremented once per Linux release. When incrementing, the date in
162162
* Documentation/userspace-api/landlock.rst should be updated to reflect the
163163
* UAPI change.
164+
* If the change involves a fix that requires userspace awareness, also update
165+
* the errata documentation in Documentation/userspace-api/landlock.rst .
164166
*/
165167
const int landlock_abi_version = 8;
166168

0 commit comments

Comments
 (0)