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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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.11-rc3) and /include/uapi/linux/landlock.h (Version linux-5.13.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 };                                                 28 };
 48                                                    29 
 49 /*                                                 30 /*
 50  * sys_landlock_create_ruleset() flags:            31  * sys_landlock_create_ruleset() flags:
 51  *                                                 32  *
 52  * - %LANDLOCK_CREATE_RULESET_VERSION: Get the     33  * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI
 53  *   version.                                      34  *   version.
 54  */                                                35  */
 55 /* clang-format off */                         << 
 56 #define LANDLOCK_CREATE_RULESET_VERSION            36 #define LANDLOCK_CREATE_RULESET_VERSION                 (1U << 0)
 57 /* clang-format on */                          << 
 58                                                    37 
 59 /**                                                38 /**
 60  * enum landlock_rule_type - Landlock rule typ     39  * enum landlock_rule_type - Landlock rule type
 61  *                                                 40  *
 62  * Argument of sys_landlock_add_rule().            41  * Argument of sys_landlock_add_rule().
 63  */                                                42  */
 64 enum landlock_rule_type {                          43 enum landlock_rule_type {
 65         /**                                        44         /**
 66          * @LANDLOCK_RULE_PATH_BENEATH: Type o     45          * @LANDLOCK_RULE_PATH_BENEATH: Type of a &struct
 67          * landlock_path_beneath_attr .            46          * landlock_path_beneath_attr .
 68          */                                        47          */
 69         LANDLOCK_RULE_PATH_BENEATH = 1,            48         LANDLOCK_RULE_PATH_BENEATH = 1,
 70         /**                                    << 
 71          * @LANDLOCK_RULE_NET_PORT: Type of a  << 
 72          * landlock_net_port_attr .            << 
 73          */                                    << 
 74         LANDLOCK_RULE_NET_PORT,                << 
 75 };                                                 49 };
 76                                                    50 
 77 /**                                                51 /**
 78  * struct landlock_path_beneath_attr - Path hi     52  * struct landlock_path_beneath_attr - Path hierarchy definition
 79  *                                                 53  *
 80  * Argument of sys_landlock_add_rule().            54  * Argument of sys_landlock_add_rule().
 81  */                                                55  */
 82 struct landlock_path_beneath_attr {                56 struct landlock_path_beneath_attr {
 83         /**                                        57         /**
 84          * @allowed_access: Bitmask of allowed     58          * @allowed_access: Bitmask of allowed actions for this file hierarchy
 85          * (cf. `Filesystem flags`_).              59          * (cf. `Filesystem flags`_).
 86          */                                        60          */
 87         __u64 allowed_access;                      61         __u64 allowed_access;
 88         /**                                        62         /**
 89          * @parent_fd: File descriptor, prefer !!  63          * @parent_fd: File descriptor, open with ``O_PATH``, which identifies
 90          * which identifies the parent directo !!  64          * the parent directory of a file hierarchy, or just a file.
 91          * file.                               << 
 92          */                                        65          */
 93         __s32 parent_fd;                           66         __s32 parent_fd;
 94         /*                                         67         /*
 95          * This struct is packed to avoid trai     68          * This struct is packed to avoid trailing reserved members.
 96          * Cf. security/landlock/syscalls.c:bu     69          * Cf. security/landlock/syscalls.c:build_check_abi()
 97          */                                        70          */
 98 } __attribute__((packed));                         71 } __attribute__((packed));
 99                                                    72 
100 /**                                                73 /**
101  * struct landlock_net_port_attr - Network por << 
102  *                                             << 
103  * Argument of sys_landlock_add_rule().        << 
104  */                                            << 
105 struct landlock_net_port_attr {                << 
106         /**                                    << 
107          * @allowed_access: Bitmask of allowed << 
108          * (cf. `Network flags`_).             << 
109          */                                    << 
110         __u64 allowed_access;                  << 
111         /**                                    << 
112          * @port: Network port in host endiann << 
113          *                                     << 
114          * It should be noted that port 0 pass << 
115          * to an available port from the ephem << 
116          * configured with the ``/proc/sys/net << 
117          * (also used for IPv6).               << 
118          *                                     << 
119          * A Landlock rule with port 0 and the << 
120          * right means that requesting to bind << 
121          * automatically translate to binding  << 
122          */                                    << 
123         __u64 port;                            << 
124 };                                             << 
125                                                << 
126 /**                                            << 
127  * DOC: fs_access                                  74  * DOC: fs_access
128  *                                                 75  *
129  * A set of actions on kernel objects may be d     76  * A set of actions on kernel objects may be defined by an attribute (e.g.
130  * &struct landlock_path_beneath_attr) includi     77  * &struct landlock_path_beneath_attr) including a bitmask of access.
131  *                                                 78  *
132  * Filesystem flags                                79  * Filesystem flags
133  * ~~~~~~~~~~~~~~~~                                80  * ~~~~~~~~~~~~~~~~
134  *                                                 81  *
135  * These flags enable to restrict a sandboxed      82  * These flags enable to restrict a sandboxed process to a set of actions on
136  * files and directories.  Files or directorie     83  * files and directories.  Files or directories opened before the sandboxing
137  * are not subject to these restrictions.          84  * are not subject to these restrictions.
138  *                                                 85  *
139  * The following access rights apply only to f !!  86  * A file can only receive these access rights:
140  *                                                 87  *
141  * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a fi     88  * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file.
142  * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a fi !!  89  * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access.
143  *   opening files for writing, you will often << 
144  *   %LANDLOCK_ACCESS_FS_TRUNCATE right.  In m << 
145  *   truncate existing files when overwriting  << 
146  * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a fil     90  * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access.
147  * - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a  << 
148  *   :manpage:`ftruncate(2)`, :manpage:`creat( << 
149  *   ``O_TRUNC``.  This access right is availa << 
150  *   Landlock ABI.                             << 
151  *                                             << 
152  * Whether an opened file can be truncated wit << 
153  * with `ioctl(2)` is determined during :manpa << 
154  * read and write permissions are checked duri << 
155  * %LANDLOCK_ACCESS_FS_READ_FILE and %LANDLOCK << 
156  *                                                 91  *
157  * A directory can receive access rights relat     92  * A directory can receive access rights related to files or directories.  The
158  * following access right is applied to the di     93  * following access right is applied to the directory itself, and the
159  * directories beneath it:                         94  * directories beneath it:
160  *                                                 95  *
161  * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a dire     96  * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a directory or list its content.
162  *                                                 97  *
163  * However, the following access rights only a     98  * However, the following access rights only apply to the content of a
164  * directory, not the directory itself:            99  * directory, not the directory itself:
165  *                                                100  *
166  * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an    101  * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an empty directory or rename one.
167  * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (    102  * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (or rename) a file.
168  * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or    103  * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or rename or link) a character
169  *   device.                                      104  *   device.
170  * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or     105  * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or rename) a directory.
171  * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or     106  * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or rename or link) a regular file.
172  * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or    107  * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or rename or link) a UNIX domain
173  *   socket.                                      108  *   socket.
174  * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or    109  * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe.
175  * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (o    110  * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device.
176  * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or     111  * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link.
177  * - %LANDLOCK_ACCESS_FS_REFER: Link or rename << 
178  *   directory (i.e. reparent a file hierarchy << 
179  *                                             << 
180  *   This access right is available since the  << 
181  *   ABI.                                      << 
182  *                                             << 
183  *   This is the only access right which is de << 
184  *   even if the right is not specified as han << 
185  *   The only way to make a ruleset grant this << 
186  *   for a specific directory by adding a matc << 
187  *                                             << 
188  *   In particular, when using the first Landl << 
189  *   always deny attempts to reparent files be << 
190  *                                             << 
191  *   In addition to the source and destination << 
192  *   %LANDLOCK_ACCESS_FS_REFER access right, t << 
193  *   operation must meet the following constra << 
194  *                                             << 
195  *   * The reparented file may not gain more a << 
196  *     directory than it previously had in the << 
197  *     attempted, the operation results in an  << 
198  *                                             << 
199  *   * When linking or renaming, the ``LANDLOC << 
200  *     respective file type must be granted fo << 
201  *     Otherwise, the operation results in an  << 
202  *                                             << 
203  *   * When renaming, the ``LANDLOCK_ACCESS_FS << 
204  *     respective file type must be granted fo << 
205  *     the operation results in an ``EACCES``  << 
206  *                                             << 
207  *   If multiple requirements are not met, the << 
208  *   precedence over ``EXDEV``.                << 
209  *                                             << 
210  * The following access right applies both to  << 
211  *                                             << 
212  * - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :ma << 
213  *   character or block device.                << 
214  *                                             << 
215  *   This access right applies to all `ioctl(2 << 
216  *   drivers.  However, the following common I << 
217  *   invokable independent of the %LANDLOCK_AC << 
218  *                                             << 
219  *   * IOCTL commands targeting file descripto << 
220  *   * IOCTL commands targeting file descripti << 
221  *   * IOCTL commands targeting file systems ( << 
222  *     ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``F << 
223  *   * Some IOCTL commands which do not make s << 
224  *     whose implementations are safe and retu << 
225  *     (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICL << 
226  *                                             << 
227  *   This access right is available since the  << 
228  *   ABI.                                      << 
229  *                                                112  *
230  * .. warning::                                   113  * .. warning::
231  *                                                114  *
232  *   It is currently not possible to restrict     115  *   It is currently not possible to restrict some file-related actions
233  *   accessible through these syscall families    116  *   accessible through these syscall families: :manpage:`chdir(2)`,
234  *   :manpage:`stat(2)`, :manpage:`flock(2)`,  !! 117  *   :manpage:`truncate(2)`, :manpage:`stat(2)`, :manpage:`flock(2)`,
235  *   :manpage:`chown(2)`, :manpage:`setxattr(2 !! 118  *   :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`setxattr(2)`,
236  *   :manpage:`fcntl(2)`, :manpage:`access(2)` !! 119  *   :manpage:`utime(2)`, :manpage:`ioctl(2)`, :manpage:`fcntl(2)`,
                                                   >> 120  *   :manpage:`access(2)`.
237  *   Future Landlock evolutions will enable to    121  *   Future Landlock evolutions will enable to restrict them.
238  */                                               122  */
239 /* clang-format off */                         << 
240 #define LANDLOCK_ACCESS_FS_EXECUTE                123 #define LANDLOCK_ACCESS_FS_EXECUTE                      (1ULL << 0)
241 #define LANDLOCK_ACCESS_FS_WRITE_FILE             124 #define LANDLOCK_ACCESS_FS_WRITE_FILE                   (1ULL << 1)
242 #define LANDLOCK_ACCESS_FS_READ_FILE              125 #define LANDLOCK_ACCESS_FS_READ_FILE                    (1ULL << 2)
243 #define LANDLOCK_ACCESS_FS_READ_DIR               126 #define LANDLOCK_ACCESS_FS_READ_DIR                     (1ULL << 3)
244 #define LANDLOCK_ACCESS_FS_REMOVE_DIR             127 #define LANDLOCK_ACCESS_FS_REMOVE_DIR                   (1ULL << 4)
245 #define LANDLOCK_ACCESS_FS_REMOVE_FILE            128 #define LANDLOCK_ACCESS_FS_REMOVE_FILE                  (1ULL << 5)
246 #define LANDLOCK_ACCESS_FS_MAKE_CHAR              129 #define LANDLOCK_ACCESS_FS_MAKE_CHAR                    (1ULL << 6)
247 #define LANDLOCK_ACCESS_FS_MAKE_DIR               130 #define LANDLOCK_ACCESS_FS_MAKE_DIR                     (1ULL << 7)
248 #define LANDLOCK_ACCESS_FS_MAKE_REG               131 #define LANDLOCK_ACCESS_FS_MAKE_REG                     (1ULL << 8)
249 #define LANDLOCK_ACCESS_FS_MAKE_SOCK              132 #define LANDLOCK_ACCESS_FS_MAKE_SOCK                    (1ULL << 9)
250 #define LANDLOCK_ACCESS_FS_MAKE_FIFO              133 #define LANDLOCK_ACCESS_FS_MAKE_FIFO                    (1ULL << 10)
251 #define LANDLOCK_ACCESS_FS_MAKE_BLOCK             134 #define LANDLOCK_ACCESS_FS_MAKE_BLOCK                   (1ULL << 11)
252 #define LANDLOCK_ACCESS_FS_MAKE_SYM               135 #define LANDLOCK_ACCESS_FS_MAKE_SYM                     (1ULL << 12)
253 #define LANDLOCK_ACCESS_FS_REFER               << 
254 #define LANDLOCK_ACCESS_FS_TRUNCATE            << 
255 #define LANDLOCK_ACCESS_FS_IOCTL_DEV           << 
256 /* clang-format on */                          << 
257                                                   136 
258 /**                                            << 
259  * DOC: net_access                             << 
260  *                                             << 
261  * Network flags                               << 
262  * ~~~~~~~~~~~~~~~~                            << 
263  *                                             << 
264  * These flags enable to restrict a sandboxed  << 
265  * actions. This is supported since the Landlo << 
266  *                                             << 
267  * The following access rights apply to TCP po << 
268  *                                             << 
269  * - %LANDLOCK_ACCESS_NET_BIND_TCP: Bind a TCP << 
270  * - %LANDLOCK_ACCESS_NET_CONNECT_TCP: Connect << 
271  *   a remote port.                            << 
272  */                                            << 
273 /* clang-format off */                         << 
274 #define LANDLOCK_ACCESS_NET_BIND_TCP           << 
275 #define LANDLOCK_ACCESS_NET_CONNECT_TCP        << 
276 /* clang-format on */                          << 
277 #endif /* _UAPI_LINUX_LANDLOCK_H */               137 #endif /* _UAPI_LINUX_LANDLOCK_H */
278                                                   138 

~ [ 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