diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:25:39 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-20 09:11:55 -0400 |
commit | 170782eb89462d30302cec12378253115b492b38 (patch) | |
tree | eff2d455057fcd084071487139ba89521f287032 /fs/fat | |
parent | 1a06d420ce9d60b98f5bdf5fd6e4200abfbd3c35 (diff) |
userns: Convert fat to use kuid/kgid where appropriate
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/fat')
-rw-r--r-- | fs/fat/fat.h | 4 | ||||
-rw-r--r-- | fs/fat/file.c | 6 | ||||
-rw-r--r-- | fs/fat/inode.c | 18 |
3 files changed, 17 insertions, 11 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index 2deeeb86f331..7d8e0dcac5d5 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -23,8 +23,8 @@ | |||
23 | #define FAT_ERRORS_RO 3 /* remount r/o on error */ | 23 | #define FAT_ERRORS_RO 3 /* remount r/o on error */ |
24 | 24 | ||
25 | struct fat_mount_options { | 25 | struct fat_mount_options { |
26 | uid_t fs_uid; | 26 | kuid_t fs_uid; |
27 | gid_t fs_gid; | 27 | kgid_t fs_gid; |
28 | unsigned short fs_fmask; | 28 | unsigned short fs_fmask; |
29 | unsigned short fs_dmask; | 29 | unsigned short fs_dmask; |
30 | unsigned short codepage; /* Codepage for shortname conversions */ | 30 | unsigned short codepage; /* Codepage for shortname conversions */ |
diff --git a/fs/fat/file.c b/fs/fat/file.c index e007b8bd8e5e..a62e0ecbe2db 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -352,7 +352,7 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) | |||
352 | { | 352 | { |
353 | umode_t allow_utime = sbi->options.allow_utime; | 353 | umode_t allow_utime = sbi->options.allow_utime; |
354 | 354 | ||
355 | if (current_fsuid() != inode->i_uid) { | 355 | if (!uid_eq(current_fsuid(), inode->i_uid)) { |
356 | if (in_group_p(inode->i_gid)) | 356 | if (in_group_p(inode->i_gid)) |
357 | allow_utime >>= 3; | 357 | allow_utime >>= 3; |
358 | if (allow_utime & MAY_WRITE) | 358 | if (allow_utime & MAY_WRITE) |
@@ -407,9 +407,9 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
407 | } | 407 | } |
408 | 408 | ||
409 | if (((attr->ia_valid & ATTR_UID) && | 409 | if (((attr->ia_valid & ATTR_UID) && |
410 | (attr->ia_uid != sbi->options.fs_uid)) || | 410 | (!uid_eq(attr->ia_uid, sbi->options.fs_uid))) || |
411 | ((attr->ia_valid & ATTR_GID) && | 411 | ((attr->ia_valid & ATTR_GID) && |
412 | (attr->ia_gid != sbi->options.fs_gid)) || | 412 | (!gid_eq(attr->ia_gid, sbi->options.fs_gid))) || |
413 | ((attr->ia_valid & ATTR_MODE) && | 413 | ((attr->ia_valid & ATTR_MODE) && |
414 | (attr->ia_mode & ~FAT_VALID_MODE))) | 414 | (attr->ia_mode & ~FAT_VALID_MODE))) |
415 | error = -EPERM; | 415 | error = -EPERM; |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 05e897fe9866..47d9eb0be886 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -791,10 +791,12 @@ static int fat_show_options(struct seq_file *m, struct dentry *root) | |||
791 | struct fat_mount_options *opts = &sbi->options; | 791 | struct fat_mount_options *opts = &sbi->options; |
792 | int isvfat = opts->isvfat; | 792 | int isvfat = opts->isvfat; |
793 | 793 | ||
794 | if (opts->fs_uid != 0) | 794 | if (!uid_eq(opts->fs_uid, GLOBAL_ROOT_UID)) |
795 | seq_printf(m, ",uid=%u", opts->fs_uid); | 795 | seq_printf(m, ",uid=%u", |
796 | if (opts->fs_gid != 0) | 796 | from_kuid_munged(&init_user_ns, opts->fs_uid)); |
797 | seq_printf(m, ",gid=%u", opts->fs_gid); | 797 | if (!gid_eq(opts->fs_gid, GLOBAL_ROOT_GID)) |
798 | seq_printf(m, ",gid=%u", | ||
799 | from_kgid_munged(&init_user_ns, opts->fs_gid)); | ||
798 | seq_printf(m, ",fmask=%04o", opts->fs_fmask); | 800 | seq_printf(m, ",fmask=%04o", opts->fs_fmask); |
799 | seq_printf(m, ",dmask=%04o", opts->fs_dmask); | 801 | seq_printf(m, ",dmask=%04o", opts->fs_dmask); |
800 | if (opts->allow_utime) | 802 | if (opts->allow_utime) |
@@ -1037,12 +1039,16 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat, | |||
1037 | case Opt_uid: | 1039 | case Opt_uid: |
1038 | if (match_int(&args[0], &option)) | 1040 | if (match_int(&args[0], &option)) |
1039 | return 0; | 1041 | return 0; |
1040 | opts->fs_uid = option; | 1042 | opts->fs_uid = make_kuid(current_user_ns(), option); |
1043 | if (!uid_valid(opts->fs_uid)) | ||
1044 | return 0; | ||
1041 | break; | 1045 | break; |
1042 | case Opt_gid: | 1046 | case Opt_gid: |
1043 | if (match_int(&args[0], &option)) | 1047 | if (match_int(&args[0], &option)) |
1044 | return 0; | 1048 | return 0; |
1045 | opts->fs_gid = option; | 1049 | opts->fs_gid = make_kgid(current_user_ns(), option); |
1050 | if (!gid_valid(opts->fs_gid)) | ||
1051 | return 0; | ||
1046 | break; | 1052 | break; |
1047 | case Opt_umask: | 1053 | case Opt_umask: |
1048 | if (match_octal(&args[0], &option)) | 1054 | if (match_octal(&args[0], &option)) |