1 .\" Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
2 .\" Copyright © 2019-2020 ANSSI
3 .\" Copyright © 2021 Microsoft Corporation
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH LANDLOCK_RESTRICT_SELF 2 2022-09-09 "Linux man-pages (unreleased)"
9 landlock_restrict_self \- enforce a Landlock ruleset
12 .RI ( libc ", " \-lc )
15 .BR "#include <linux/landlock.h>" " /* Definition of " LANDLOCK_* " constants */"
16 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
18 .BI "int syscall(SYS_landlock_restrict_self, int " ruleset_fd ,
19 .BI " uint32_t " flags );
21 Once a Landlock ruleset is populated with the desired rules, the
22 .BR landlock_restrict_self ()
23 system call enables enforcing this ruleset on the calling thread.
26 for a global overview.
28 A thread can be restricted with multiple rulesets that are then
29 composed together to form the thread's Landlock domain.
30 This can be seen as a stack of rulesets but
31 it is implemented in a more efficient way.
32 A domain can only be updated in such a way that
33 the constraints of each past and future composed rulesets
34 will restrict the thread and its future children for their entire life.
35 It is then possible to gradually enforce tailored access control policies
36 with multiple independent rulesets coming from different sources
37 (e.g., init system configuration, user session policy,
38 built-in application policy).
39 However, most applications should only need one call to
40 .BR landlock_restrict_self ()
41 and they should avoid arbitrary numbers of such calls because of the
42 composed rulesets limit.
43 Instead, developers are encouraged to build a tailored ruleset thanks to
45 .BR landlock_add_rule (2).
47 In order to enforce a ruleset, either the caller must have the
49 capability in its user namespace, or the thread must already have the
54 this avoids scenarios where unprivileged processes can affect
55 the behavior of privileged children (e.g., because of set-user-ID binaries).
56 If that bit was not already set by an ancestor of this thread,
57 the thread must make the following call:
60 prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
64 is a Landlock ruleset file descriptor obtained with
65 .BR landlock_create_ruleset (2)
66 and fully populated with a set of calls to
67 .BR landlock_add_rule (2).
73 .BR landlock_restrict_self ()
76 .BR landlock_restrict_self ()
77 can fail for the following reasons:
80 Landlock is supported by the kernel but disabled at boot time.
88 is not a file descriptor for the current thread.
92 is not a ruleset file descriptor.
96 has no read access to the underlying ruleset,
97 or the calling thread is not running with
99 or it doesn't have the
101 in its user namespace.
104 The maximum number of composed rulesets is reached for the calling thread.
105 This limit is currently 64.
107 Landlock was added in Linux 5.13.
109 This system call is Linux-specific.
114 .BR landlock_create_ruleset (2),
115 .BR landlock_add_rule (2),