Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 2 | /* |
| 3 | * security/tomoyo/tomoyo.c |
| 4 | * |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 5 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
Casey Schaufler | 3c4ed7b | 2015-05-02 15:10:46 -0700 | [diff] [blame] | 8 | #include <linux/lsm_hooks.h> |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 9 | #include "common.h" |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 10 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 11 | /** |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 12 | * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread. |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 13 | * |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 14 | * Returns pointer to "struct tomoyo_domain_info" for current thread. |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 15 | */ |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 16 | struct tomoyo_domain_info *tomoyo_domain(void) |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 17 | { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 18 | struct tomoyo_task *s = tomoyo_task(current); |
Casey Schaufler | 43fc460 | 2018-09-21 17:18:07 -0700 | [diff] [blame] | 19 | |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 20 | if (s->old_domain_info && !current->in_execve) { |
| 21 | atomic_dec(&s->old_domain_info->users); |
| 22 | s->old_domain_info = NULL; |
| 23 | } |
| 24 | return s->domain_info; |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 25 | } |
| 26 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 27 | /** |
| 28 | * tomoyo_cred_prepare - Target for security_prepare_creds(). |
| 29 | * |
| 30 | * @new: Pointer to "struct cred". |
| 31 | * @old: Pointer to "struct cred". |
| 32 | * @gfp: Memory allocation flags. |
| 33 | * |
| 34 | * Returns 0. |
| 35 | */ |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 36 | static int tomoyo_cred_prepare(struct cred *new, const struct cred *old, |
| 37 | gfp_t gfp) |
| 38 | { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 39 | /* Restore old_domain_info saved by previous execve() request. */ |
| 40 | struct tomoyo_task *s = tomoyo_task(current); |
Casey Schaufler | 43fc460 | 2018-09-21 17:18:07 -0700 | [diff] [blame] | 41 | |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 42 | if (s->old_domain_info && !current->in_execve) { |
| 43 | atomic_dec(&s->domain_info->users); |
| 44 | s->domain_info = s->old_domain_info; |
| 45 | s->old_domain_info = NULL; |
| 46 | } |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 47 | return 0; |
| 48 | } |
| 49 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 50 | /** |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 51 | * tomoyo_bprm_committed_creds - Target for security_bprm_committed_creds(). |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 52 | * |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 53 | * @bprm: Pointer to "struct linux_binprm". |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 54 | */ |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 55 | static void tomoyo_bprm_committed_creds(struct linux_binprm *bprm) |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 56 | { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 57 | /* Clear old_domain_info saved by execve() request. */ |
| 58 | struct tomoyo_task *s = tomoyo_task(current); |
| 59 | |
| 60 | atomic_dec(&s->old_domain_info->users); |
| 61 | s->old_domain_info = NULL; |
Tetsuo Handa | ec8e6a4 | 2010-02-11 09:43:20 +0900 | [diff] [blame] | 62 | } |
| 63 | |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 64 | #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 65 | /** |
| 66 | * tomoyo_bprm_set_creds - Target for security_bprm_set_creds(). |
| 67 | * |
| 68 | * @bprm: Pointer to "struct linux_binprm". |
| 69 | * |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 70 | * Returns 0. |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 71 | */ |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 72 | static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) |
| 73 | { |
| 74 | /* |
| 75 | * Do only if this function is called for the first time of an execve |
| 76 | * operation. |
| 77 | */ |
Kees Cook | ddb4a14 | 2017-07-18 15:25:23 -0700 | [diff] [blame] | 78 | if (bprm->called_set_creds) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 79 | return 0; |
| 80 | /* |
| 81 | * Load policy if /sbin/tomoyo-init exists and /sbin/init is requested |
| 82 | * for the first time. |
| 83 | */ |
| 84 | if (!tomoyo_policy_loaded) |
| 85 | tomoyo_load_policy(bprm->filename); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 86 | return 0; |
| 87 | } |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 88 | #endif |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 89 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 90 | /** |
| 91 | * tomoyo_bprm_check_security - Target for security_bprm_check(). |
| 92 | * |
| 93 | * @bprm: Pointer to "struct linux_binprm". |
| 94 | * |
| 95 | * Returns 0 on success, negative value otherwise. |
| 96 | */ |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 97 | static int tomoyo_bprm_check_security(struct linux_binprm *bprm) |
| 98 | { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 99 | struct tomoyo_task *s = tomoyo_task(current); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * Execute permission is checked against pathname passed to do_execve() |
| 103 | * using current domain. |
| 104 | */ |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 105 | if (!s->old_domain_info) { |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 106 | const int idx = tomoyo_read_lock(); |
| 107 | const int err = tomoyo_find_next_domain(bprm); |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 108 | |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 109 | tomoyo_read_unlock(idx); |
| 110 | return err; |
| 111 | } |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 112 | /* |
| 113 | * Read permission is checked against interpreters using next domain. |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 114 | */ |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 115 | return tomoyo_check_open_permission(s->domain_info, |
| 116 | &bprm->file->f_path, O_RDONLY); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 117 | } |
| 118 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 119 | /** |
| 120 | * tomoyo_inode_getattr - Target for security_inode_getattr(). |
| 121 | * |
| 122 | * @mnt: Pointer to "struct vfsmount". |
| 123 | * @dentry: Pointer to "struct dentry". |
| 124 | * |
| 125 | * Returns 0 on success, negative value otherwise. |
| 126 | */ |
Al Viro | 3f7036a | 2015-03-08 19:28:30 -0400 | [diff] [blame] | 127 | static int tomoyo_inode_getattr(const struct path *path) |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 128 | { |
Al Viro | 3f7036a | 2015-03-08 19:28:30 -0400 | [diff] [blame] | 129 | return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL); |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 130 | } |
| 131 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 132 | /** |
| 133 | * tomoyo_path_truncate - Target for security_path_truncate(). |
| 134 | * |
| 135 | * @path: Pointer to "struct path". |
| 136 | * |
| 137 | * Returns 0 on success, negative value otherwise. |
| 138 | */ |
Al Viro | 81f4c50 | 2016-03-25 14:22:01 -0400 | [diff] [blame] | 139 | static int tomoyo_path_truncate(const struct path *path) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 140 | { |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 141 | return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path, NULL); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 142 | } |
| 143 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 144 | /** |
| 145 | * tomoyo_path_unlink - Target for security_path_unlink(). |
| 146 | * |
| 147 | * @parent: Pointer to "struct path". |
| 148 | * @dentry: Pointer to "struct dentry". |
| 149 | * |
| 150 | * Returns 0 on success, negative value otherwise. |
| 151 | */ |
Al Viro | 989f74e | 2016-03-25 15:13:39 -0400 | [diff] [blame] | 152 | static int tomoyo_path_unlink(const struct path *parent, struct dentry *dentry) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 153 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 154 | struct path path = { .mnt = parent->mnt, .dentry = dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 155 | |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 156 | return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 157 | } |
| 158 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 159 | /** |
| 160 | * tomoyo_path_mkdir - Target for security_path_mkdir(). |
| 161 | * |
| 162 | * @parent: Pointer to "struct path". |
| 163 | * @dentry: Pointer to "struct dentry". |
| 164 | * @mode: DAC permission mode. |
| 165 | * |
| 166 | * Returns 0 on success, negative value otherwise. |
| 167 | */ |
Al Viro | d360775 | 2016-03-25 15:21:09 -0400 | [diff] [blame] | 168 | static int tomoyo_path_mkdir(const struct path *parent, struct dentry *dentry, |
Al Viro | 4572bef | 2011-11-21 14:56:21 -0500 | [diff] [blame] | 169 | umode_t mode) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 170 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 171 | struct path path = { .mnt = parent->mnt, .dentry = dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 172 | |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 173 | return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path, |
| 174 | mode & S_IALLUGO); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 175 | } |
| 176 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 177 | /** |
| 178 | * tomoyo_path_rmdir - Target for security_path_rmdir(). |
| 179 | * |
| 180 | * @parent: Pointer to "struct path". |
| 181 | * @dentry: Pointer to "struct dentry". |
| 182 | * |
| 183 | * Returns 0 on success, negative value otherwise. |
| 184 | */ |
Al Viro | 989f74e | 2016-03-25 15:13:39 -0400 | [diff] [blame] | 185 | static int tomoyo_path_rmdir(const struct path *parent, struct dentry *dentry) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 186 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 187 | struct path path = { .mnt = parent->mnt, .dentry = dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 188 | |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 189 | return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 190 | } |
| 191 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 192 | /** |
| 193 | * tomoyo_path_symlink - Target for security_path_symlink(). |
| 194 | * |
| 195 | * @parent: Pointer to "struct path". |
| 196 | * @dentry: Pointer to "struct dentry". |
| 197 | * @old_name: Symlink's content. |
| 198 | * |
| 199 | * Returns 0 on success, negative value otherwise. |
| 200 | */ |
Al Viro | d360775 | 2016-03-25 15:21:09 -0400 | [diff] [blame] | 201 | static int tomoyo_path_symlink(const struct path *parent, struct dentry *dentry, |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 202 | const char *old_name) |
| 203 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 204 | struct path path = { .mnt = parent->mnt, .dentry = dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 205 | |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 206 | return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 207 | } |
| 208 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 209 | /** |
| 210 | * tomoyo_path_mknod - Target for security_path_mknod(). |
| 211 | * |
| 212 | * @parent: Pointer to "struct path". |
| 213 | * @dentry: Pointer to "struct dentry". |
| 214 | * @mode: DAC permission mode. |
| 215 | * @dev: Device attributes. |
| 216 | * |
| 217 | * Returns 0 on success, negative value otherwise. |
| 218 | */ |
Al Viro | d360775 | 2016-03-25 15:21:09 -0400 | [diff] [blame] | 219 | static int tomoyo_path_mknod(const struct path *parent, struct dentry *dentry, |
Al Viro | 04fc66e | 2011-11-21 14:58:38 -0500 | [diff] [blame] | 220 | umode_t mode, unsigned int dev) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 221 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 222 | struct path path = { .mnt = parent->mnt, .dentry = dentry }; |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 223 | int type = TOMOYO_TYPE_CREATE; |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 224 | const unsigned int perm = mode & S_IALLUGO; |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 225 | |
| 226 | switch (mode & S_IFMT) { |
| 227 | case S_IFCHR: |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 228 | type = TOMOYO_TYPE_MKCHAR; |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 229 | break; |
| 230 | case S_IFBLK: |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 231 | type = TOMOYO_TYPE_MKBLOCK; |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 232 | break; |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 233 | default: |
| 234 | goto no_dev; |
| 235 | } |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 236 | return tomoyo_mkdev_perm(type, &path, perm, dev); |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 237 | no_dev: |
| 238 | switch (mode & S_IFMT) { |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 239 | case S_IFIFO: |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 240 | type = TOMOYO_TYPE_MKFIFO; |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 241 | break; |
| 242 | case S_IFSOCK: |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 243 | type = TOMOYO_TYPE_MKSOCK; |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 244 | break; |
| 245 | } |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 246 | return tomoyo_path_number_perm(type, &path, perm); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 247 | } |
| 248 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 249 | /** |
| 250 | * tomoyo_path_link - Target for security_path_link(). |
| 251 | * |
| 252 | * @old_dentry: Pointer to "struct dentry". |
| 253 | * @new_dir: Pointer to "struct path". |
| 254 | * @new_dentry: Pointer to "struct dentry". |
| 255 | * |
| 256 | * Returns 0 on success, negative value otherwise. |
| 257 | */ |
Al Viro | 3ccee46 | 2016-03-25 15:27:45 -0400 | [diff] [blame] | 258 | static int tomoyo_path_link(struct dentry *old_dentry, const struct path *new_dir, |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 259 | struct dentry *new_dentry) |
| 260 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 261 | struct path path1 = { .mnt = new_dir->mnt, .dentry = old_dentry }; |
| 262 | struct path path2 = { .mnt = new_dir->mnt, .dentry = new_dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 263 | |
Tetsuo Handa | 97d6931 | 2010-02-16 09:46:15 +0900 | [diff] [blame] | 264 | return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 265 | } |
| 266 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 267 | /** |
| 268 | * tomoyo_path_rename - Target for security_path_rename(). |
| 269 | * |
| 270 | * @old_parent: Pointer to "struct path". |
| 271 | * @old_dentry: Pointer to "struct dentry". |
| 272 | * @new_parent: Pointer to "struct path". |
| 273 | * @new_dentry: Pointer to "struct dentry". |
| 274 | * |
| 275 | * Returns 0 on success, negative value otherwise. |
| 276 | */ |
Al Viro | 3ccee46 | 2016-03-25 15:27:45 -0400 | [diff] [blame] | 277 | static int tomoyo_path_rename(const struct path *old_parent, |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 278 | struct dentry *old_dentry, |
Al Viro | 3ccee46 | 2016-03-25 15:27:45 -0400 | [diff] [blame] | 279 | const struct path *new_parent, |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 280 | struct dentry *new_dentry) |
| 281 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 282 | struct path path1 = { .mnt = old_parent->mnt, .dentry = old_dentry }; |
| 283 | struct path path2 = { .mnt = new_parent->mnt, .dentry = new_dentry }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 284 | |
Tetsuo Handa | 97d6931 | 2010-02-16 09:46:15 +0900 | [diff] [blame] | 285 | return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 286 | } |
| 287 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 288 | /** |
| 289 | * tomoyo_file_fcntl - Target for security_file_fcntl(). |
| 290 | * |
| 291 | * @file: Pointer to "struct file". |
| 292 | * @cmd: Command for fcntl(). |
| 293 | * @arg: Argument for @cmd. |
| 294 | * |
| 295 | * Returns 0 on success, negative value otherwise. |
| 296 | */ |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 297 | static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, |
| 298 | unsigned long arg) |
| 299 | { |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 300 | if (!(cmd == F_SETFL && ((arg ^ file->f_flags) & O_APPEND))) |
| 301 | return 0; |
| 302 | return tomoyo_check_open_permission(tomoyo_domain(), &file->f_path, |
| 303 | O_WRONLY | (arg & O_APPEND)); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 304 | } |
| 305 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 306 | /** |
Eric Paris | 83d4985 | 2012-04-04 13:45:40 -0400 | [diff] [blame] | 307 | * tomoyo_file_open - Target for security_file_open(). |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 308 | * |
| 309 | * @f: Pointer to "struct file". |
| 310 | * @cred: Pointer to "struct cred". |
| 311 | * |
| 312 | * Returns 0 on success, negative value otherwise. |
| 313 | */ |
Al Viro | 9481769 | 2018-07-10 14:13:18 -0400 | [diff] [blame] | 314 | static int tomoyo_file_open(struct file *f) |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 315 | { |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 316 | /* Don't check read permission here if called from do_execve(). */ |
| 317 | if (current->in_execve) |
| 318 | return 0; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 319 | return tomoyo_check_open_permission(tomoyo_domain(), &f->f_path, |
| 320 | f->f_flags); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 321 | } |
| 322 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 323 | /** |
| 324 | * tomoyo_file_ioctl - Target for security_file_ioctl(). |
| 325 | * |
| 326 | * @file: Pointer to "struct file". |
| 327 | * @cmd: Command for ioctl(). |
| 328 | * @arg: Argument for @cmd. |
| 329 | * |
| 330 | * Returns 0 on success, negative value otherwise. |
| 331 | */ |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 332 | static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, |
| 333 | unsigned long arg) |
| 334 | { |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 335 | return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 336 | } |
| 337 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 338 | /** |
| 339 | * tomoyo_path_chmod - Target for security_path_chmod(). |
| 340 | * |
Al Viro | cdcf116 | 2011-12-08 10:51:53 -0500 | [diff] [blame] | 341 | * @path: Pointer to "struct path". |
| 342 | * @mode: DAC permission mode. |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 343 | * |
| 344 | * Returns 0 on success, negative value otherwise. |
| 345 | */ |
Al Viro | be01f9f | 2016-03-25 14:56:23 -0400 | [diff] [blame] | 346 | static int tomoyo_path_chmod(const struct path *path, umode_t mode) |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 347 | { |
Al Viro | cdcf116 | 2011-12-08 10:51:53 -0500 | [diff] [blame] | 348 | return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, path, |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 349 | mode & S_IALLUGO); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 350 | } |
| 351 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 352 | /** |
| 353 | * tomoyo_path_chown - Target for security_path_chown(). |
| 354 | * |
| 355 | * @path: Pointer to "struct path". |
| 356 | * @uid: Owner ID. |
| 357 | * @gid: Group ID. |
| 358 | * |
| 359 | * Returns 0 on success, negative value otherwise. |
| 360 | */ |
Al Viro | 7fd25da | 2016-03-25 14:44:41 -0400 | [diff] [blame] | 361 | static int tomoyo_path_chown(const struct path *path, kuid_t uid, kgid_t gid) |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 362 | { |
| 363 | int error = 0; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 364 | |
Eric W. Biederman | d2b31ca | 2012-06-01 16:14:19 -0600 | [diff] [blame] | 365 | if (uid_valid(uid)) |
| 366 | error = tomoyo_path_number_perm(TOMOYO_TYPE_CHOWN, path, |
| 367 | from_kuid(&init_user_ns, uid)); |
| 368 | if (!error && gid_valid(gid)) |
| 369 | error = tomoyo_path_number_perm(TOMOYO_TYPE_CHGRP, path, |
| 370 | from_kgid(&init_user_ns, gid)); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 371 | return error; |
| 372 | } |
| 373 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 374 | /** |
| 375 | * tomoyo_path_chroot - Target for security_path_chroot(). |
| 376 | * |
| 377 | * @path: Pointer to "struct path". |
| 378 | * |
| 379 | * Returns 0 on success, negative value otherwise. |
| 380 | */ |
Al Viro | 77b286c | 2016-03-25 15:28:43 -0400 | [diff] [blame] | 381 | static int tomoyo_path_chroot(const struct path *path) |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 382 | { |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 383 | return tomoyo_path_perm(TOMOYO_TYPE_CHROOT, path, NULL); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 384 | } |
| 385 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 386 | /** |
| 387 | * tomoyo_sb_mount - Target for security_sb_mount(). |
| 388 | * |
| 389 | * @dev_name: Name of device file. Maybe NULL. |
| 390 | * @path: Pointer to "struct path". |
| 391 | * @type: Name of filesystem type. Maybe NULL. |
| 392 | * @flags: Mount options. |
| 393 | * @data: Optional data. Maybe NULL. |
| 394 | * |
| 395 | * Returns 0 on success, negative value otherwise. |
| 396 | */ |
Al Viro | 8a04c43 | 2016-03-25 14:52:53 -0400 | [diff] [blame] | 397 | static int tomoyo_sb_mount(const char *dev_name, const struct path *path, |
Al Viro | 808d4e3 | 2012-10-11 11:42:01 -0400 | [diff] [blame] | 398 | const char *type, unsigned long flags, void *data) |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 399 | { |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 400 | return tomoyo_mount_permission(dev_name, path, type, flags, data); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 401 | } |
| 402 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 403 | /** |
| 404 | * tomoyo_sb_umount - Target for security_sb_umount(). |
| 405 | * |
| 406 | * @mnt: Pointer to "struct vfsmount". |
| 407 | * @flags: Unmount options. |
| 408 | * |
| 409 | * Returns 0 on success, negative value otherwise. |
| 410 | */ |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 411 | static int tomoyo_sb_umount(struct vfsmount *mnt, int flags) |
| 412 | { |
Kees Cook | 8291798 | 2017-03-29 16:52:58 -0700 | [diff] [blame] | 413 | struct path path = { .mnt = mnt, .dentry = mnt->mnt_root }; |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 414 | |
Tetsuo Handa | 97fb35e | 2011-07-08 13:25:53 +0900 | [diff] [blame] | 415 | return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 416 | } |
| 417 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 418 | /** |
| 419 | * tomoyo_sb_pivotroot - Target for security_sb_pivotroot(). |
| 420 | * |
| 421 | * @old_path: Pointer to "struct path". |
| 422 | * @new_path: Pointer to "struct path". |
| 423 | * |
| 424 | * Returns 0 on success, negative value otherwise. |
| 425 | */ |
Al Viro | 3b73b68 | 2016-03-25 15:31:19 -0400 | [diff] [blame] | 426 | static int tomoyo_sb_pivotroot(const struct path *old_path, const struct path *new_path) |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 427 | { |
Tetsuo Handa | 97d6931 | 2010-02-16 09:46:15 +0900 | [diff] [blame] | 428 | return tomoyo_path2_perm(TOMOYO_TYPE_PIVOT_ROOT, new_path, old_path); |
Tetsuo Handa | 937bf61 | 2009-12-02 21:09:48 +0900 | [diff] [blame] | 429 | } |
| 430 | |
Tetsuo Handa | 059d84d | 2011-09-10 15:23:54 +0900 | [diff] [blame] | 431 | /** |
| 432 | * tomoyo_socket_listen - Check permission for listen(). |
| 433 | * |
| 434 | * @sock: Pointer to "struct socket". |
| 435 | * @backlog: Backlog parameter. |
| 436 | * |
| 437 | * Returns 0 on success, negative value otherwise. |
| 438 | */ |
| 439 | static int tomoyo_socket_listen(struct socket *sock, int backlog) |
| 440 | { |
| 441 | return tomoyo_socket_listen_permission(sock); |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * tomoyo_socket_connect - Check permission for connect(). |
| 446 | * |
| 447 | * @sock: Pointer to "struct socket". |
| 448 | * @addr: Pointer to "struct sockaddr". |
| 449 | * @addr_len: Size of @addr. |
| 450 | * |
| 451 | * Returns 0 on success, negative value otherwise. |
| 452 | */ |
| 453 | static int tomoyo_socket_connect(struct socket *sock, struct sockaddr *addr, |
| 454 | int addr_len) |
| 455 | { |
| 456 | return tomoyo_socket_connect_permission(sock, addr, addr_len); |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * tomoyo_socket_bind - Check permission for bind(). |
| 461 | * |
| 462 | * @sock: Pointer to "struct socket". |
| 463 | * @addr: Pointer to "struct sockaddr". |
| 464 | * @addr_len: Size of @addr. |
| 465 | * |
| 466 | * Returns 0 on success, negative value otherwise. |
| 467 | */ |
| 468 | static int tomoyo_socket_bind(struct socket *sock, struct sockaddr *addr, |
| 469 | int addr_len) |
| 470 | { |
| 471 | return tomoyo_socket_bind_permission(sock, addr, addr_len); |
| 472 | } |
| 473 | |
| 474 | /** |
| 475 | * tomoyo_socket_sendmsg - Check permission for sendmsg(). |
| 476 | * |
| 477 | * @sock: Pointer to "struct socket". |
| 478 | * @msg: Pointer to "struct msghdr". |
| 479 | * @size: Size of message. |
| 480 | * |
| 481 | * Returns 0 on success, negative value otherwise. |
| 482 | */ |
| 483 | static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg, |
| 484 | int size) |
| 485 | { |
| 486 | return tomoyo_socket_sendmsg_permission(sock, msg, size); |
| 487 | } |
| 488 | |
Casey Schaufler | bbd3662 | 2018-11-12 09:30:56 -0800 | [diff] [blame] | 489 | struct lsm_blob_sizes tomoyo_blob_sizes __lsm_ro_after_init = { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 490 | .lbs_task = sizeof(struct tomoyo_task), |
Casey Schaufler | bbd3662 | 2018-11-12 09:30:56 -0800 | [diff] [blame] | 491 | }; |
| 492 | |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 493 | /** |
| 494 | * tomoyo_task_alloc - Target for security_task_alloc(). |
| 495 | * |
| 496 | * @task: Pointer to "struct task_struct". |
| 497 | * @flags: clone() flags. |
| 498 | * |
| 499 | * Returns 0. |
| 500 | */ |
| 501 | static int tomoyo_task_alloc(struct task_struct *task, |
| 502 | unsigned long clone_flags) |
| 503 | { |
| 504 | struct tomoyo_task *old = tomoyo_task(current); |
| 505 | struct tomoyo_task *new = tomoyo_task(task); |
| 506 | |
| 507 | new->domain_info = old->domain_info; |
| 508 | atomic_inc(&new->domain_info->users); |
| 509 | new->old_domain_info = NULL; |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * tomoyo_task_free - Target for security_task_free(). |
| 515 | * |
| 516 | * @task: Pointer to "struct task_struct". |
| 517 | */ |
| 518 | static void tomoyo_task_free(struct task_struct *task) |
| 519 | { |
| 520 | struct tomoyo_task *s = tomoyo_task(task); |
| 521 | |
| 522 | if (s->domain_info) { |
| 523 | atomic_dec(&s->domain_info->users); |
| 524 | s->domain_info = NULL; |
| 525 | } |
| 526 | if (s->old_domain_info) { |
| 527 | atomic_dec(&s->old_domain_info->users); |
| 528 | s->old_domain_info = NULL; |
| 529 | } |
| 530 | } |
| 531 | |
Tetsuo Handa | c3fa109 | 2009-06-08 12:37:39 +0900 | [diff] [blame] | 532 | /* |
| 533 | * tomoyo_security_ops is a "struct security_operations" which is used for |
| 534 | * registering TOMOYO. |
| 535 | */ |
James Morris | ca97d93 | 2017-02-15 00:18:51 +1100 | [diff] [blame] | 536 | static struct security_hook_list tomoyo_hooks[] __lsm_ro_after_init = { |
Casey Schaufler | e20b043 | 2015-05-02 15:11:36 -0700 | [diff] [blame] | 537 | LSM_HOOK_INIT(cred_prepare, tomoyo_cred_prepare), |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 538 | LSM_HOOK_INIT(bprm_committed_creds, tomoyo_bprm_committed_creds), |
| 539 | LSM_HOOK_INIT(task_alloc, tomoyo_task_alloc), |
| 540 | LSM_HOOK_INIT(task_free, tomoyo_task_free), |
| 541 | #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER |
Casey Schaufler | e20b043 | 2015-05-02 15:11:36 -0700 | [diff] [blame] | 542 | LSM_HOOK_INIT(bprm_set_creds, tomoyo_bprm_set_creds), |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 543 | #endif |
Casey Schaufler | e20b043 | 2015-05-02 15:11:36 -0700 | [diff] [blame] | 544 | LSM_HOOK_INIT(bprm_check_security, tomoyo_bprm_check_security), |
| 545 | LSM_HOOK_INIT(file_fcntl, tomoyo_file_fcntl), |
| 546 | LSM_HOOK_INIT(file_open, tomoyo_file_open), |
| 547 | LSM_HOOK_INIT(path_truncate, tomoyo_path_truncate), |
| 548 | LSM_HOOK_INIT(path_unlink, tomoyo_path_unlink), |
| 549 | LSM_HOOK_INIT(path_mkdir, tomoyo_path_mkdir), |
| 550 | LSM_HOOK_INIT(path_rmdir, tomoyo_path_rmdir), |
| 551 | LSM_HOOK_INIT(path_symlink, tomoyo_path_symlink), |
| 552 | LSM_HOOK_INIT(path_mknod, tomoyo_path_mknod), |
| 553 | LSM_HOOK_INIT(path_link, tomoyo_path_link), |
| 554 | LSM_HOOK_INIT(path_rename, tomoyo_path_rename), |
| 555 | LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr), |
| 556 | LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl), |
| 557 | LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod), |
| 558 | LSM_HOOK_INIT(path_chown, tomoyo_path_chown), |
| 559 | LSM_HOOK_INIT(path_chroot, tomoyo_path_chroot), |
| 560 | LSM_HOOK_INIT(sb_mount, tomoyo_sb_mount), |
| 561 | LSM_HOOK_INIT(sb_umount, tomoyo_sb_umount), |
| 562 | LSM_HOOK_INIT(sb_pivotroot, tomoyo_sb_pivotroot), |
| 563 | LSM_HOOK_INIT(socket_bind, tomoyo_socket_bind), |
| 564 | LSM_HOOK_INIT(socket_connect, tomoyo_socket_connect), |
| 565 | LSM_HOOK_INIT(socket_listen, tomoyo_socket_listen), |
| 566 | LSM_HOOK_INIT(socket_sendmsg, tomoyo_socket_sendmsg), |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 567 | }; |
| 568 | |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 569 | /* Lock for GC. */ |
Lai Jiangshan | 505f14f | 2013-03-16 00:50:53 +0800 | [diff] [blame] | 570 | DEFINE_SRCU(tomoyo_ss); |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 571 | |
Casey Schaufler | 43fc460 | 2018-09-21 17:18:07 -0700 | [diff] [blame] | 572 | int tomoyo_enabled __lsm_ro_after_init = 1; |
| 573 | |
Tetsuo Handa | 0f2a55d | 2011-07-14 14:46:51 +0900 | [diff] [blame] | 574 | /** |
| 575 | * tomoyo_init - Register TOMOYO Linux as a LSM module. |
| 576 | * |
| 577 | * Returns 0. |
| 578 | */ |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 579 | static int __init tomoyo_init(void) |
| 580 | { |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 581 | struct tomoyo_task *s = tomoyo_task(current); |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 582 | |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 583 | /* register ourselves with the security framework */ |
Casey Schaufler | d69dece5 | 2017-01-18 17:09:05 -0800 | [diff] [blame] | 584 | security_add_hooks(tomoyo_hooks, ARRAY_SIZE(tomoyo_hooks), "tomoyo"); |
Tetsuo Handa | cdcf672 | 2019-01-24 18:37:35 +0900 | [diff] [blame] | 585 | pr_info("TOMOYO Linux initialized\n"); |
Tetsuo Handa | 8c6cb98 | 2019-01-19 23:11:40 +0900 | [diff] [blame] | 586 | s->domain_info = &tomoyo_kernel_domain; |
| 587 | atomic_inc(&tomoyo_kernel_domain.users); |
| 588 | s->old_domain_info = NULL; |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 589 | tomoyo_mm_init(); |
Casey Schaufler | 43fc460 | 2018-09-21 17:18:07 -0700 | [diff] [blame] | 590 | |
Kentaro Takeda | f743324 | 2009-02-05 17:18:16 +0900 | [diff] [blame] | 591 | return 0; |
| 592 | } |
| 593 | |
Kees Cook | 3d6e5f6 | 2018-10-10 17:18:23 -0700 | [diff] [blame] | 594 | DEFINE_LSM(tomoyo) = { |
Kees Cook | 07aed2f | 2018-10-10 17:18:24 -0700 | [diff] [blame] | 595 | .name = "tomoyo", |
Casey Schaufler | 43fc460 | 2018-09-21 17:18:07 -0700 | [diff] [blame] | 596 | .enabled = &tomoyo_enabled, |
Kees Cook | a5e2fe7 | 2018-10-12 12:07:39 -0700 | [diff] [blame] | 597 | .flags = LSM_FLAG_LEGACY_MAJOR, |
Casey Schaufler | bbd3662 | 2018-11-12 09:30:56 -0800 | [diff] [blame] | 598 | .blobs = &tomoyo_blob_sizes, |
Kees Cook | 3d6e5f6 | 2018-10-10 17:18:23 -0700 | [diff] [blame] | 599 | .init = tomoyo_init, |
| 600 | }; |