@@ -8,13 +8,13 @@ Landlock: unprivileged access control
88=====================================
99
1010:Author: Mickaël Salaün
11- :Date: September 2024
11+ :Date: October 2024
1212
13- The goal of Landlock is to enable to restrict ambient rights (e.g. global
13+ The goal of Landlock is to enable restriction of ambient rights (e.g. global
1414filesystem or network access) for a set of processes. Because Landlock
15- is a stackable LSM, it makes possible to create safe security sandboxes as new
16- security layers in addition to the existing system-wide access-controls. This
17- kind of sandbox is expected to help mitigate the security impact of bugs or
15+ is a stackable LSM, it makes it possible to create safe security sandboxes as
16+ new security layers in addition to the existing system-wide access-controls.
17+ This kind of sandbox is expected to help mitigate the security impact of bugs or
1818unexpected/malicious behaviors in user space applications. Landlock empowers
1919any process, including unprivileged ones, to securely restrict themselves.
2020
@@ -86,8 +86,8 @@ to be explicit about the denied-by-default access rights.
8686 LANDLOCK_SCOPE_SIGNAL,
8787 };
8888
89- Because we may not know on which kernel version an application will be
90- executed , it is safer to follow a best-effort security approach. Indeed, we
89+ Because we may not know which kernel version an application will be executed
90+ on , it is safer to follow a best-effort security approach. Indeed, we
9191should try to protect users as much as possible whatever the kernel they are
9292using.
9393
@@ -129,7 +129,7 @@ version, and only use the available subset of access rights:
129129 LANDLOCK_SCOPE_SIGNAL);
130130 }
131131
132- This enables to create an inclusive ruleset that will contain our rules.
132+ This enables the creation of an inclusive ruleset that will contain our rules.
133133
134134.. code-block :: c
135135
@@ -219,42 +219,41 @@ If the ``landlock_restrict_self`` system call succeeds, the current thread is
219219now restricted and this policy will be enforced on all its subsequently created
220220children as well. Once a thread is landlocked, there is no way to remove its
221221security policy; only adding more restrictions is allowed. These threads are
222- now in a new Landlock domain, merge of their parent one (if any) with the new
223- ruleset.
222+ now in a new Landlock domain, which is a merger of their parent one (if any)
223+ with the new ruleset.
224224
225225Full working code can be found in `samples/landlock/sandboxer.c `_.
226226
227227Good practices
228228--------------
229229
230- It is recommended setting access rights to file hierarchy leaves as much as
230+ It is recommended to set access rights to file hierarchy leaves as much as
231231possible. For instance, it is better to be able to have ``~/doc/ `` as a
232232read-only hierarchy and ``~/tmp/ `` as a read-write hierarchy, compared to
233233``~/ `` as a read-only hierarchy and ``~/tmp/ `` as a read-write hierarchy.
234234Following this good practice leads to self-sufficient hierarchies that do not
235235depend on their location (i.e. parent directories). This is particularly
236236relevant when we want to allow linking or renaming. Indeed, having consistent
237- access rights per directory enables to change the location of such directory
237+ access rights per directory enables changing the location of such directories
238238without relying on the destination directory access rights (except those that
239239are required for this operation, see ``LANDLOCK_ACCESS_FS_REFER ``
240240documentation).
241241
242242Having self-sufficient hierarchies also helps to tighten the required access
243243rights to the minimal set of data. This also helps avoid sinkhole directories,
244- i.e. directories where data can be linked to but not linked from. However,
244+ i.e. directories where data can be linked to but not linked from. However,
245245this depends on data organization, which might not be controlled by developers.
246246In this case, granting read-write access to ``~/tmp/ ``, instead of write-only
247- access, would potentially allow to move ``~/tmp/ `` to a non-readable directory
247+ access, would potentially allow moving ``~/tmp/ `` to a non-readable directory
248248and still keep the ability to list the content of ``~/tmp/ ``.
249249
250250Layers of file path access rights
251251---------------------------------
252252
253253Each time a thread enforces a ruleset on itself, it updates its Landlock domain
254- with a new layer of policy. Indeed, this complementary policy is stacked with
255- the potentially other rulesets already restricting this thread. A sandboxed
256- thread can then safely add more constraints to itself with a new enforced
257- ruleset.
254+ with a new layer of policy. This complementary policy is stacked with any
255+ other rulesets potentially already restricting this thread. A sandboxed thread
256+ can then safely add more constraints to itself with a new enforced ruleset.
258257
259258One policy layer grants access to a file path if at least one of its rules
260259encountered on the path grants the access. A sandboxed thread can only access
@@ -265,7 +264,7 @@ etc.).
265264Bind mounts and OverlayFS
266265-------------------------
267266
268- Landlock enables to restrict access to file hierarchies, which means that these
267+ Landlock enables restricting access to file hierarchies, which means that these
269268access rights can be propagated with bind mounts (cf.
270269Documentation/filesystems/sharedsubtree.rst) but not with
271270Documentation/filesystems/overlayfs.rst.
@@ -278,21 +277,21 @@ access to multiple file hierarchies at the same time, whether these hierarchies
278277are the result of bind mounts or not.
279278
280279An OverlayFS mount point consists of upper and lower layers. These layers are
281- combined in a merge directory, result of the mount point. This merge hierarchy
282- may include files from the upper and lower layers, but modifications performed
283- on the merge hierarchy only reflects on the upper layer. From a Landlock
284- policy point of view, each OverlayFS layers and merge hierarchies are
285- standalone and contains their own set of files and directories, which is
286- different from bind mounts. A policy restricting an OverlayFS layer will not
287- restrict the resulted merged hierarchy, and vice versa. Landlock users should
288- then only think about file hierarchies they want to allow access to, regardless
289- of the underlying filesystem.
280+ combined in a merge directory, and that merged directory becomes available at
281+ the mount point. This merge hierarchy may include files from the upper and
282+ lower layers, but modifications performed on the merge hierarchy only reflect
283+ on the upper layer. From a Landlock policy point of view, all OverlayFS layers
284+ and merge hierarchies are standalone and each contains their own set of files
285+ and directories, which is different from bind mounts. A policy restricting an
286+ OverlayFS layer will not restrict the resulted merged hierarchy, and vice versa.
287+ Landlock users should then only think about file hierarchies they want to allow
288+ access to, regardless of the underlying filesystem.
290289
291290Inheritance
292291-----------
293292
294293Every new thread resulting from a :manpage: `clone(2)` inherits Landlock domain
295- restrictions from its parent. This is similar to the seccomp inheritance (cf.
294+ restrictions from its parent. This is similar to seccomp inheritance (cf.
296295Documentation/userspace-api/seccomp_filter.rst) or any other LSM dealing with
297296task's :manpage: `credentials(7)`. For instance, one process's thread may apply
298297Landlock rules to itself, but they will not be automatically applied to other
@@ -311,8 +310,8 @@ Ptrace restrictions
311310A sandboxed process has less privileges than a non-sandboxed process and must
312311then be subject to additional restrictions when manipulating another process.
313312To be allowed to use :manpage: `ptrace(2)` and related syscalls on a target
314- process, a sandboxed process should have a subset of the target process rules,
315- which means the tracee must be in a sub-domain of the tracer.
313+ process, a sandboxed process should have a superset of the target process's
314+ access rights, which means the tracee must be in a sub-domain of the tracer.
316315
317316IPC scoping
318317-----------
@@ -322,7 +321,7 @@ interactions between sandboxes. Each Landlock domain can be explicitly scoped
322321for a set of actions by specifying it on a ruleset. For example, if a
323322sandboxed process should not be able to :manpage: `connect(2)` to a
324323non-sandboxed process through abstract :manpage: `unix(7)` sockets, we can
325- specify such restriction with ``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET ``.
324+ specify such a restriction with ``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET ``.
326325Moreover, if a sandboxed process should not be able to send a signal to a
327326non-sandboxed process, we can specify this restriction with
328327``LANDLOCK_SCOPE_SIGNAL ``.
@@ -394,7 +393,7 @@ Backward and forward compatibility
394393Landlock is designed to be compatible with past and future versions of the
395394kernel. This is achieved thanks to the system call attributes and the
396395associated bitflags, particularly the ruleset's ``handled_access_fs ``. Making
397- handled access right explicit enables the kernel and user space to have a clear
396+ handled access rights explicit enables the kernel and user space to have a clear
398397contract with each other. This is required to make sure sandboxing will not
399398get stricter with a system update, which could break applications.
400399
@@ -563,33 +562,34 @@ always allowed when using a kernel that only supports the first or second ABI.
563562Starting with the Landlock ABI version 3, it is now possible to securely control
564563truncation thanks to the new ``LANDLOCK_ACCESS_FS_TRUNCATE `` access right.
565564
566- Network support (ABI < 4)
567- -------------------------
565+ TCP bind and connect (ABI < 4)
566+ ------------------------------
568567
569568Starting with the Landlock ABI version 4, it is now possible to restrict TCP
570569bind and connect actions to only a set of allowed ports thanks to the new
571570``LANDLOCK_ACCESS_NET_BIND_TCP `` and ``LANDLOCK_ACCESS_NET_CONNECT_TCP ``
572571access rights.
573572
574- IOCTL (ABI < 5)
575- ---------------
573+ Device IOCTL (ABI < 5)
574+ ----------------------
576575
577576IOCTL operations could not be denied before the fifth Landlock ABI, so
578577:manpage: `ioctl(2)` is always allowed when using a kernel that only supports an
579578earlier ABI.
580579
581580Starting with the Landlock ABI version 5, it is possible to restrict the use of
582- :manpage: `ioctl(2)` using the new ``LANDLOCK_ACCESS_FS_IOCTL_DEV `` right.
581+ :manpage: `ioctl(2)` on character and block devices using the new
582+ ``LANDLOCK_ACCESS_FS_IOCTL_DEV `` right.
583583
584- Abstract UNIX socket scoping (ABI < 6)
585- --------------------------------------
584+ Abstract UNIX socket (ABI < 6)
585+ ------------------------------
586586
587587Starting with the Landlock ABI version 6, it is possible to restrict
588588connections to an abstract :manpage: `unix(7)` socket by setting
589589``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET `` to the ``scoped `` ruleset attribute.
590590
591- Signal scoping (ABI < 6)
592- ------------------------
591+ Signal (ABI < 6)
592+ ----------------
593593
594594Starting with the Landlock ABI version 6, it is possible to restrict
595595:manpage: `signal(7)` sending by setting ``LANDLOCK_SCOPE_SIGNAL `` to the
@@ -605,9 +605,9 @@ Build time configuration
605605
606606Landlock was first introduced in Linux 5.13 but it must be configured at build
607607time with ``CONFIG_SECURITY_LANDLOCK=y ``. Landlock must also be enabled at boot
608- time as the other security modules. The list of security modules enabled by
608+ time like other security modules. The list of security modules enabled by
609609default is set with ``CONFIG_LSM ``. The kernel configuration should then
610- contains ``CONFIG_LSM=landlock,[...] `` with ``[...] `` as the list of other
610+ contain ``CONFIG_LSM=landlock,[...] `` with ``[...] `` as the list of other
611611potentially useful security modules for the running system (see the
612612``CONFIG_LSM `` help).
613613
@@ -669,7 +669,7 @@ Questions and answers
669669What about user space sandbox managers?
670670---------------------------------------
671671
672- Using user space process to enforce restrictions on kernel resources can lead
672+ Using user space processes to enforce restrictions on kernel resources can lead
673673to race conditions or inconsistent evaluations (i.e. `Incorrect mirroring of
674674the OS code and state
675675<https://www.ndss-symposium.org/ndss2003/traps-and-pitfalls-practical-problems-system-call-interposition-based-security-tools/> `_).
0 commit comments