1 .. SPDX-License-Identifier: GPL-2.0
2 .. Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
3 .. Copyright © 2019-2020 ANSSI
4 .. Copyright © 2021-2022 Microsoft Corporation
6 =====================================
7 Landlock: unprivileged access control
8 =====================================
10 :Author: Mickaël Salaün
13 The goal of Landlock is to enable restriction of ambient rights (e.g. global
14 filesystem or network access) for a set of processes. Because Landlock
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 unexpected/malicious behaviors in user space applications. Landlock empowers
19 any process, including unprivileged ones, to securely restrict themselves.
21 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):
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>`.
32 A Landlock rule describes an action on an object which the process intends to
33 perform. A set of rules is aggregated in a ruleset, which can then restrict
34 the thread enforcing it, and its future children.
36 The two existing types of rules are:
39 For these rules, the object is a file hierarchy,
40 and the related filesystem actions are defined with
41 `filesystem access rights`.
43 Network rules (since ABI v4)
44 For these rules, the object is a TCP port,
45 and the related actions are defined with `network access rights`.
47 Defining and enforcing a security policy
48 ----------------------------------------
50 We first need to define the ruleset that will contain our rules.
52 For this example, the ruleset will contain rules that only allow filesystem
53 read actions and establish a specific TCP connection. Filesystem write
54 actions and other TCP actions will be denied.
56 The ruleset then needs to handle both these kinds of actions. This is
57 required for backward and forward compatibility (i.e. the kernel and user
58 space may not know each other's supported restrictions), hence the need
59 to be explicit about the denied-by-default access rights.
63 struct landlock_ruleset_attr ruleset_attr = {
65 LANDLOCK_ACCESS_FS_EXECUTE |
66 LANDLOCK_ACCESS_FS_WRITE_FILE |
67 LANDLOCK_ACCESS_FS_READ_FILE |
68 LANDLOCK_ACCESS_FS_READ_DIR |
69 LANDLOCK_ACCESS_FS_REMOVE_DIR |
70 LANDLOCK_ACCESS_FS_REMOVE_FILE |
71 LANDLOCK_ACCESS_FS_MAKE_CHAR |
72 LANDLOCK_ACCESS_FS_MAKE_DIR |
73 LANDLOCK_ACCESS_FS_MAKE_REG |
74 LANDLOCK_ACCESS_FS_MAKE_SOCK |
75 LANDLOCK_ACCESS_FS_MAKE_FIFO |
76 LANDLOCK_ACCESS_FS_MAKE_BLOCK |
77 LANDLOCK_ACCESS_FS_MAKE_SYM |
78 LANDLOCK_ACCESS_FS_REFER |
79 LANDLOCK_ACCESS_FS_TRUNCATE |
80 LANDLOCK_ACCESS_FS_IOCTL_DEV,
82 LANDLOCK_ACCESS_NET_BIND_TCP |
83 LANDLOCK_ACCESS_NET_CONNECT_TCP,
85 LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET |
86 LANDLOCK_SCOPE_SIGNAL,
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 should try to protect users as much as possible whatever the kernel they are
94 To be compatible with older Linux versions, we detect the available Landlock ABI
95 version, and only use the available subset of access rights:
101 abi = landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_VERSION);
103 /* Degrades gracefully if Landlock is not handled. */
104 perror("The running kernel does not enable to use Landlock");
109 /* Removes LANDLOCK_ACCESS_FS_REFER for ABI < 2 */
110 ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_REFER;
111 __attribute__((fallthrough));
113 /* Removes LANDLOCK_ACCESS_FS_TRUNCATE for ABI < 3 */
114 ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_TRUNCATE;
115 __attribute__((fallthrough));
117 /* Removes network support for ABI < 4 */
118 ruleset_attr.handled_access_net &=
119 ~(LANDLOCK_ACCESS_NET_BIND_TCP |
120 LANDLOCK_ACCESS_NET_CONNECT_TCP);
121 __attribute__((fallthrough));
123 /* Removes LANDLOCK_ACCESS_FS_IOCTL_DEV for ABI < 5 */
124 ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_IOCTL_DEV;
125 __attribute__((fallthrough));
127 /* Removes LANDLOCK_SCOPE_* for ABI < 6 */
128 ruleset_attr.scoped &= ~(LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET |
129 LANDLOCK_SCOPE_SIGNAL);
132 This enables the creation of an inclusive ruleset that will contain our rules.
138 ruleset_fd = landlock_create_ruleset(&ruleset_attr, sizeof(ruleset_attr), 0);
139 if (ruleset_fd < 0) {
140 perror("Failed to create a ruleset");
144 We can now add a new rule to this ruleset thanks to the returned file
145 descriptor referring to this ruleset. The rule will only allow reading the
146 file hierarchy ``/usr``. Without another rule, write actions would then be
147 denied by the ruleset. To add ``/usr`` to the ruleset, we open it with the
148 ``O_PATH`` flag and fill the &struct landlock_path_beneath_attr with this file
154 struct landlock_path_beneath_attr path_beneath = {
156 LANDLOCK_ACCESS_FS_EXECUTE |
157 LANDLOCK_ACCESS_FS_READ_FILE |
158 LANDLOCK_ACCESS_FS_READ_DIR,
161 path_beneath.parent_fd = open("/usr", O_PATH | O_CLOEXEC);
162 if (path_beneath.parent_fd < 0) {
163 perror("Failed to open file");
167 err = landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,
169 close(path_beneath.parent_fd);
171 perror("Failed to update ruleset");
176 It may also be required to create rules following the same logic as explained
177 for the ruleset creation, by filtering access rights according to the Landlock
178 ABI version. In this example, this is not required because all of the requested
179 ``allowed_access`` rights are already available in ABI 1.
181 For network access-control, we can add a set of rules that allow to use a port
182 number for a specific action: HTTPS connections.
186 struct landlock_net_port_attr net_port = {
187 .allowed_access = LANDLOCK_ACCESS_NET_CONNECT_TCP,
191 err = landlock_add_rule(ruleset_fd, LANDLOCK_RULE_NET_PORT,
194 The next step is to restrict the current thread from gaining more privileges
195 (e.g. through a SUID binary). We now have a ruleset with the first rule
196 allowing read access to ``/usr`` while denying all other handled accesses for
197 the filesystem, and a second rule allowing HTTPS connections.
201 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
202 perror("Failed to restrict privileges");
207 The current thread is now ready to sandbox itself with the ruleset.
211 if (landlock_restrict_self(ruleset_fd, 0)) {
212 perror("Failed to enforce ruleset");
218 If the ``landlock_restrict_self`` system call succeeds, the current thread is
219 now restricted and this policy will be enforced on all its subsequently created
220 children as well. Once a thread is landlocked, there is no way to remove its
221 security policy; only adding more restrictions is allowed. These threads are
222 now in a new Landlock domain, which is a merger of their parent one (if any)
223 with the new ruleset.
225 Full working code can be found in `samples/landlock/sandboxer.c`_.
230 It is recommended to set access rights to file hierarchy leaves as much as
231 possible. For instance, it is better to be able to have ``~/doc/`` as a
232 read-only hierarchy and ``~/tmp/`` as a read-write hierarchy, compared to
233 ``~/`` as a read-only hierarchy and ``~/tmp/`` as a read-write hierarchy.
234 Following this good practice leads to self-sufficient hierarchies that do not
235 depend on their location (i.e. parent directories). This is particularly
236 relevant when we want to allow linking or renaming. Indeed, having consistent
237 access rights per directory enables changing the location of such directories
238 without relying on the destination directory access rights (except those that
239 are required for this operation, see ``LANDLOCK_ACCESS_FS_REFER``
242 Having self-sufficient hierarchies also helps to tighten the required access
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,
245 this depends on data organization, which might not be controlled by developers.
246 In this case, granting read-write access to ``~/tmp/``, instead of write-only
247 access, would potentially allow moving ``~/tmp/`` to a non-readable directory
248 and still keep the ability to list the content of ``~/tmp/``.
250 Layers of file path access rights
251 ---------------------------------
253 Each time a thread enforces a ruleset on itself, it updates its Landlock domain
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 One policy layer grants access to a file path if at least one of its rules
259 encountered on the path grants the access. A sandboxed thread can only access
260 a file path if all its enforced policy layers grant the access as well as all
261 the other system access controls (e.g. filesystem DAC, other LSM policies,
264 Bind mounts and OverlayFS
265 -------------------------
267 Landlock enables restricting access to file hierarchies, which means that these
268 access rights can be propagated with bind mounts (cf.
269 Documentation/filesystems/sharedsubtree.rst) but not with
270 Documentation/filesystems/overlayfs.rst.
272 A bind mount mirrors a source file hierarchy to a destination. The destination
273 hierarchy is then composed of the exact same files, on which Landlock rules can
274 be tied, either via the source or the destination path. These rules restrict
275 access when they are encountered on a path, which means that they can restrict
276 access to multiple file hierarchies at the same time, whether these hierarchies
277 are the result of bind mounts or not.
279 An OverlayFS mount point consists of upper and lower layers. These layers are
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.
293 Every new thread resulting from a :manpage:`clone(2)` inherits Landlock domain
294 restrictions from its parent. This is similar to seccomp inheritance (cf.
295 Documentation/userspace-api/seccomp_filter.rst) or any other LSM dealing with
296 task's :manpage:`credentials(7)`. For instance, one process's thread may apply
297 Landlock rules to itself, but they will not be automatically applied to other
298 sibling threads (unlike POSIX thread credential changes, cf.
301 When a thread sandboxes itself, we have the guarantee that the related security
302 policy will stay enforced on all this thread's descendants. This allows
303 creating standalone and modular security policies per application, which will
304 automatically be composed between themselves according to their runtime parent
310 A sandboxed process has less privileges than a non-sandboxed process and must
311 then be subject to additional restrictions when manipulating another process.
312 To be allowed to use :manpage:`ptrace(2)` and related syscalls on a target
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.
319 Similar to the implicit `Ptrace restrictions`_, we may want to further restrict
320 interactions between sandboxes. Therefore, at ruleset creation time, each
321 Landlock domain can restrict the scope for certain operations, so that these
322 operations can only reach out to processes within the same Landlock domain or in
323 a nested Landlock domain (the "scope").
325 The operations which can be scoped are:
327 ``LANDLOCK_SCOPE_SIGNAL``
328 This limits the sending of signals to target processes which run within the
329 same or a nested Landlock domain.
331 ``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET``
332 This limits the set of abstract :manpage:`unix(7)` sockets to which we can
333 :manpage:`connect(2)` to socket addresses which were created by a process in
334 the same or a nested Landlock domain.
336 A :manpage:`sendto(2)` on a non-connected datagram socket is treated as if
337 it were doing an implicit :manpage:`connect(2)` and will be blocked if the
338 remote end does not stem from the same or a nested Landlock domain.
340 A :manpage:`sendto(2)` on a socket which was previously connected will not
341 be restricted. This works for both datagram and stream sockets.
343 IPC scoping does not support exceptions via :manpage:`landlock_add_rule(2)`.
344 If an operation is scoped within a domain, no rules can be added to allow access
345 to resources or processes outside of the scope.
350 The operations covered by ``LANDLOCK_ACCESS_FS_WRITE_FILE`` and
351 ``LANDLOCK_ACCESS_FS_TRUNCATE`` both change the contents of a file and sometimes
352 overlap in non-intuitive ways. It is recommended to always specify both of
355 A particularly surprising example is :manpage:`creat(2)`. The name suggests
356 that this system call requires the rights to create and write files. However,
357 it also requires the truncate right if an existing file under the same name is
360 It should also be noted that truncating files does not require the
361 ``LANDLOCK_ACCESS_FS_WRITE_FILE`` right. Apart from the :manpage:`truncate(2)`
362 system call, this can also be done through :manpage:`open(2)` with the flags
363 ``O_RDONLY | O_TRUNC``.
365 The truncate right is associated with the opened file (see below).
367 Rights associated with file descriptors
368 ---------------------------------------
370 When opening a file, the availability of the ``LANDLOCK_ACCESS_FS_TRUNCATE`` and
371 ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` rights is associated with the newly created
372 file descriptor and will be used for subsequent truncation and ioctl attempts
373 using :manpage:`ftruncate(2)` and :manpage:`ioctl(2)`. The behavior is similar
374 to opening a file for reading or writing, where permissions are checked during
375 :manpage:`open(2)`, but not during the subsequent :manpage:`read(2)` and
376 :manpage:`write(2)` calls.
378 As a consequence, it is possible that a process has multiple open file
379 descriptors referring to the same file, but Landlock enforces different things
380 when operating with these file descriptors. This can happen when a Landlock
381 ruleset gets enforced and the process keeps file descriptors which were opened
382 both before and after the enforcement. It is also possible to pass such file
383 descriptors between processes, keeping their Landlock properties, even when some
384 of the involved processes do not have an enforced Landlock ruleset.
389 Backward and forward compatibility
390 ----------------------------------
392 Landlock is designed to be compatible with past and future versions of the
393 kernel. This is achieved thanks to the system call attributes and the
394 associated bitflags, particularly the ruleset's ``handled_access_fs``. Making
395 handled access rights explicit enables the kernel and user space to have a clear
396 contract with each other. This is required to make sure sandboxing will not
397 get stricter with a system update, which could break applications.
399 Developers can subscribe to the `Landlock mailing list
400 <https://subspace.kernel.org/lists.linux.dev.html>`_ to knowingly update and
401 test their applications with the latest available features. In the interest of
402 users, and because they may use different kernel versions, it is strongly
403 encouraged to follow a best-effort security approach by checking the Landlock
404 ABI version at runtime and only enforcing the supported features.
406 .. _landlock_abi_versions:
408 Landlock ABI versions
409 ---------------------
411 The Landlock ABI version can be read with the sys_landlock_create_ruleset()
418 abi = landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_VERSION);
422 printf("Landlock is not supported by the current kernel.\n");
425 printf("Landlock is currently disabled.\n");
431 printf("Landlock supports LANDLOCK_ACCESS_FS_REFER.\n");
434 The following kernel interfaces are implicitly supported by the first ABI
435 version. Features only supported from a specific version are explicitly marked
444 .. kernel-doc:: include/uapi/linux/landlock.h
445 :identifiers: fs_access net_access scope
447 Creating a new ruleset
448 ----------------------
450 .. kernel-doc:: security/landlock/syscalls.c
451 :identifiers: sys_landlock_create_ruleset
453 .. kernel-doc:: include/uapi/linux/landlock.h
454 :identifiers: landlock_ruleset_attr
459 .. kernel-doc:: security/landlock/syscalls.c
460 :identifiers: sys_landlock_add_rule
462 .. kernel-doc:: include/uapi/linux/landlock.h
463 :identifiers: landlock_rule_type landlock_path_beneath_attr
464 landlock_net_port_attr
469 .. kernel-doc:: security/landlock/syscalls.c
470 :identifiers: sys_landlock_restrict_self
475 Filesystem topology modification
476 --------------------------------
478 Threads sandboxed with filesystem restrictions cannot modify filesystem
479 topology, whether via :manpage:`mount(2)` or :manpage:`pivot_root(2)`.
480 However, :manpage:`chroot(2)` calls are not denied.
485 Access to regular files and directories can be restricted by Landlock,
486 according to the handled accesses of a ruleset. However, files that do not
487 come from a user-visible filesystem (e.g. pipe, socket), but can still be
488 accessed through ``/proc/<pid>/fd/*``, cannot currently be explicitly
489 restricted. Likewise, some special kernel filesystems such as nsfs, which can
490 be accessed through ``/proc/<pid>/ns/*``, cannot currently be explicitly
491 restricted. However, thanks to the `ptrace restrictions`_, access to such
492 sensitive ``/proc`` files are automatically restricted according to domain
493 hierarchies. Future Landlock evolutions could still enable to explicitly
494 restrict such paths with dedicated ruleset flags.
499 There is a limit of 16 layers of stacked rulesets. This can be an issue for a
500 task willing to enforce a new ruleset in complement to its 16 inherited
501 rulesets. Once this limit is reached, sys_landlock_restrict_self() returns
502 E2BIG. It is then strongly suggested to carefully build rulesets once in the
503 life of a thread, especially for applications able to launch other applications
504 that may also want to sandbox themselves (e.g. shells, container managers,
510 Kernel memory allocated to create rulesets is accounted and can be restricted
511 by the Documentation/admin-guide/cgroup-v1/memory.rst.
516 The ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right restricts the use of
517 :manpage:`ioctl(2)`, but it only applies to *newly opened* device files. This
518 means specifically that pre-existing file descriptors like stdin, stdout and
519 stderr are unaffected.
521 Users should be aware that TTY devices have traditionally permitted to control
522 other processes on the same TTY through the ``TIOCSTI`` and ``TIOCLINUX`` IOCTL
523 commands. Both of these require ``CAP_SYS_ADMIN`` on modern Linux systems, but
524 the behavior is configurable for ``TIOCSTI``.
526 On older systems, it is therefore recommended to close inherited TTY file
527 descriptors, or to reopen them from ``/proc/self/fd/*`` without the
528 ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right, if possible.
530 Landlock's IOCTL support is coarse-grained at the moment, but may become more
531 fine-grained in the future. Until then, users are advised to establish the
532 guarantees that they need through the file hierarchy, by only allowing the
533 ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right on files where it is really required.
538 File renaming and linking (ABI < 2)
539 -----------------------------------
541 Because Landlock targets unprivileged access controls, it needs to properly
542 handle composition of rules. Such property also implies rules nesting.
543 Properly handling multiple layers of rulesets, each one of them able to
544 restrict access to files, also implies inheritance of the ruleset restrictions
545 from a parent to its hierarchy. Because files are identified and restricted by
546 their hierarchy, moving or linking a file from one directory to another implies
547 propagation of the hierarchy constraints, or restriction of these actions
548 according to the potentially lost constraints. To protect against privilege
549 escalations through renaming or linking, and for the sake of simplicity,
550 Landlock previously limited linking and renaming to the same directory.
551 Starting with the Landlock ABI version 2, it is now possible to securely
552 control renaming and linking thanks to the new ``LANDLOCK_ACCESS_FS_REFER``
555 File truncation (ABI < 3)
556 -------------------------
558 File truncation could not be denied before the third Landlock ABI, so it is
559 always allowed when using a kernel that only supports the first or second ABI.
561 Starting with the Landlock ABI version 3, it is now possible to securely control
562 truncation thanks to the new ``LANDLOCK_ACCESS_FS_TRUNCATE`` access right.
564 TCP bind and connect (ABI < 4)
565 ------------------------------
567 Starting with the Landlock ABI version 4, it is now possible to restrict TCP
568 bind and connect actions to only a set of allowed ports thanks to the new
569 ``LANDLOCK_ACCESS_NET_BIND_TCP`` and ``LANDLOCK_ACCESS_NET_CONNECT_TCP``
572 Device IOCTL (ABI < 5)
573 ----------------------
575 IOCTL operations could not be denied before the fifth Landlock ABI, so
576 :manpage:`ioctl(2)` is always allowed when using a kernel that only supports an
579 Starting with the Landlock ABI version 5, it is possible to restrict the use of
580 :manpage:`ioctl(2)` on character and block devices using the new
581 ``LANDLOCK_ACCESS_FS_IOCTL_DEV`` right.
583 Abstract UNIX socket (ABI < 6)
584 ------------------------------
586 Starting with the Landlock ABI version 6, it is possible to restrict
587 connections to an abstract :manpage:`unix(7)` socket by setting
588 ``LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET`` to the ``scoped`` ruleset attribute.
593 Starting with the Landlock ABI version 6, it is possible to restrict
594 :manpage:`signal(7)` sending by setting ``LANDLOCK_SCOPE_SIGNAL`` to the
595 ``scoped`` ruleset attribute.
600 Starting with the Landlock ABI version 7, it is possible to control logging of
601 Landlock audit events with the ``LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF``,
602 ``LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON``, and
603 ``LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF`` flags passed to
604 sys_landlock_restrict_self(). See Documentation/admin-guide/LSM/landlock.rst
605 for more details on audit.
612 Build time configuration
613 ------------------------
615 Landlock was first introduced in Linux 5.13 but it must be configured at build
616 time with ``CONFIG_SECURITY_LANDLOCK=y``. Landlock must also be enabled at boot
617 time like other security modules. The list of security modules enabled by
618 default is set with ``CONFIG_LSM``. The kernel configuration should then
619 contain ``CONFIG_LSM=landlock,[...]`` with ``[...]`` as the list of other
620 potentially useful security modules for the running system (see the
621 ``CONFIG_LSM`` help).
623 Boot time configuration
624 -----------------------
626 If the running kernel does not have ``landlock`` in ``CONFIG_LSM``, then we can
627 enable Landlock by adding ``lsm=landlock,[...]`` to
628 Documentation/admin-guide/kernel-parameters.rst in the boot loader
631 For example, if the current built-in configuration is:
633 .. code-block:: console
635 $ zgrep -h "^CONFIG_LSM=" "/boot/config-$(uname -r)" /proc/config.gz 2>/dev/null
636 CONFIG_LSM="lockdown,yama,integrity,apparmor"
638 ...and if the cmdline doesn't contain ``landlock`` either:
640 .. code-block:: console
642 $ sed -n 's/.*\(\<lsm=\S\+\).*/\1/p' /proc/cmdline
643 lsm=lockdown,yama,integrity,apparmor
645 ...we should configure the boot loader to set a cmdline extending the ``lsm``
646 list with the ``landlock,`` prefix::
648 lsm=landlock,lockdown,yama,integrity,apparmor
650 After a reboot, we can check that Landlock is up and running by looking at
653 .. code-block:: console
655 # dmesg | grep landlock || journalctl -kb -g landlock
656 [ 0.000000] Command line: [...] lsm=landlock,lockdown,yama,integrity,apparmor
657 [ 0.000000] Kernel command line: [...] lsm=landlock,lockdown,yama,integrity,apparmor
658 [ 0.000000] LSM: initializing lsm=lockdown,capability,landlock,yama,integrity,apparmor
659 [ 0.000000] landlock: Up and running.
661 The kernel may be configured at build time to always load the ``lockdown`` and
662 ``capability`` LSMs. In that case, these LSMs will appear at the beginning of
663 the ``LSM: initializing`` log line as well, even if they are not configured in
669 To be able to explicitly allow TCP operations (e.g., adding a network rule with
670 ``LANDLOCK_ACCESS_NET_BIND_TCP``), the kernel must support TCP
671 (``CONFIG_INET=y``). Otherwise, sys_landlock_add_rule() returns an
672 ``EAFNOSUPPORT`` error, which can safely be ignored because this kind of TCP
673 operation is already not possible.
675 Questions and answers
676 =====================
678 What about user space sandbox managers?
679 ---------------------------------------
681 Using user space processes to enforce restrictions on kernel resources can lead
682 to race conditions or inconsistent evaluations (i.e. `Incorrect mirroring of
683 the OS code and state
684 <https://www.ndss-symposium.org/ndss2003/traps-and-pitfalls-practical-problems-system-call-interposition-based-security-tools/>`_).
686 What about namespaces and containers?
687 -------------------------------------
689 Namespaces can help create sandboxes but they are not designed for
690 access-control and then miss useful features for such use case (e.g. no
691 fine-grained restrictions). Moreover, their complexity can lead to security
692 issues, especially when untrusted processes can manipulate them (cf.
693 `Controlling access to user namespaces <https://lwn.net/Articles/673597/>`_).
695 How to disable Landlock audit records?
696 --------------------------------------
698 You might want to put in place filters as explained here:
699 Documentation/admin-guide/LSM/landlock.rst
701 Additional documentation
702 ========================
704 * Documentation/admin-guide/LSM/landlock.rst
705 * Documentation/security/landlock.rst
706 * https://landlock.io
709 .. _samples/landlock/sandboxer.c:
710 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/samples/landlock/sandboxer.c