Skip to content

Commit 0e89ef6

Browse files
committed
landlock: Extend documentation for kernel support
Extend the kernel support section with one subsection for build time configuration and another for boot time configuration. Extend the boot time subsection with a concrete example. Update the journalctl command to include the boot option. Cc: Kees Cook <[email protected]> Reviewed-by: Günther Noack <[email protected]> Link: https://lore.kernel.org/r/[email protected] [mic: Improve wording as suggested by Günther] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent b4007fd commit 0e89ef6

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

Documentation/userspace-api/landlock.rst

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ unexpected/malicious behaviors in user space applications. Landlock empowers
1919
any process, including unprivileged ones, to securely restrict themselves.
2020

2121
We can quickly make sure that Landlock is enabled in the running system by
22-
looking for "landlock: Up and running" in kernel logs (as root): ``dmesg | grep
23-
landlock || journalctl -kg landlock`` . Developers can also easily check for
24-
Landlock support with a :ref:`related system call <landlock_abi_versions>`. If
25-
Landlock is not currently supported, we need to :ref:`configure the kernel
26-
appropriately <kernel_support>`.
22+
looking for "landlock: Up and running" in kernel logs (as root):
23+
``dmesg | grep landlock || journalctl -kb -g landlock`` .
24+
Developers can also easily check for Landlock support with a
25+
:ref:`related system call <landlock_abi_versions>`.
26+
If Landlock is not currently supported, we need to
27+
:ref:`configure the kernel appropriately <kernel_support>`.
2728

2829
Landlock rules
2930
==============
@@ -499,6 +500,9 @@ access rights.
499500
Kernel support
500501
==============
501502

503+
Build time configuration
504+
------------------------
505+
502506
Landlock was first introduced in Linux 5.13 but it must be configured at build
503507
time with ``CONFIG_SECURITY_LANDLOCK=y``. Landlock must also be enabled at boot
504508
time as the other security modules. The list of security modules enabled by
@@ -507,11 +511,52 @@ contains ``CONFIG_LSM=landlock,[...]`` with ``[...]`` as the list of other
507511
potentially useful security modules for the running system (see the
508512
``CONFIG_LSM`` help).
509513

514+
Boot time configuration
515+
-----------------------
516+
510517
If the running kernel does not have ``landlock`` in ``CONFIG_LSM``, then we can
511-
still enable it by adding ``lsm=landlock,[...]`` to
512-
Documentation/admin-guide/kernel-parameters.rst thanks to the bootloader
518+
enable Landlock by adding ``lsm=landlock,[...]`` to
519+
Documentation/admin-guide/kernel-parameters.rst in the boot loader
513520
configuration.
514521

522+
For example, if the current built-in configuration is:
523+
524+
.. code-block:: console
525+
526+
$ zgrep -h "^CONFIG_LSM=" "/boot/config-$(uname -r)" /proc/config.gz 2>/dev/null
527+
CONFIG_LSM="lockdown,yama,integrity,apparmor"
528+
529+
...and if the cmdline doesn't contain ``landlock`` either:
530+
531+
.. code-block:: console
532+
533+
$ sed -n 's/.*\(\<lsm=\S\+\).*/\1/p' /proc/cmdline
534+
lsm=lockdown,yama,integrity,apparmor
535+
536+
...we should configure the boot loader to set a cmdline extending the ``lsm``
537+
list with the ``landlock,`` prefix::
538+
539+
lsm=landlock,lockdown,yama,integrity,apparmor
540+
541+
After a reboot, we can check that Landlock is up and running by looking at
542+
kernel logs:
543+
544+
.. code-block:: console
545+
546+
# dmesg | grep landlock || journalctl -kb -g landlock
547+
[ 0.000000] Command line: [...] lsm=landlock,lockdown,yama,integrity,apparmor
548+
[ 0.000000] Kernel command line: [...] lsm=landlock,lockdown,yama,integrity,apparmor
549+
[ 0.000000] LSM: initializing lsm=lockdown,capability,landlock,yama,integrity,apparmor
550+
[ 0.000000] landlock: Up and running.
551+
552+
The kernel may be configured at build time to always load the ``lockdown`` and
553+
``capability`` LSMs. In that case, these LSMs will appear at the beginning of
554+
the ``LSM: initializing`` log line as well, even if they are not configured in
555+
the boot loader.
556+
557+
Network support
558+
---------------
559+
515560
To be able to explicitly allow TCP operations (e.g., adding a network rule with
516561
``LANDLOCK_ACCESS_NET_BIND_TCP``), the kernel must support TCP
517562
(``CONFIG_INET=y``). Otherwise, sys_landlock_add_rule() returns an

0 commit comments

Comments
 (0)