Pull Landlock LSM from James Morris: "Add Landlock, a new LSM from Mickaël Salaün. Briefly, Landlock provides for unprivileged application sandboxing. From Mickaël's cover letter: "The goal of Landlock is to enable to restrict ambient rights (e.g. global filesystem access) for a set of processes. Because Landlock is a stackable LSM [1], it makes possible to create safe security sandboxes as new security layers in addition to the existing system-wide access-controls. This kind of sandbox is expected to help mitigate the security impact of bugs or unexpected/malicious behaviors in user-space applications. Landlock empowers any process, including unprivileged ones, to securely restrict themselves. Landlock is inspired by seccomp-bpf but instead of filtering syscalls and their raw arguments, a Landlock rule can restrict the use of kernel objects like file hierarchies, according to the kernel semantic. Landlock also takes inspiration from other OS sandbox mechanisms: XNU Sandbox, FreeBSD Capsicum or OpenBSD Pledge/Unveil. In this current form, Landlock misses some access-control features. This enables to minimize this patch series and ease review. This series still addresses multiple use cases, especially with the combined use of seccomp-bpf: applications with built-in sandboxing, init systems, security sandbox tools and security-oriented APIs [2]" The cover letter and v34 posting is here: https://lore.kernel.org/linux-security-module/20210422154123.13086-1-mic@digikod.net/ See also: https://landlock.io/ This code has had extensive design discussion and review over several years" Link: https://lore.kernel.org/lkml/50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com/ [1] Link: https://lore.kernel.org/lkml/f646e1c7-33cf-333f-070c-0a40ad0468cd@digikod.net/ [2] * tag 'landlock_v34' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: landlock: Enable user space to infer supported features landlock: Add user and kernel documentation samples/landlock: Add a sandbox manager example selftests/landlock: Add user space tests landlock: Add syscall implementations arch: Wire up Landlock syscalls fs,security: Add sb_delete hook landlock: Support filesystem access-control LSM: Infrastructure management of the superblock landlock: Add ptrace restrictions landlock: Set up the security framework and manage credentials landlock: Add ruleset and domain management landlock: Add object management
Showing the changes to include/uapi (2 of 72 files). Show all
Unified · Split
| @@ -866,8 +866,15 @@ __SYSCALL(__NR_mount_setattr, sys_mount_setattr) · 865 unmodified lines | |||
| 866 | #define __NR_quotactl_path 443 | 866 | #define __NR_quotactl_path 443 |
| 867 | __SYSCALL(__NR_quotactl_path, sys_quotactl_path) | 867 | __SYSCALL(__NR_quotactl_path, sys_quotactl_path) |
| 868 | 868 | ||
| 869 | #define __NR_landlock_create_ruleset 444 | ||
| 870 | __SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset) | ||
| 871 | #define __NR_landlock_add_rule 445 | ||
| 872 | __SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule) | ||
| 873 | #define __NR_landlock_restrict_self 446 | ||
| 874 | __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self) | ||
| 875 | |||
| 869 | #undef __NR_syscalls | 876 | #undef __NR_syscalls |
| 870 | #define __NR_syscalls 444 | 877 | #define __NR_syscalls 447 |
| 871 | 878 | ||
| 872 | /* | 879 | /* |
| 873 | * 32 bit systems traditionally used different | 880 | * 32 bit systems traditionally used different |
| @@ -0,0 +1,137 @@ | |||
| 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 <mic@digikod.net> | ||
| 6 | * Copyright © 2018-2020 ANSSI | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef _UAPI_LINUX_LANDLOCK_H | ||
| 10 | #define _UAPI_LINUX_LANDLOCK_H | ||
| 11 | |||
| 12 | #include <linux/types.h> | ||
| 13 | |||
| 14 | /** | ||
| 15 | * struct landlock_ruleset_attr - Ruleset definition | ||
| 16 | * | ||
| 17 | * Argument of sys_landlock_create_ruleset(). This structure can grow in | ||
| 18 | * future versions. | ||
| 19 | */ | ||
| 20 | struct landlock_ruleset_attr { | ||
| 21 | /** | ||
| 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. This is needed for backward | ||
| 25 | * compatibility reasons. | ||
| 26 | */ | ||
| 27 | __u64 handled_access_fs; | ||
| 28 | }; | ||
| 29 | |||
| 30 | /* | ||
| 31 | * sys_landlock_create_ruleset() flags: | ||
| 32 | * | ||
| 33 | * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI | ||
| 34 | * version. | ||
| 35 | */ | ||
| 36 | #define LANDLOCK_CREATE_RULESET_VERSION (1U << 0) | ||
| 37 | |||
| 38 | /** | ||
| 39 | * enum landlock_rule_type - Landlock rule type | ||
| 40 | * | ||
| 41 | * Argument of sys_landlock_add_rule(). | ||
| 42 | */ | ||
| 43 | enum landlock_rule_type { | ||
| 44 | /** | ||
| 45 | * @LANDLOCK_RULE_PATH_BENEATH: Type of a &struct | ||
| 46 | * landlock_path_beneath_attr . | ||
| 47 | */ | ||
| 48 | LANDLOCK_RULE_PATH_BENEATH = 1, | ||
| 49 | }; | ||
| 50 | |||
| 51 | /** | ||
| 52 | * struct landlock_path_beneath_attr - Path hierarchy definition | ||
| 53 | * | ||
| 54 | * Argument of sys_landlock_add_rule(). | ||
| 55 | */ | ||
| 56 | struct landlock_path_beneath_attr { | ||
| 57 | /** | ||
| 58 | * @allowed_access: Bitmask of allowed actions for this file hierarchy | ||
| 59 | * (cf. `Filesystem flags`_). | ||
| 60 | */ | ||
| 61 | __u64 allowed_access; | ||
| 62 | /** | ||
| 63 | * @parent_fd: File descriptor, open with ``O_PATH``, which identifies | ||
| 64 | * the parent directory of a file hierarchy, or just a file. | ||
| 65 | */ | ||
| 66 | __s32 parent_fd; | ||
| 67 | /* | ||
| 68 | * This struct is packed to avoid trailing reserved members. | ||
| 69 | * Cf. security/landlock/syscalls.c:build_check_abi() | ||
| 70 | */ | ||
| 71 | } __attribute__((packed)); | ||
| 72 | |||
| 73 | /** | ||
| 74 | * DOC: fs_access | ||
| 75 | * | ||
| 76 | * A set of actions on kernel objects may be defined by an attribute (e.g. | ||
| 77 | * &struct landlock_path_beneath_attr) including a bitmask of access. | ||
| 78 | * | ||
| 79 | * Filesystem flags | ||
| 80 | * ~~~~~~~~~~~~~~~~ | ||
| 81 | * | ||
| 82 | * These flags enable to restrict a sandboxed process to a set of actions on | ||
| 83 | * files and directories. Files or directories opened before the sandboxing | ||
| 84 | * are not subject to these restrictions. | ||
| 85 | * | ||
| 86 | * A file can only receive these access rights: | ||
| 87 | * | ||
| 88 | * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file. | ||
| 89 | * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. | ||
| 90 | * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access. | ||
| 91 | * | ||
| 92 | * A directory can receive access rights related to files or directories. The | ||
| 93 | * following access right is applied to the directory itself, and the | ||
| 94 | * directories beneath it: | ||
| 95 | * | ||
| 96 | * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a directory or list its content. | ||
| 97 | * | ||
| 98 | * However, the following access rights only apply to the content of a | ||
| 99 | * directory, not the directory itself: | ||
| 100 | * | ||
| 101 | * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an empty directory or rename one. | ||
| 102 | * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (or rename) a file. | ||
| 103 | * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or rename or link) a character | ||
| 104 | * device. | ||
| 105 | * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or rename) a directory. | ||
| 106 | * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or rename or link) a regular file. | ||
| 107 | * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or rename or link) a UNIX domain | ||
| 108 | * socket. | ||
| 109 | * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe. | ||
| 110 | * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device. | ||
| 111 | * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link. | ||
| 112 | * | ||
| 113 | * .. warning:: | ||
| 114 | * | ||
| 115 | * It is currently not possible to restrict some file-related actions | ||
| 116 | * accessible through these syscall families: :manpage:`chdir(2)`, | ||
| 117 | * :manpage:`truncate(2)`, :manpage:`stat(2)`, :manpage:`flock(2)`, | ||
| 118 | * :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`setxattr(2)`, | ||
| 119 | * :manpage:`utime(2)`, :manpage:`ioctl(2)`, :manpage:`fcntl(2)`, | ||
| 120 | * :manpage:`access(2)`. | ||
| 121 | * Future Landlock evolutions will enable to restrict them. | ||
| 122 | */ | ||
| 123 | #define LANDLOCK_ACCESS_FS_EXECUTE (1ULL << 0) | ||
| 124 | #define LANDLOCK_ACCESS_FS_WRITE_FILE (1ULL << 1) | ||
| 125 | #define LANDLOCK_ACCESS_FS_READ_FILE (1ULL << 2) | ||
| 126 | #define LANDLOCK_ACCESS_FS_READ_DIR (1ULL << 3) | ||
| 127 | #define LANDLOCK_ACCESS_FS_REMOVE_DIR (1ULL << 4) | ||
| 128 | #define LANDLOCK_ACCESS_FS_REMOVE_FILE (1ULL << 5) | ||
| 129 | #define LANDLOCK_ACCESS_FS_MAKE_CHAR (1ULL << 6) | ||
| 130 | #define LANDLOCK_ACCESS_FS_MAKE_DIR (1ULL << 7) | ||
| 131 | #define LANDLOCK_ACCESS_FS_MAKE_REG (1ULL << 8) | ||
| 132 | #define LANDLOCK_ACCESS_FS_MAKE_SOCK (1ULL << 9) | ||
| 133 | #define LANDLOCK_ACCESS_FS_MAKE_FIFO (1ULL << 10) | ||
| 134 | #define LANDLOCK_ACCESS_FS_MAKE_BLOCK (1ULL << 11) | ||
| 135 | #define LANDLOCK_ACCESS_FS_MAKE_SYM (1ULL << 12) | ||
| 136 | |||
| 137 | #endif /* _UAPI_LINUX_LANDLOCK_H */ | ||