Skip to contentSkip to conversation

landlock: Explain how to support Landlock

PATCH Superseded Mickaël Salaün 2 participants 3 messages May 12, 2022 – May 13, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mickaël Salaün

author maintainer
#0 lore raw

PATCH 1/1 landlock: Explain how to support Landlock

Let's help users by documenting how to enable and check for Landlock in the kernel and the running system. The userspace-api section may not be the best place for this but it still makes sense to put all the user documentation at the same place.

---
 Documentation/userspace-api/landlock.rst | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Documentation/userspace-api/landlock.rst +26 -0
index 7b4fe6218132..e69dbddcc191 100644
@@ -388,6 +388,32 @@ Starting with the Landlock ABI version 2, it is now possible to securely
 control renaming and linking thanks to the new `LANDLOCK_ACCESS_FS_REFER`
 access right.
 
+Landlock support
+================
+
+Kernel configuration
+--------------------
+
+Landlock can be supported since Linux 5.13 but it must be configured in the
+kernel with `CONFIG_SECURITY_LANDLOCK=y`, and it should be enabled at boot time
+with `CONFIG_LSM=landlock,[...]`.  The `[...]` must be replaced with the list
+of LSMs that may be useful for the running system (see the `CONFIG_LSM` help).
+
+Running system configuration
+----------------------------
+
+If the running kernel doesn't have `landlock` in `CONFIG_LSM`, then we can
+still enable it by adding `lsm=landlock,[...]` to
+Documentation/admin-guide/kernel-parameters.rst. The `[...]` must be replaced
+with the list of LSMs that may be useful for the running system (see the
+`CONFIG_LSM` help).
+
+Running system check
+--------------------
+
+We can check that Landlock is enabled by looking for "landlock: Up and running"
+in kernel logs: `dmesg | grep landlock`
+
 Questions and answers
 =====================
 

base-commit: 67761d8181f0fb9dbd264caa5b6408dbc0d8e86a

Signature · 1 line
2.36.0
maintainer
#1 lore raw
Quoted 18 lines · Mickaël Salaün

Let's help users by documenting how to enable and check for Landlock in the kernel and the running system. The userspace-api section may not be the best place for this but it still makes sense to put all the user documentation at the same place.

---
 Documentation/userspace-api/landlock.rst | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Documentation/userspace-api/landlock.rst +0 -0
index 7b4fe6218132..e69dbddcc191 100644

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 395

Quoted 8 lines
Documentation/userspace-api/landlock.rst +5 -0
@@ -388,6 +388,32 @@ Starting with the Landlock ABI version 2, it is now possible to securely
 control renaming and linking thanks to the new `LANDLOCK_ACCESS_FS_REFER`
 access right.
 
+Landlock support
+================
+
+Kernel configuration
+--------------------

I would suggest changing the section name to "Kernel build configuration" to make it clear the instructions below need to be done at build time.

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 397

Quoted 1 line
Documentation/userspace-api/landlock.rst +1 -0
+Landlock can be supported since Linux 5.13 but it must be configured in the

I would suggest rephrasing the first part of this sentence slightly:

"Landlock was first introduced in Linux v5.13 but it must be ..."

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 398

Quoted 1 line
Documentation/userspace-api/landlock.rst +1 -0
+kernel with `CONFIG_SECURITY_LANDLOCK=y`, and it should be enabled at boot time

CONFIG_LSM is a Kconfig build time variable not a runtime command line variable, yes?

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 403

Quoted 5 lines
Documentation/userspace-api/landlock.rst +5 -0
+with `CONFIG_LSM=landlock,[...]`.  The `[...]` must be replaced with the list
+of LSMs that may be useful for the running system (see the `CONFIG_LSM` help).
+
+Running system configuration
+----------------------------

This is nit-picky, but I would suggest a section name of "Kernel command line configuration".

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 415

Quoted 11 lines
Documentation/userspace-api/landlock.rst +11 -0
+If the running kernel doesn't have `landlock` in `CONFIG_LSM`, then we can
+still enable it by adding `lsm=landlock,[...]` to
+Documentation/admin-guide/kernel-parameters.rst. The `[...]` must be replaced
+with the list of LSMs that may be useful for the running system (see the
+`CONFIG_LSM` help).
+
+Running system check
+--------------------
+
+We can check that Landlock is enabled by looking for "landlock: Up and running"
+in kernel logs: `dmesg | grep landlock`

I would suggest moving the "Running system check" section up closer to the top of the documentation, perhaps right before the "Landlock rules" section. My thinking is that it is better to mention this as soon as possible in the doc so that users can verify Landlock is present and functioning before trying any of the code examples and failing. I think it is okay to leave the "how to enable Landlock" sections at the bottom and simply refer to them in the "system check" section.

Signature · 1 line
paul-moore.com
author maintainer
#2 lore raw
Quoted 22 lines · Paul Moore
Quoted 21 lines · Mickaël Salaün

Let's help users by documenting how to enable and check for Landlock in the kernel and the running system. The userspace-api section may not be the best place for this but it still makes sense to put all the user documentation at the same place.

---
  Documentation/userspace-api/landlock.rst | 26 ++++++++++++++++++++++++
  1 file changed, 26 insertions(+)
Documentation/userspace-api/landlock.rst +0 -0
index 7b4fe6218132..e69dbddcc191 100644
@@ -388,6 +388,32 @@ Starting with the Landlock ABI version 2, it is now possible to securely
  control renaming and linking thanks to the new `LANDLOCK_ACCESS_FS_REFER`
  access right.
 
Quoted 9 lines

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 395

Quoted 5 lines
Documentation/userspace-api/landlock.rst +5 -0
+Landlock support
+================
+
+Kernel configuration
+--------------------

I would suggest changing the section name to "Kernel build configuration" to make it clear the instructions below need to be done at build time.

That would be better indeed.

[rewinding] …well, this title would go away if I merge this subsection with the next one.

Quoted 6 lines

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 397

Quoted 2 lines
Documentation/userspace-api/landlock.rst +1 -0
+Landlock can be supported since Linux 5.13 but it must be configured in the

I would suggest rephrasing the first part of this sentence slightly:

"Landlock was first introduced in Linux v5.13 but it must be ..."

OK

Quoted 5 lines

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 398

Quoted 2 lines
Documentation/userspace-api/landlock.rst +1 -0
+kernel with `CONFIG_SECURITY_LANDLOCK=y`, and it should be enabled at boot time

CONFIG_LSM is a Kconfig build time variable not a runtime command line variable, yes?

Yes. This is confusing because it sets the default value of cmdline. I'll rephrase this paragraph.

Quoted 9 lines

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 403

Quoted 6 lines
Documentation/userspace-api/landlock.rst +5 -0
+with `CONFIG_LSM=landlock,[...]`.  The `[...]` must be replaced with the list
+of LSMs that may be useful for the running system (see the `CONFIG_LSM` help).
+
+Running system configuration
+----------------------------

This is nit-picky, but I would suggest a section name of "Kernel command line configuration".

I was thinking about "Kernel boot configuration" but I'll try to merge the two configuration subsections and put the check subsection earlier.

Quoted 13 lines

Documentation/userspace-api/landlock.rst Starting with the Landlock ABI version 2, it is now possible to securely · line 415

Quoted 12 lines
Documentation/userspace-api/landlock.rst +11 -0
+If the running kernel doesn't have `landlock` in `CONFIG_LSM`, then we can
+still enable it by adding `lsm=landlock,[...]` to
+Documentation/admin-guide/kernel-parameters.rst. The `[...]` must be replaced
+with the list of LSMs that may be useful for the running system (see the
+`CONFIG_LSM` help).
+
+Running system check
+--------------------
+
+We can check that Landlock is enabled by looking for "landlock: Up and running"
+in kernel logs: `dmesg | grep landlock`
Quoted 9 lines

I would suggest moving the "Running system check" section up closer to the top of the documentation, perhaps right before the "Landlock rules" section. My thinking is that it is better to mention this as soon as possible in the doc so that users can verify Landlock is present and functioning before trying any of the code examples and failing. I think it is okay to leave the "how to enable Landlock" sections at the bottom and simply refer to them in the "system check" section.

Good idea, thanks!