Commit 7dc05881b64792e0ea41293e9595cc962a716225
1 parent
c9235f4872
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
userns: Convert debugfs to use kuid/kgid where appropriate.
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Showing 2 changed files with 18 additions and 9 deletions Side-by-side Diff
fs/debugfs/inode.c
... | ... | @@ -128,8 +128,8 @@ |
128 | 128 | } |
129 | 129 | |
130 | 130 | struct debugfs_mount_opts { |
131 | - uid_t uid; | |
132 | - gid_t gid; | |
131 | + kuid_t uid; | |
132 | + kgid_t gid; | |
133 | 133 | umode_t mode; |
134 | 134 | }; |
135 | 135 | |
... | ... | @@ -156,6 +156,8 @@ |
156 | 156 | substring_t args[MAX_OPT_ARGS]; |
157 | 157 | int option; |
158 | 158 | int token; |
159 | + kuid_t uid; | |
160 | + kgid_t gid; | |
159 | 161 | char *p; |
160 | 162 | |
161 | 163 | opts->mode = DEBUGFS_DEFAULT_MODE; |
162 | 164 | |
... | ... | @@ -169,12 +171,18 @@ |
169 | 171 | case Opt_uid: |
170 | 172 | if (match_int(&args[0], &option)) |
171 | 173 | return -EINVAL; |
172 | - opts->uid = option; | |
174 | + uid = make_kuid(current_user_ns(), option); | |
175 | + if (!uid_valid(uid)) | |
176 | + return -EINVAL; | |
177 | + opts->uid = uid; | |
173 | 178 | break; |
174 | 179 | case Opt_gid: |
175 | 180 | if (match_octal(&args[0], &option)) |
176 | 181 | return -EINVAL; |
177 | - opts->gid = option; | |
182 | + gid = make_kgid(current_user_ns(), option); | |
183 | + if (!gid_valid(gid)) | |
184 | + return -EINVAL; | |
185 | + opts->gid = gid; | |
178 | 186 | break; |
179 | 187 | case Opt_mode: |
180 | 188 | if (match_octal(&args[0], &option)) |
... | ... | @@ -226,10 +234,12 @@ |
226 | 234 | struct debugfs_fs_info *fsi = root->d_sb->s_fs_info; |
227 | 235 | struct debugfs_mount_opts *opts = &fsi->mount_opts; |
228 | 236 | |
229 | - if (opts->uid != 0) | |
230 | - seq_printf(m, ",uid=%u", opts->uid); | |
231 | - if (opts->gid != 0) | |
232 | - seq_printf(m, ",gid=%u", opts->gid); | |
237 | + if (!uid_eq(opts->uid, GLOBAL_ROOT_UID)) | |
238 | + seq_printf(m, ",uid=%u", | |
239 | + from_kuid_munged(&init_user_ns, opts->uid)); | |
240 | + if (!gid_eq(opts->gid, GLOBAL_ROOT_GID)) | |
241 | + seq_printf(m, ",gid=%u", | |
242 | + from_kgid_munged(&init_user_ns, opts->gid)); | |
233 | 243 | if (opts->mode != DEBUGFS_DEFAULT_MODE) |
234 | 244 | seq_printf(m, ",mode=%o", opts->mode); |
235 | 245 |