|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 | +/* |
| 3 | + * Landlock - User space API |
| 4 | + * |
| 5 | + * Copyright © 2017-2020 Mickaël Salaün <[email protected]> |
| 6 | + * Copyright © 2018-2020 ANSSI |
| 7 | + */ |
| 8 | + |
| 9 | +#ifndef _UAPI_LINUX_LANDLOCK_H |
| 10 | +#define _UAPI_LINUX_LANDLOCK_H |
| 11 | + |
| 12 | +/** |
| 13 | + * DOC: fs_access |
| 14 | + * |
| 15 | + * A set of actions on kernel objects may be defined by an attribute (e.g. |
| 16 | + * &struct landlock_path_beneath_attr) including a bitmask of access. |
| 17 | + * |
| 18 | + * Filesystem flags |
| 19 | + * ~~~~~~~~~~~~~~~~ |
| 20 | + * |
| 21 | + * These flags enable to restrict a sandboxed process to a set of actions on |
| 22 | + * files and directories. Files or directories opened before the sandboxing |
| 23 | + * are not subject to these restrictions. |
| 24 | + * |
| 25 | + * A file can only receive these access rights: |
| 26 | + * |
| 27 | + * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file. |
| 28 | + * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. |
| 29 | + * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access. |
| 30 | + * |
| 31 | + * A directory can receive access rights related to files or directories. The |
| 32 | + * following access right is applied to the directory itself, and the |
| 33 | + * directories beneath it: |
| 34 | + * |
| 35 | + * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a directory or list its content. |
| 36 | + * |
| 37 | + * However, the following access rights only apply to the content of a |
| 38 | + * directory, not the directory itself: |
| 39 | + * |
| 40 | + * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an empty directory or rename one. |
| 41 | + * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (or rename) a file. |
| 42 | + * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or rename or link) a character |
| 43 | + * device. |
| 44 | + * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or rename) a directory. |
| 45 | + * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or rename or link) a regular file. |
| 46 | + * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or rename or link) a UNIX domain |
| 47 | + * socket. |
| 48 | + * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe. |
| 49 | + * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device. |
| 50 | + * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link. |
| 51 | + * |
| 52 | + * .. warning:: |
| 53 | + * |
| 54 | + * It is currently not possible to restrict some file-related actions |
| 55 | + * accessible through these syscall families: :manpage:`chdir(2)`, |
| 56 | + * :manpage:`truncate(2)`, :manpage:`stat(2)`, :manpage:`flock(2)`, |
| 57 | + * :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`setxattr(2)`, |
| 58 | + * :manpage:`utime(2)`, :manpage:`ioctl(2)`, :manpage:`fcntl(2)`, |
| 59 | + * :manpage:`access(2)`. |
| 60 | + * Future Landlock evolutions will enable to restrict them. |
| 61 | + */ |
| 62 | +#define LANDLOCK_ACCESS_FS_EXECUTE (1ULL << 0) |
| 63 | +#define LANDLOCK_ACCESS_FS_WRITE_FILE (1ULL << 1) |
| 64 | +#define LANDLOCK_ACCESS_FS_READ_FILE (1ULL << 2) |
| 65 | +#define LANDLOCK_ACCESS_FS_READ_DIR (1ULL << 3) |
| 66 | +#define LANDLOCK_ACCESS_FS_REMOVE_DIR (1ULL << 4) |
| 67 | +#define LANDLOCK_ACCESS_FS_REMOVE_FILE (1ULL << 5) |
| 68 | +#define LANDLOCK_ACCESS_FS_MAKE_CHAR (1ULL << 6) |
| 69 | +#define LANDLOCK_ACCESS_FS_MAKE_DIR (1ULL << 7) |
| 70 | +#define LANDLOCK_ACCESS_FS_MAKE_REG (1ULL << 8) |
| 71 | +#define LANDLOCK_ACCESS_FS_MAKE_SOCK (1ULL << 9) |
| 72 | +#define LANDLOCK_ACCESS_FS_MAKE_FIFO (1ULL << 10) |
| 73 | +#define LANDLOCK_ACCESS_FS_MAKE_BLOCK (1ULL << 11) |
| 74 | +#define LANDLOCK_ACCESS_FS_MAKE_SYM (1ULL << 12) |
| 75 | + |
| 76 | +#endif /* _UAPI_LINUX_LANDLOCK_H */ |
0 commit comments