diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 18:58:38 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-21 06:13:07 -0400 |
commit | c010d1ff4f69c9f4aa331dfd8266262fb1b478ce (patch) | |
tree | 8930c8f28fa0b3cd07d10a8321015b7760abea57 /fs/adfs | |
parent | 9a11f4513c2e308e0025a55b465d377438606445 (diff) |
userns: Convert adfs to use kuid and kgid where appropriate
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/adfs')
-rw-r--r-- | fs/adfs/adfs.h | 4 | ||||
-rw-r--r-- | fs/adfs/inode.c | 4 | ||||
-rw-r--r-- | fs/adfs/super.c | 21 |
3 files changed, 17 insertions, 12 deletions
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h index 718ac1f440c6..585adafb0cc2 100644 --- a/fs/adfs/adfs.h +++ b/fs/adfs/adfs.h | |||
@@ -46,8 +46,8 @@ struct adfs_sb_info { | |||
46 | struct adfs_discmap *s_map; /* bh list containing map */ | 46 | struct adfs_discmap *s_map; /* bh list containing map */ |
47 | struct adfs_dir_ops *s_dir; /* directory operations */ | 47 | struct adfs_dir_ops *s_dir; /* directory operations */ |
48 | 48 | ||
49 | uid_t s_uid; /* owner uid */ | 49 | kuid_t s_uid; /* owner uid */ |
50 | gid_t s_gid; /* owner gid */ | 50 | kgid_t s_gid; /* owner gid */ |
51 | umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ | 51 | umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ |
52 | umode_t s_other_mask; /* ADFS other perm -> unix perm */ | 52 | umode_t s_other_mask; /* ADFS other perm -> unix perm */ |
53 | int s_ftsuffix; /* ,xyz hex filetype suffix option */ | 53 | int s_ftsuffix; /* ,xyz hex filetype suffix option */ |
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c index 1dab6a174d6a..e9bad5093a3f 100644 --- a/fs/adfs/inode.c +++ b/fs/adfs/inode.c | |||
@@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr) | |||
304 | * we can't change the UID or GID of any file - | 304 | * we can't change the UID or GID of any file - |
305 | * we have a global UID/GID in the superblock | 305 | * we have a global UID/GID in the superblock |
306 | */ | 306 | */ |
307 | if ((ia_valid & ATTR_UID && attr->ia_uid != ADFS_SB(sb)->s_uid) || | 307 | if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, ADFS_SB(sb)->s_uid)) || |
308 | (ia_valid & ATTR_GID && attr->ia_gid != ADFS_SB(sb)->s_gid)) | 308 | (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, ADFS_SB(sb)->s_gid))) |
309 | error = -EPERM; | 309 | error = -EPERM; |
310 | 310 | ||
311 | if (error) | 311 | if (error) |
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index bdaec92353c2..22a0d7ed5fa1 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/seq_file.h> | 15 | #include <linux/seq_file.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/statfs.h> | 17 | #include <linux/statfs.h> |
18 | #include <linux/user_namespace.h> | ||
18 | #include "adfs.h" | 19 | #include "adfs.h" |
19 | #include "dir_f.h" | 20 | #include "dir_f.h" |
20 | #include "dir_fplus.h" | 21 | #include "dir_fplus.h" |
@@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root) | |||
130 | { | 131 | { |
131 | struct adfs_sb_info *asb = ADFS_SB(root->d_sb); | 132 | struct adfs_sb_info *asb = ADFS_SB(root->d_sb); |
132 | 133 | ||
133 | if (asb->s_uid != 0) | 134 | if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID)) |
134 | seq_printf(seq, ",uid=%u", asb->s_uid); | 135 | seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid)); |
135 | if (asb->s_gid != 0) | 136 | if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID)) |
136 | seq_printf(seq, ",gid=%u", asb->s_gid); | 137 | seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid)); |
137 | if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK) | 138 | if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK) |
138 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); | 139 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); |
139 | if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) | 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 | case Opt_uid: | 176 | case Opt_uid: |
176 | if (match_int(args, &option)) | 177 | if (match_int(args, &option)) |
177 | return -EINVAL; | 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 | break; | 182 | break; |
180 | case Opt_gid: | 183 | case Opt_gid: |
181 | if (match_int(args, &option)) | 184 | if (match_int(args, &option)) |
182 | return -EINVAL; | 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 | break; | 189 | break; |
185 | case Opt_ownmask: | 190 | case Opt_ownmask: |
186 | if (match_octal(args, &option)) | 191 | if (match_octal(args, &option)) |
@@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
369 | sb->s_fs_info = asb; | 374 | sb->s_fs_info = asb; |
370 | 375 | ||
371 | /* set default options */ | 376 | /* set default options */ |
372 | asb->s_uid = 0; | 377 | asb->s_uid = GLOBAL_ROOT_UID; |
373 | asb->s_gid = 0; | 378 | asb->s_gid = GLOBAL_ROOT_GID; |
374 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; | 379 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; |
375 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; | 380 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; |
376 | asb->s_ftsuffix = 0; | 381 | asb->s_ftsuffix = 0; |