12
12
#include <linux/types.h>
13
13
14
14
/**
15
- * struct landlock_ruleset_attr - Ruleset definition
15
+ * struct landlock_ruleset_attr - Ruleset definition.
16
16
*
17
- * Argument of sys_landlock_create_ruleset(). This structure can grow in
18
- * future versions.
17
+ * Argument of sys_landlock_create_ruleset().
18
+ *
19
+ * This structure defines a set of *handled access rights*, a set of actions on
20
+ * different object types, which should be denied by default when the ruleset is
21
+ * enacted. Vice versa, access rights that are not specifically listed here are
22
+ * not going to be denied by this ruleset when it is enacted.
23
+ *
24
+ * For historical reasons, the %LANDLOCK_ACCESS_FS_REFER right is always denied
25
+ * by default, even when its bit is not set in @handled_access_fs. In order to
26
+ * add new rules with this access right, the bit must still be set explicitly
27
+ * (cf. `Filesystem flags`_).
28
+ *
29
+ * The explicit listing of *handled access rights* is required for backwards
30
+ * compatibility reasons. In most use cases, processes that use Landlock will
31
+ * *handle* a wide range or all access rights that they know about at build time
32
+ * (and that they have tested with a kernel that supported them all).
33
+ *
34
+ * This structure can grow in future Landlock versions.
19
35
*/
20
36
struct landlock_ruleset_attr {
21
37
/**
22
- * @handled_access_fs: Bitmask of actions (cf. `Filesystem flags`_)
23
- * that is handled by this ruleset and should then be forbidden if no
24
- * rule explicitly allow them: it is a deny-by-default list that should
25
- * contain as much Landlock access rights as possible. Indeed, all
26
- * Landlock filesystem access rights that are not part of
27
- * handled_access_fs are allowed. This is needed for backward
28
- * compatibility reasons. One exception is the
29
- * %LANDLOCK_ACCESS_FS_REFER access right, which is always implicitly
30
- * handled, but must still be explicitly handled to add new rules with
31
- * this access right.
38
+ * @handled_access_fs: Bitmask of handled filesystem actions
39
+ * (cf. `Filesystem flags`_).
32
40
*/
33
41
__u64 handled_access_fs ;
34
42
/**
35
- * @handled_access_net: Bitmask of actions (cf. `Network flags`_)
36
- * that is handled by this ruleset and should then be forbidden if no
37
- * rule explicitly allow them.
43
+ * @handled_access_net: Bitmask of handled network actions (cf. `Network
44
+ * flags`_).
38
45
*/
39
46
__u64 handled_access_net ;
40
47
};
@@ -97,20 +104,21 @@ struct landlock_path_beneath_attr {
97
104
*/
98
105
struct landlock_net_port_attr {
99
106
/**
100
- * @allowed_access: Bitmask of allowed access network for a port
107
+ * @allowed_access: Bitmask of allowed network actions for a port
101
108
* (cf. `Network flags`_).
102
109
*/
103
110
__u64 allowed_access ;
104
111
/**
105
112
* @port: Network port in host endianness.
106
113
*
107
- * It should be noted that port 0 passed to :manpage:`bind(2)` will
108
- * bind to an available port from a specific port range. This can be
109
- * configured thanks to the ``/proc/sys/net/ipv4/ip_local_port_range``
110
- * sysctl (also used for IPv6). A Landlock rule with port 0 and the
111
- * ``LANDLOCK_ACCESS_NET_BIND_TCP`` right means that requesting to bind
112
- * on port 0 is allowed and it will automatically translate to binding
113
- * on the related port range.
114
+ * It should be noted that port 0 passed to :manpage:`bind(2)` will bind
115
+ * to an available port from the ephemeral port range. This can be
116
+ * configured with the ``/proc/sys/net/ipv4/ip_local_port_range`` sysctl
117
+ * (also used for IPv6).
118
+ *
119
+ * A Landlock rule with port 0 and the ``LANDLOCK_ACCESS_NET_BIND_TCP``
120
+ * right means that requesting to bind on port 0 is allowed and it will
121
+ * automatically translate to binding on the related port range.
114
122
*/
115
123
__u64 port ;
116
124
};
@@ -131,10 +139,10 @@ struct landlock_net_port_attr {
131
139
* The following access rights apply only to files:
132
140
*
133
141
* - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file.
134
- * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. Note that
135
- * you might additionally need the %LANDLOCK_ACCESS_FS_TRUNCATE right in order
136
- * to overwrite files with :manpage:`open(2)` using ``O_TRUNC`` or
137
- * :manpage:`creat(2)`.
142
+ * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. When
143
+ * opening files for writing, you will often additionally need the
144
+ * %LANDLOCK_ACCESS_FS_TRUNCATE right. In many cases, these system calls
145
+ * truncate existing files when overwriting them (e.g., :manpage:`creat(2)`) .
138
146
* - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access.
139
147
* - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a file with :manpage:`truncate(2)`,
140
148
* :manpage:`ftruncate(2)`, :manpage:`creat(2)`, or :manpage:`open(2)` with
@@ -256,7 +264,7 @@ struct landlock_net_port_attr {
256
264
* These flags enable to restrict a sandboxed process to a set of network
257
265
* actions. This is supported since the Landlock ABI version 4.
258
266
*
259
- * TCP sockets with allowed actions :
267
+ * The following access rights apply to TCP port numbers :
260
268
*
261
269
* - %LANDLOCK_ACCESS_NET_BIND_TCP: Bind a TCP socket to a local port.
262
270
* - %LANDLOCK_ACCESS_NET_CONNECT_TCP: Connect an active TCP socket to
0 commit comments