@@ -8,13 +8,13 @@ Landlock: unprivileged access control
8
8
=====================================
9
9
10
10
:Author: Mickaël Salaün
11
- :Date: September 2024
11
+ :Date: October 2024
12
12
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
14
14
filesystem 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
18
18
unexpected/malicious behaviors in user space applications. Landlock empowers
19
19
any process, including unprivileged ones, to securely restrict themselves.
20
20
@@ -86,8 +86,8 @@ to be explicit about the denied-by-default access rights.
86
86
LANDLOCK_SCOPE_SIGNAL,
87
87
};
88
88
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
91
91
should try to protect users as much as possible whatever the kernel they are
92
92
using.
93
93
@@ -129,7 +129,7 @@ version, and only use the available subset of access rights:
129
129
LANDLOCK_SCOPE_SIGNAL);
130
130
}
131
131
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.
133
133
134
134
.. code-block :: c
135
135
@@ -219,42 +219,41 @@ If the ``landlock_restrict_self`` system call succeeds, the current thread is
219
219
now restricted and this policy will be enforced on all its subsequently created
220
220
children as well. Once a thread is landlocked, there is no way to remove its
221
221
security 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.
224
224
225
225
Full working code can be found in `samples/landlock/sandboxer.c `_.
226
226
227
227
Good practices
228
228
--------------
229
229
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
231
231
possible. For instance, it is better to be able to have ``~/doc/ `` as a
232
232
read-only hierarchy and ``~/tmp/ `` as a read-write hierarchy, compared to
233
233
``~/ `` as a read-only hierarchy and ``~/tmp/ `` as a read-write hierarchy.
234
234
Following this good practice leads to self-sufficient hierarchies that do not
235
235
depend on their location (i.e. parent directories). This is particularly
236
236
relevant 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
238
238
without relying on the destination directory access rights (except those that
239
239
are required for this operation, see ``LANDLOCK_ACCESS_FS_REFER ``
240
240
documentation).
241
241
242
242
Having self-sufficient hierarchies also helps to tighten the required access
243
243
rights 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,
245
245
this depends on data organization, which might not be controlled by developers.
246
246
In 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
248
248
and still keep the ability to list the content of ``~/tmp/ ``.
249
249
250
250
Layers of file path access rights
251
251
---------------------------------
252
252
253
253
Each 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.
258
257
259
258
One policy layer grants access to a file path if at least one of its rules
260
259
encountered on the path grants the access. A sandboxed thread can only access
@@ -265,7 +264,7 @@ etc.).
265
264
Bind mounts and OverlayFS
266
265
-------------------------
267
266
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
269
268
access rights can be propagated with bind mounts (cf.
270
269
Documentation/filesystems/sharedsubtree.rst) but not with
271
270
Documentation/filesystems/overlayfs.rst.
@@ -278,21 +277,21 @@ access to multiple file hierarchies at the same time, whether these hierarchies
278
277
are the result of bind mounts or not.
279
278
280
279
An 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.
290
289
291
290
Inheritance
292
291
-----------
293
292
294
293
Every 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.
296
295
Documentation/userspace-api/seccomp_filter.rst) or any other LSM dealing with
297
296
task's :manpage: `credentials(7)`. For instance, one process's thread may apply
298
297
Landlock rules to itself, but they will not be automatically applied to other
@@ -311,8 +310,8 @@ Ptrace restrictions
311
310
A sandboxed process has less privileges than a non-sandboxed process and must
312
311
then be subject to additional restrictions when manipulating another process.
313
312
To 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.
316
315
317
316
IPC scoping
318
317
-----------
@@ -322,7 +321,7 @@ interactions between sandboxes. Each Landlock domain can be explicitly scoped
322
321
for a set of actions by specifying it on a ruleset. For example, if a
323
322
sandboxed process should not be able to :manpage: `connect(2)` to a
324
323
non-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 ``.
326
325
Moreover, if a sandboxed process should not be able to send a signal to a
327
326
non-sandboxed process, we can specify this restriction with
328
327
``LANDLOCK_SCOPE_SIGNAL ``.
@@ -394,7 +393,7 @@ Backward and forward compatibility
394
393
Landlock is designed to be compatible with past and future versions of the
395
394
kernel. This is achieved thanks to the system call attributes and the
396
395
associated 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
398
397
contract with each other. This is required to make sure sandboxing will not
399
398
get stricter with a system update, which could break applications.
400
399
@@ -563,33 +562,34 @@ always allowed when using a kernel that only supports the first or second ABI.
563
562
Starting with the Landlock ABI version 3, it is now possible to securely control
564
563
truncation thanks to the new ``LANDLOCK_ACCESS_FS_TRUNCATE `` access right.
565
564
566
- Network support (ABI < 4)
567
- -------------------------
565
+ TCP bind and connect (ABI < 4)
566
+ ------------------------------
568
567
569
568
Starting with the Landlock ABI version 4, it is now possible to restrict TCP
570
569
bind and connect actions to only a set of allowed ports thanks to the new
571
570
``LANDLOCK_ACCESS_NET_BIND_TCP `` and ``LANDLOCK_ACCESS_NET_CONNECT_TCP ``
572
571
access rights.
573
572
574
- IOCTL (ABI < 5)
575
- ---------------
573
+ Device IOCTL (ABI < 5)
574
+ ----------------------
576
575
577
576
IOCTL operations could not be denied before the fifth Landlock ABI, so
578
577
:manpage: `ioctl(2)` is always allowed when using a kernel that only supports an
579
578
earlier ABI.
580
579
581
580
Starting 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.
583
583
584
- Abstract UNIX socket scoping (ABI < 6)
585
- --------------------------------------
584
+ Abstract UNIX socket (ABI < 6)
585
+ ------------------------------
586
586
587
587
Starting with the Landlock ABI version 6, it is possible to restrict
588
588
connections to an abstract :manpage: `unix(7)` socket by setting
589
589
``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET `` to the ``scoped `` ruleset attribute.
590
590
591
- Signal scoping (ABI < 6)
592
- ------------------------
591
+ Signal (ABI < 6)
592
+ ----------------
593
593
594
594
Starting with the Landlock ABI version 6, it is possible to restrict
595
595
:manpage: `signal(7)` sending by setting ``LANDLOCK_SCOPE_SIGNAL `` to the
@@ -605,9 +605,9 @@ Build time configuration
605
605
606
606
Landlock was first introduced in Linux 5.13 but it must be configured at build
607
607
time 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
609
609
default 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
611
611
potentially useful security modules for the running system (see the
612
612
``CONFIG_LSM `` help).
613
613
@@ -669,7 +669,7 @@ Questions and answers
669
669
What about user space sandbox managers?
670
670
---------------------------------------
671
671
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
673
673
to race conditions or inconsistent evaluations (i.e. `Incorrect mirroring of
674
674
the OS code and state
675
675
<https://www.ndss-symposium.org/ndss2003/traps-and-pitfalls-practical-problems-system-call-interposition-based-security-tools/> `_).
0 commit comments