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_ADD_RULE 2 2021-06-27 "Linux man-pages (unreleased)"
9 landlock_add_rule \- add a new Landlock rule to a 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_add_rule, int " ruleset_fd ,
19 .BI " enum landlock_rule_type " rule_type ,
20 .BI " const void *" rule_attr ", uint32_t " flags );
23 A Landlock rule describes an action on an object.
24 An object is currently a file hierarchy,
25 and the related filesystem actions
26 are defined with a set of access rights.
28 .BR landlock_add_rule ()
29 system call enables adding a new Landlock rule to an existing ruleset
31 .BR landlock_create_ruleset (2).
34 for a global overview.
37 is a Landlock ruleset file descriptor obtained with
38 .BR landlock_create_ruleset (2).
41 identifies the structure type pointed to by
43 Currently, Linux supports the following
47 .B LANDLOCK_RULE_PATH_BENEATH
48 This defines the object type as a file hierarchy.
51 points to the following structure:
55 struct landlock_path_beneath_attr {
56 uint64_t allowed_access;
58 } __attribute__((packed));
63 contains a bitmask of allowed filesystem actions for this file hierarchy
70 is an opened file descriptor, preferably with the
73 which identifies the parent directory of the file hierarchy or
80 .BR landlock_add_rule ()
83 .BR landlock_add_rule ()
84 can failed for the following reasons:
87 Landlock is supported by the kernel but disabled at boot time.
91 is not 0, or the rule accesses are inconsistent (i.e.,
92 .I rule_attr->allowed_access
93 is not a subset of the ruleset handled accesses).
97 .I rule_attr->allowed_access
102 is not a file descriptor for the current thread,
105 is not a file descriptor as expected.
109 is not a ruleset file descriptor,
112 is not the expected file descriptor type.
116 has no write access to the underlying ruleset.
120 was not a valid address.
122 Landlock was added in Linux 5.13.
124 This system call is Linux-specific.
129 .BR landlock_create_ruleset (2),
130 .BR landlock_restrict_self (2),