Skip to content

Commit 09340cf

Browse files
committed
landlock: Document good practices about filesystem policies
Explain how to set access rights per hierarchy in an efficient and safe way, especially with the LANDLOCK_ACCESS_FS_REFER side effect (i.e. partial ordering and constraints for access rights per hierarchy). Reviewed-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Mickaël Salaün <mic@digikod.net> Link: https://lore.kernel.org/r/20220506161102.525323-12-mic@digikod.net
1 parent 6f59abf commit 09340cf

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Documentation/userspace-api/landlock.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,27 @@ ruleset.
156156

157157
Full working code can be found in `samples/landlock/sandboxer.c`_.
158158

159+
Good practices
160+
--------------
161+
162+
It is recommended setting access rights to file hierarchy leaves as much as
163+
possible. For instance, it is better to be able to have ``~/doc/`` as a
164+
read-only hierarchy and ``~/tmp/`` as a read-write hierarchy, compared to
165+
``~/`` as a read-only hierarchy and ``~/tmp/`` as a read-write hierarchy.
166+
Following this good practice leads to self-sufficient hierarchies that don't
167+
depend on their location (i.e. parent directories). This is particularly
168+
relevant when we want to allow linking or renaming. Indeed, having consistent
169+
access rights per directory enables to change the location of such directory
170+
without relying on the destination directory access rights (except those that
171+
are required for this operation, see `LANDLOCK_ACCESS_FS_REFER` documentation).
172+
Having self-sufficient hierarchies also helps to tighten the required access
173+
rights to the minimal set of data. This also helps avoid sinkhole directories,
174+
i.e. directories where data can be linked to but not linked from. However,
175+
this depends on data organization, which might not be controlled by developers.
176+
In this case, granting read-write access to ``~/tmp/``, instead of write-only
177+
access, would potentially allow to move ``~/tmp/`` to a non-readable directory
178+
and still keep the ability to list the content of ``~/tmp/``.
179+
159180
Layers of file path access rights
160181
---------------------------------
161182

0 commit comments

Comments
 (0)