]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/landlock_restrict_self.2
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man2 / landlock_restrict_self.2
CommitLineData
3f7e4f80
MS
1.\" Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
2.\" Copyright © 2019-2020 ANSSI
3.\" Copyright © 2021 Microsoft Corporation
4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
3f7e4f80 6.\"
45186a5d 7.TH LANDLOCK_RESTRICT_SELF 2 2021-06-27 "Linux man-pages (unreleased)"
3f7e4f80
MS
8.SH NAME
9landlock_restrict_self \- enforce a Landlock ruleset
127d9e7f
AC
10.SH LIBRARY
11Standard C library
8fc3b2cf 12.RI ( libc ", " \-lc )
3f7e4f80
MS
13.SH SYNOPSIS
14.nf
15.BR "#include <linux/landlock.h>" " /* Definition of " LANDLOCK_* " constants */"
16.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
17.PP
18.BI "int syscall(SYS_landlock_restrict_self, int " ruleset_fd ,
085a9296 19.BI " uint32_t " flags );
3f7e4f80
MS
20.SH DESCRIPTION
21Once a Landlock ruleset is populated with the desired rules, the
22.BR landlock_restrict_self ()
23system call enables enforcing this ruleset on the calling thread.
24See
25.BR landlock (7)
26for a global overview.
27.PP
085a9296
AC
28A thread can be restricted with multiple rulesets that are then
29composed together to form the thread's Landlock domain.
30This can be seen as a stack of rulesets but
31it is implemented in a more efficient way.
32A domain can only be updated in such a way that
33the constraints of each past and future composed rulesets
34will restrict the thread and its future children for their entire life.
3f7e4f80 35It is then possible to gradually enforce tailored access control policies
61136d55 36with multiple independent rulesets coming from different sources
3f7e4f80
MS
37(e.g., init system configuration, user session policy,
38built-in application policy).
39However, most applications should only need one call to
40.BR landlock_restrict_self ()
41and they should avoid arbitrary numbers of such calls because of the
42composed rulesets limit.
43Instead, developers are encouraged to build a tailored ruleset thanks to
44multiple calls to
45.BR landlock_add_rule (2).
46.PP
47In order to enforce a ruleset, either the caller must have the
48.B CAP_SYS_ADMIN
49capability in its user namespace, or the thread must already have the
50.I no_new_privs
51bit set.
52As for
53.BR seccomp (2),
085a9296
AC
54this avoids scenarios where unprivileged processes can affect
55the behavior of privileged children (e.g., because of set-user-ID binaries).
3f7e4f80
MS
56If that bit was not already set by an ancestor of this thread,
57the thread must make the following call:
58.IP
59.EX
60prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
61.EE
62.PP
63.I ruleset_fd
64is a Landlock ruleset file descriptor obtained with
65.BR landlock_create_ruleset (2)
66and fully populated with a set of calls to
67.BR landlock_add_rule (2).
68.PP
69.I flags
70must be 0.
71.SH RETURN VALUE
72On success,
73.BR landlock_restrict_self ()
74returns 0.
75.SH ERRORS
76.BR landlock_restrict_self ()
085a9296 77can fail for the following reasons:
3f7e4f80
MS
78.TP
79.B EOPNOTSUPP
80Landlock is supported by the kernel but disabled at boot time.
81.TP
82.B EINVAL
83.I flags
84is not 0.
85.TP
86.B EBADF
87.I ruleset_fd
88is not a file descriptor for the current thread.
89.TP
90.B EBADFD
91.I ruleset_fd
92is not a ruleset file descriptor.
93.TP
94.B EPERM
95.I ruleset_fd
96has no read access to the underlying ruleset,
97or the calling thread is not running with
98.IR no_new_privs ,
99or it doesn't have the
100.B CAP_SYS_ADMIN
101in its user namespace.
102.TP
103.B E2BIG
104The maximum number of composed rulesets is reached for the calling thread.
105This limit is currently 64.
106.SH VERSIONS
107Landlock was added in Linux 5.13.
3113c7f3 108.SH STANDARDS
3f7e4f80
MS
109This system call is Linux-specific.
110.SH EXAMPLES
111See
112.BR landlock (7).
113.SH SEE ALSO
114.BR landlock_create_ruleset (2),
115.BR landlock_add_rule (2),
116.BR landlock (7)