aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/super.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-02-07 18:39:12 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-05-15 17:59:26 -0400
commitb8a9f9e183229d163d8ace855cbbb63c209fba3c (patch)
treebbc939ff827c9ec3220bc5c6177c9964d45cc1e6 /fs/ext2/super.c
parentf04c6ce2cfaff4b982a6c8ad37e07c14379c111c (diff)
userns: Convert ext2 to use kuid/kgid where appropriate.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/ext2/super.c')
-rw-r--r--fs/ext2/super.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index e1025c7a437a..38f816071ddb 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -228,13 +228,15 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
228 seq_puts(seq, ",grpid"); 228 seq_puts(seq, ",grpid");
229 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS)) 229 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
230 seq_puts(seq, ",nogrpid"); 230 seq_puts(seq, ",nogrpid");
231 if (sbi->s_resuid != EXT2_DEF_RESUID || 231 if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) ||
232 le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) { 232 le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) {
233 seq_printf(seq, ",resuid=%u", sbi->s_resuid); 233 seq_printf(seq, ",resuid=%u",
234 from_kuid_munged(&init_user_ns, sbi->s_resuid));
234 } 235 }
235 if (sbi->s_resgid != EXT2_DEF_RESGID || 236 if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) ||
236 le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) { 237 le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) {
237 seq_printf(seq, ",resgid=%u", sbi->s_resgid); 238 seq_printf(seq, ",resgid=%u",
239 from_kgid_munged(&init_user_ns, sbi->s_resgid));
238 } 240 }
239 if (test_opt(sb, ERRORS_RO)) { 241 if (test_opt(sb, ERRORS_RO)) {
240 int def_errors = le16_to_cpu(es->s_errors); 242 int def_errors = le16_to_cpu(es->s_errors);
@@ -436,6 +438,8 @@ static int parse_options(char *options, struct super_block *sb)
436 struct ext2_sb_info *sbi = EXT2_SB(sb); 438 struct ext2_sb_info *sbi = EXT2_SB(sb);
437 substring_t args[MAX_OPT_ARGS]; 439 substring_t args[MAX_OPT_ARGS];
438 int option; 440 int option;
441 kuid_t uid;
442 kgid_t gid;
439 443
440 if (!options) 444 if (!options)
441 return 1; 445 return 1;
@@ -462,12 +466,23 @@ static int parse_options(char *options, struct super_block *sb)
462 case Opt_resuid: 466 case Opt_resuid:
463 if (match_int(&args[0], &option)) 467 if (match_int(&args[0], &option))
464 return 0; 468 return 0;
465 sbi->s_resuid = option; 469 uid = make_kuid(current_user_ns(), option);
470 if (!uid_valid(uid)) {
471 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
472 return -1;
473
474 }
475 sbi->s_resuid = uid;
466 break; 476 break;
467 case Opt_resgid: 477 case Opt_resgid:
468 if (match_int(&args[0], &option)) 478 if (match_int(&args[0], &option))
469 return 0; 479 return 0;
470 sbi->s_resgid = option; 480 gid = make_kgid(current_user_ns(), option);
481 if (!gid_valid(gid)) {
482 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
483 return -1;
484 }
485 sbi->s_resgid = gid;
471 break; 486 break;
472 case Opt_sb: 487 case Opt_sb:
473 /* handled by get_sb_block() instead of here */ 488 /* handled by get_sb_block() instead of here */
@@ -841,8 +856,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
841 else 856 else
842 set_opt(sbi->s_mount_opt, ERRORS_RO); 857 set_opt(sbi->s_mount_opt, ERRORS_RO);
843 858
844 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 859 sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
845 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 860 sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
846 861
847 set_opt(sbi->s_mount_opt, RESERVATION); 862 set_opt(sbi->s_mount_opt, RESERVATION);
848 863