|
15 | 15 | #include <linux/seq_file.h> |
16 | 16 | #include <linux/slab.h> |
17 | 17 | #include <linux/statfs.h> |
| 18 | +#include <linux/user_namespace.h> |
18 | 19 | #include "adfs.h" |
19 | 20 | #include "dir_f.h" |
20 | 21 | #include "dir_fplus.h" |
@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root) |
130 | 131 | { |
131 | 132 | struct adfs_sb_info *asb = ADFS_SB(root->d_sb); |
132 | 133 |
|
133 | | - if (asb->s_uid != 0) |
134 | | - seq_printf(seq, ",uid=%u", asb->s_uid); |
135 | | - if (asb->s_gid != 0) |
136 | | - seq_printf(seq, ",gid=%u", asb->s_gid); |
| 134 | + if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID)) |
| 135 | + seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid)); |
| 136 | + if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID)) |
| 137 | + seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid)); |
137 | 138 | if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK) |
138 | 139 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); |
139 | 140 | if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) |
@@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options) |
175 | 176 | case Opt_uid: |
176 | 177 | if (match_int(args, &option)) |
177 | 178 | return -EINVAL; |
178 | | - asb->s_uid = option; |
| 179 | + asb->s_uid = make_kuid(current_user_ns(), option); |
| 180 | + if (!uid_valid(asb->s_uid)) |
| 181 | + return -EINVAL; |
179 | 182 | break; |
180 | 183 | case Opt_gid: |
181 | 184 | if (match_int(args, &option)) |
182 | 185 | return -EINVAL; |
183 | | - asb->s_gid = option; |
| 186 | + asb->s_gid = make_kgid(current_user_ns(), option); |
| 187 | + if (!gid_valid(asb->s_gid)) |
| 188 | + return -EINVAL; |
184 | 189 | break; |
185 | 190 | case Opt_ownmask: |
186 | 191 | if (match_octal(args, &option)) |
@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) |
369 | 374 | sb->s_fs_info = asb; |
370 | 375 |
|
371 | 376 | /* set default options */ |
372 | | - asb->s_uid = 0; |
373 | | - asb->s_gid = 0; |
| 377 | + asb->s_uid = GLOBAL_ROOT_UID; |
| 378 | + asb->s_gid = GLOBAL_ROOT_GID; |
374 | 379 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; |
375 | 380 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; |
376 | 381 | asb->s_ftsuffix = 0; |
|
0 commit comments