Commit 170782eb89462d30302cec12378253115b492b38
1 parent
1a06d420ce
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>
Showing 4 changed files with 17 additions and 12 deletions Side-by-side Diff
fs/fat/fat.h
... | ... | @@ -23,8 +23,8 @@ |
23 | 23 | #define FAT_ERRORS_RO 3 /* remount r/o on error */ |
24 | 24 | |
25 | 25 | struct fat_mount_options { |
26 | - uid_t fs_uid; | |
27 | - gid_t fs_gid; | |
26 | + kuid_t fs_uid; | |
27 | + kgid_t fs_gid; | |
28 | 28 | unsigned short fs_fmask; |
29 | 29 | unsigned short fs_dmask; |
30 | 30 | unsigned short codepage; /* Codepage for shortname conversions */ |
fs/fat/file.c
... | ... | @@ -352,7 +352,7 @@ |
352 | 352 | { |
353 | 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 | 356 | if (in_group_p(inode->i_gid)) |
357 | 357 | allow_utime >>= 3; |
358 | 358 | if (allow_utime & MAY_WRITE) |
359 | 359 | |
... | ... | @@ -407,9 +407,9 @@ |
407 | 407 | } |
408 | 408 | |
409 | 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 | 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 | 413 | ((attr->ia_valid & ATTR_MODE) && |
414 | 414 | (attr->ia_mode & ~FAT_VALID_MODE))) |
415 | 415 | error = -EPERM; |
fs/fat/inode.c
... | ... | @@ -791,10 +791,12 @@ |
791 | 791 | struct fat_mount_options *opts = &sbi->options; |
792 | 792 | int isvfat = opts->isvfat; |
793 | 793 | |
794 | - if (opts->fs_uid != 0) | |
795 | - seq_printf(m, ",uid=%u", opts->fs_uid); | |
796 | - if (opts->fs_gid != 0) | |
797 | - seq_printf(m, ",gid=%u", opts->fs_gid); | |
794 | + if (!uid_eq(opts->fs_uid, GLOBAL_ROOT_UID)) | |
795 | + seq_printf(m, ",uid=%u", | |
796 | + from_kuid_munged(&init_user_ns, opts->fs_uid)); | |
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 | 800 | seq_printf(m, ",fmask=%04o", opts->fs_fmask); |
799 | 801 | seq_printf(m, ",dmask=%04o", opts->fs_dmask); |
800 | 802 | if (opts->allow_utime) |
801 | 803 | |
... | ... | @@ -1037,12 +1039,16 @@ |
1037 | 1039 | case Opt_uid: |
1038 | 1040 | if (match_int(&args[0], &option)) |
1039 | 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 | 1045 | break; |
1042 | 1046 | case Opt_gid: |
1043 | 1047 | if (match_int(&args[0], &option)) |
1044 | 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 | 1052 | break; |
1047 | 1053 | case Opt_umask: |
1048 | 1054 | if (match_octal(&args[0], &option)) |