~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/uapi/linux/landlock.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/uapi/linux/landlock.h (Version linux-6.12-rc7) and /include/uapi/linux/landlock.h (Version linux-5.18.19)


  1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux      1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2 /*                                                  2 /*
  3  * Landlock - User space API                        3  * Landlock - User space API
  4  *                                                  4  *
  5  * Copyright © 2017-2020 Mickaël Salaün <mi      5  * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
  6  * Copyright © 2018-2020 ANSSI                     6  * Copyright © 2018-2020 ANSSI
  7  */                                                 7  */
  8                                                     8 
  9 #ifndef _UAPI_LINUX_LANDLOCK_H                      9 #ifndef _UAPI_LINUX_LANDLOCK_H
 10 #define _UAPI_LINUX_LANDLOCK_H                     10 #define _UAPI_LINUX_LANDLOCK_H
 11                                                    11 
 12 #include <linux/types.h>                           12 #include <linux/types.h>
 13                                                    13 
 14 /**                                                14 /**
 15  * struct landlock_ruleset_attr - Ruleset defi !!  15  * struct landlock_ruleset_attr - Ruleset definition
 16  *                                                 16  *
 17  * Argument of sys_landlock_create_ruleset().  !!  17  * Argument of sys_landlock_create_ruleset().  This structure can grow in
 18  *                                             !!  18  * future versions.
 19  * This structure defines a set of *handled ac << 
 20  * different object types, which should be den << 
 21  * enacted.  Vice versa, access rights that ar << 
 22  * not going to be denied by this ruleset when << 
 23  *                                             << 
 24  * For historical reasons, the %LANDLOCK_ACCES << 
 25  * by default, even when its bit is not set in << 
 26  * add new rules with this access right, the b << 
 27  * (cf. `Filesystem flags`_).                  << 
 28  *                                             << 
 29  * The explicit listing of *handled access rig << 
 30  * compatibility reasons.  In most use cases,  << 
 31  * *handle* a wide range or all access rights  << 
 32  * (and that they have tested with a kernel th << 
 33  *                                             << 
 34  * This structure can grow in future Landlock  << 
 35  */                                                19  */
 36 struct landlock_ruleset_attr {                     20 struct landlock_ruleset_attr {
 37         /**                                        21         /**
 38          * @handled_access_fs: Bitmask of hand !!  22          * @handled_access_fs: Bitmask of actions (cf. `Filesystem flags`_)
 39          * (cf. `Filesystem flags`_).          !!  23          * that is handled by this ruleset and should then be forbidden if no
                                                   >>  24          * rule explicitly allow them.  This is needed for backward
                                                   >>  25          * compatibility reasons.
 40          */                                        26          */
 41         __u64 handled_access_fs;                   27         __u64 handled_access_fs;
 42         /**                                    << 
 43          * @handled_access_net: Bitmask of han << 
 44          * flags`_).                           << 
 45          */                                    << 
 46         __u64 handled_access_net;              << 
 47         /**                                    << 
 48          * @scoped: Bitmask of scopes (cf. `Sc << 
 49          * restricting a Landlock domain from  << 
 50          * resources (e.g. IPCs).              << 
 51          */                                    << 
 52         __u64 scoped;                          << 
 53 };                                                 28 };
 54                                                    29 
 55 /*                                                 30 /*
 56  * sys_landlock_create_ruleset() flags:            31  * sys_landlock_create_ruleset() flags:
 57  *                                                 32  *
 58  * - %LANDLOCK_CREATE_RULESET_VERSION: Get the     33  * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI
 59  *   version.                                      34  *   version.
 60  */                                                35  */
 61 /* clang-format off */                             36 /* clang-format off */
 62 #define LANDLOCK_CREATE_RULESET_VERSION            37 #define LANDLOCK_CREATE_RULESET_VERSION                 (1U << 0)
 63 /* clang-format on */                              38 /* clang-format on */
 64                                                    39 
 65 /**                                                40 /**
 66  * enum landlock_rule_type - Landlock rule typ     41  * enum landlock_rule_type - Landlock rule type
 67  *                                                 42  *
 68  * Argument of sys_landlock_add_rule().            43  * Argument of sys_landlock_add_rule().
 69  */                                                44  */
 70 enum landlock_rule_type {                          45 enum landlock_rule_type {
 71         /**                                        46         /**
 72          * @LANDLOCK_RULE_PATH_BENEATH: Type o     47          * @LANDLOCK_RULE_PATH_BENEATH: Type of a &struct
 73          * landlock_path_beneath_attr .            48          * landlock_path_beneath_attr .
 74          */                                        49          */
 75         LANDLOCK_RULE_PATH_BENEATH = 1,            50         LANDLOCK_RULE_PATH_BENEATH = 1,
 76         /**                                    << 
 77          * @LANDLOCK_RULE_NET_PORT: Type of a  << 
 78          * landlock_net_port_attr .            << 
 79          */                                    << 
 80         LANDLOCK_RULE_NET_PORT,                << 
 81 };                                                 51 };
 82                                                    52 
 83 /**                                                53 /**
 84  * struct landlock_path_beneath_attr - Path hi     54  * struct landlock_path_beneath_attr - Path hierarchy definition
 85  *                                                 55  *
 86  * Argument of sys_landlock_add_rule().            56  * Argument of sys_landlock_add_rule().
 87  */                                                57  */
 88 struct landlock_path_beneath_attr {                58 struct landlock_path_beneath_attr {
 89         /**                                        59         /**
 90          * @allowed_access: Bitmask of allowed     60          * @allowed_access: Bitmask of allowed actions for this file hierarchy
 91          * (cf. `Filesystem flags`_).              61          * (cf. `Filesystem flags`_).
 92          */                                        62          */
 93         __u64 allowed_access;                      63         __u64 allowed_access;
 94         /**                                        64         /**
 95          * @parent_fd: File descriptor, prefer     65          * @parent_fd: File descriptor, preferably opened with ``O_PATH``,
 96          * which identifies the parent directo     66          * which identifies the parent directory of a file hierarchy, or just a
 97          * file.                                   67          * file.
 98          */                                        68          */
 99         __s32 parent_fd;                           69         __s32 parent_fd;
100         /*                                         70         /*
101          * This struct is packed to avoid trai     71          * This struct is packed to avoid trailing reserved members.
102          * Cf. security/landlock/syscalls.c:bu     72          * Cf. security/landlock/syscalls.c:build_check_abi()
103          */                                        73          */
104 } __attribute__((packed));                         74 } __attribute__((packed));
105                                                    75 
106 /**                                                76 /**
107  * struct landlock_net_port_attr - Network por << 
108  *                                             << 
109  * Argument of sys_landlock_add_rule().        << 
110  */                                            << 
111 struct landlock_net_port_attr {                << 
112         /**                                    << 
113          * @allowed_access: Bitmask of allowed << 
114          * (cf. `Network flags`_).             << 
115          */                                    << 
116         __u64 allowed_access;                  << 
117         /**                                    << 
118          * @port: Network port in host endiann << 
119          *                                     << 
120          * It should be noted that port 0 pass << 
121          * to an available port from the ephem << 
122          * configured with the ``/proc/sys/net << 
123          * (also used for IPv6).               << 
124          *                                     << 
125          * A Landlock rule with port 0 and the << 
126          * right means that requesting to bind << 
127          * automatically translate to binding  << 
128          */                                    << 
129         __u64 port;                            << 
130 };                                             << 
131                                                << 
132 /**                                            << 
133  * DOC: fs_access                                  77  * DOC: fs_access
134  *                                                 78  *
135  * A set of actions on kernel objects may be d     79  * A set of actions on kernel objects may be defined by an attribute (e.g.
136  * &struct landlock_path_beneath_attr) includi     80  * &struct landlock_path_beneath_attr) including a bitmask of access.
137  *                                                 81  *
138  * Filesystem flags                                82  * Filesystem flags
139  * ~~~~~~~~~~~~~~~~                                83  * ~~~~~~~~~~~~~~~~
140  *                                                 84  *
141  * These flags enable to restrict a sandboxed      85  * These flags enable to restrict a sandboxed process to a set of actions on
142  * files and directories.  Files or directorie     86  * files and directories.  Files or directories opened before the sandboxing
143  * are not subject to these restrictions.          87  * are not subject to these restrictions.
144  *                                                 88  *
145  * The following access rights apply only to f !!  89  * A file can only receive these access rights:
146  *                                                 90  *
147  * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a fi     91  * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file.
148  * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a fi !!  92  * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access.
149  *   opening files for writing, you will often << 
150  *   %LANDLOCK_ACCESS_FS_TRUNCATE right.  In m << 
151  *   truncate existing files when overwriting  << 
152  * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a fil     93  * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access.
153  * - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a  << 
154  *   :manpage:`ftruncate(2)`, :manpage:`creat( << 
155  *   ``O_TRUNC``.  This access right is availa << 
156  *   Landlock ABI.                             << 
157  *                                             << 
158  * Whether an opened file can be truncated wit << 
159  * with `ioctl(2)` is determined during :manpa << 
160  * read and write permissions are checked duri << 
161  * %LANDLOCK_ACCESS_FS_READ_FILE and %LANDLOCK << 
162  *                                                 94  *
163  * A directory can receive access rights relat     95  * A directory can receive access rights related to files or directories.  The
164  * following access right is applied to the di     96  * following access right is applied to the directory itself, and the
165  * directories beneath it:                         97  * directories beneath it:
166  *                                                 98  *
167  * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a dire     99  * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a directory or list its content.
168  *                                                100  *
169  * However, the following access rights only a    101  * However, the following access rights only apply to the content of a
170  * directory, not the directory itself:           102  * directory, not the directory itself:
171  *                                                103  *
172  * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an    104  * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an empty directory or rename one.
173  * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (    105  * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (or rename) a file.
174  * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or    106  * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or rename or link) a character
175  *   device.                                      107  *   device.
176  * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or     108  * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or rename) a directory.
177  * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or     109  * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or rename or link) a regular file.
178  * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or    110  * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or rename or link) a UNIX domain
179  *   socket.                                      111  *   socket.
180  * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or    112  * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe.
181  * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (o    113  * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device.
182  * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or     114  * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link.
183  * - %LANDLOCK_ACCESS_FS_REFER: Link or rename << 
184  *   directory (i.e. reparent a file hierarchy << 
185  *                                             << 
186  *   This access right is available since the  << 
187  *   ABI.                                      << 
188  *                                             << 
189  *   This is the only access right which is de << 
190  *   even if the right is not specified as han << 
191  *   The only way to make a ruleset grant this << 
192  *   for a specific directory by adding a matc << 
193  *                                             << 
194  *   In particular, when using the first Landl << 
195  *   always deny attempts to reparent files be << 
196  *                                             << 
197  *   In addition to the source and destination << 
198  *   %LANDLOCK_ACCESS_FS_REFER access right, t << 
199  *   operation must meet the following constra << 
200  *                                             << 
201  *   * The reparented file may not gain more a << 
202  *     directory than it previously had in the << 
203  *     attempted, the operation results in an  << 
204  *                                             << 
205  *   * When linking or renaming, the ``LANDLOC << 
206  *     respective file type must be granted fo << 
207  *     Otherwise, the operation results in an  << 
208  *                                             << 
209  *   * When renaming, the ``LANDLOCK_ACCESS_FS << 
210  *     respective file type must be granted fo << 
211  *     the operation results in an ``EACCES``  << 
212  *                                             << 
213  *   If multiple requirements are not met, the << 
214  *   precedence over ``EXDEV``.                << 
215  *                                             << 
216  * The following access right applies both to  << 
217  *                                             << 
218  * - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :ma << 
219  *   character or block device.                << 
220  *                                             << 
221  *   This access right applies to all `ioctl(2 << 
222  *   drivers.  However, the following common I << 
223  *   invokable independent of the %LANDLOCK_AC << 
224  *                                             << 
225  *   * IOCTL commands targeting file descripto << 
226  *   * IOCTL commands targeting file descripti << 
227  *   * IOCTL commands targeting file systems ( << 
228  *     ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``F << 
229  *   * Some IOCTL commands which do not make s << 
230  *     whose implementations are safe and retu << 
231  *     (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICL << 
232  *                                             << 
233  *   This access right is available since the  << 
234  *   ABI.                                      << 
235  *                                                115  *
236  * .. warning::                                   116  * .. warning::
237  *                                                117  *
238  *   It is currently not possible to restrict     118  *   It is currently not possible to restrict some file-related actions
239  *   accessible through these syscall families    119  *   accessible through these syscall families: :manpage:`chdir(2)`,
240  *   :manpage:`stat(2)`, :manpage:`flock(2)`,  !! 120  *   :manpage:`truncate(2)`, :manpage:`stat(2)`, :manpage:`flock(2)`,
241  *   :manpage:`chown(2)`, :manpage:`setxattr(2 !! 121  *   :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`setxattr(2)`,
242  *   :manpage:`fcntl(2)`, :manpage:`access(2)` !! 122  *   :manpage:`utime(2)`, :manpage:`ioctl(2)`, :manpage:`fcntl(2)`,
                                                   >> 123  *   :manpage:`access(2)`.
243  *   Future Landlock evolutions will enable to    124  *   Future Landlock evolutions will enable to restrict them.
244  */                                               125  */
245 /* clang-format off */                            126 /* clang-format off */
246 #define LANDLOCK_ACCESS_FS_EXECUTE                127 #define LANDLOCK_ACCESS_FS_EXECUTE                      (1ULL << 0)
247 #define LANDLOCK_ACCESS_FS_WRITE_FILE             128 #define LANDLOCK_ACCESS_FS_WRITE_FILE                   (1ULL << 1)
248 #define LANDLOCK_ACCESS_FS_READ_FILE              129 #define LANDLOCK_ACCESS_FS_READ_FILE                    (1ULL << 2)
249 #define LANDLOCK_ACCESS_FS_READ_DIR               130 #define LANDLOCK_ACCESS_FS_READ_DIR                     (1ULL << 3)
250 #define LANDLOCK_ACCESS_FS_REMOVE_DIR             131 #define LANDLOCK_ACCESS_FS_REMOVE_DIR                   (1ULL << 4)
251 #define LANDLOCK_ACCESS_FS_REMOVE_FILE            132 #define LANDLOCK_ACCESS_FS_REMOVE_FILE                  (1ULL << 5)
252 #define LANDLOCK_ACCESS_FS_MAKE_CHAR              133 #define LANDLOCK_ACCESS_FS_MAKE_CHAR                    (1ULL << 6)
253 #define LANDLOCK_ACCESS_FS_MAKE_DIR               134 #define LANDLOCK_ACCESS_FS_MAKE_DIR                     (1ULL << 7)
254 #define LANDLOCK_ACCESS_FS_MAKE_REG               135 #define LANDLOCK_ACCESS_FS_MAKE_REG                     (1ULL << 8)
255 #define LANDLOCK_ACCESS_FS_MAKE_SOCK              136 #define LANDLOCK_ACCESS_FS_MAKE_SOCK                    (1ULL << 9)
256 #define LANDLOCK_ACCESS_FS_MAKE_FIFO              137 #define LANDLOCK_ACCESS_FS_MAKE_FIFO                    (1ULL << 10)
257 #define LANDLOCK_ACCESS_FS_MAKE_BLOCK             138 #define LANDLOCK_ACCESS_FS_MAKE_BLOCK                   (1ULL << 11)
258 #define LANDLOCK_ACCESS_FS_MAKE_SYM               139 #define LANDLOCK_ACCESS_FS_MAKE_SYM                     (1ULL << 12)
259 #define LANDLOCK_ACCESS_FS_REFER               << 
260 #define LANDLOCK_ACCESS_FS_TRUNCATE            << 
261 #define LANDLOCK_ACCESS_FS_IOCTL_DEV           << 
262 /* clang-format on */                             140 /* clang-format on */
263                                                << 
264 /**                                            << 
265  * DOC: net_access                             << 
266  *                                             << 
267  * Network flags                               << 
268  * ~~~~~~~~~~~~~~~~                            << 
269  *                                             << 
270  * These flags enable to restrict a sandboxed  << 
271  * actions. This is supported since the Landlo << 
272  *                                             << 
273  * The following access rights apply to TCP po << 
274  *                                             << 
275  * - %LANDLOCK_ACCESS_NET_BIND_TCP: Bind a TCP << 
276  * - %LANDLOCK_ACCESS_NET_CONNECT_TCP: Connect << 
277  *   a remote port.                            << 
278  */                                            << 
279 /* clang-format off */                         << 
280 #define LANDLOCK_ACCESS_NET_BIND_TCP           << 
281 #define LANDLOCK_ACCESS_NET_CONNECT_TCP        << 
282 /* clang-format on */                          << 
283                                                << 
284 /**                                            << 
285  * DOC: scope                                  << 
286  *                                             << 
287  * Scope flags                                 << 
288  * ~~~~~~~~~~~                                 << 
289  *                                             << 
290  * These flags enable to isolate a sandboxed p << 
291  * Setting a flag for a ruleset will isolate t << 
292  * connections to resources outside the domain << 
293  *                                             << 
294  * Scopes:                                     << 
295  *                                             << 
296  * - %LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET: Res << 
297  *   connecting to an abstract UNIX socket cre << 
298  *   related Landlock domain (e.g. a parent do << 
299  * - %LANDLOCK_SCOPE_SIGNAL: Restrict a sandbo << 
300  *   to another process outside the domain.    << 
301  */                                            << 
302 /* clang-format off */                         << 
303 #define LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET    << 
304 #define LANDLOCK_SCOPE_SIGNAL                  << 
305 /* clang-format on*/                           << 
306                                                   141 
307 #endif /* _UAPI_LINUX_LANDLOCK_H */               142 #endif /* _UAPI_LINUX_LANDLOCK_H */
308                                                   143 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php