diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 18:41:24 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-15 17:59:27 -0400 |
commit | 1523299d5817773e344d135d4b1c485f269400bc (patch) | |
tree | eef0768f5418facb1d37dbe99f346b9d77223f9f /fs/ext3/super.c | |
parent | b8a9f9e183229d163d8ace855cbbb63c209fba3c (diff) |
userns: Convert ext3 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/ext3/super.c')
-rw-r--r-- | fs/ext3/super.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index cf0b5921cf0f..94ef7e616129 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -617,13 +617,15 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root) | |||
617 | seq_puts(seq, ",grpid"); | 617 | seq_puts(seq, ",grpid"); |
618 | if (!test_opt(sb, GRPID) && (def_mount_opts & EXT3_DEFM_BSDGROUPS)) | 618 | if (!test_opt(sb, GRPID) && (def_mount_opts & EXT3_DEFM_BSDGROUPS)) |
619 | seq_puts(seq, ",nogrpid"); | 619 | seq_puts(seq, ",nogrpid"); |
620 | if (sbi->s_resuid != EXT3_DEF_RESUID || | 620 | if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT3_DEF_RESUID)) || |
621 | le16_to_cpu(es->s_def_resuid) != EXT3_DEF_RESUID) { | 621 | le16_to_cpu(es->s_def_resuid) != EXT3_DEF_RESUID) { |
622 | seq_printf(seq, ",resuid=%u", sbi->s_resuid); | 622 | seq_printf(seq, ",resuid=%u", |
623 | from_kuid_munged(&init_user_ns, sbi->s_resuid)); | ||
623 | } | 624 | } |
624 | if (sbi->s_resgid != EXT3_DEF_RESGID || | 625 | if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT3_DEF_RESGID)) || |
625 | le16_to_cpu(es->s_def_resgid) != EXT3_DEF_RESGID) { | 626 | le16_to_cpu(es->s_def_resgid) != EXT3_DEF_RESGID) { |
626 | seq_printf(seq, ",resgid=%u", sbi->s_resgid); | 627 | seq_printf(seq, ",resgid=%u", |
628 | from_kgid_munged(&init_user_ns, sbi->s_resgid)); | ||
627 | } | 629 | } |
628 | if (test_opt(sb, ERRORS_RO)) { | 630 | if (test_opt(sb, ERRORS_RO)) { |
629 | int def_errors = le16_to_cpu(es->s_errors); | 631 | int def_errors = le16_to_cpu(es->s_errors); |
@@ -967,6 +969,8 @@ static int parse_options (char *options, struct super_block *sb, | |||
967 | substring_t args[MAX_OPT_ARGS]; | 969 | substring_t args[MAX_OPT_ARGS]; |
968 | int data_opt = 0; | 970 | int data_opt = 0; |
969 | int option; | 971 | int option; |
972 | kuid_t uid; | ||
973 | kgid_t gid; | ||
970 | #ifdef CONFIG_QUOTA | 974 | #ifdef CONFIG_QUOTA |
971 | int qfmt; | 975 | int qfmt; |
972 | #endif | 976 | #endif |
@@ -1000,12 +1004,23 @@ static int parse_options (char *options, struct super_block *sb, | |||
1000 | case Opt_resuid: | 1004 | case Opt_resuid: |
1001 | if (match_int(&args[0], &option)) | 1005 | if (match_int(&args[0], &option)) |
1002 | return 0; | 1006 | return 0; |
1003 | sbi->s_resuid = option; | 1007 | uid = make_kuid(current_user_ns(), option); |
1008 | if (!uid_valid(uid)) { | ||
1009 | ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option); | ||
1010 | return -1; | ||
1011 | |||
1012 | } | ||
1013 | sbi->s_resuid = uid; | ||
1004 | break; | 1014 | break; |
1005 | case Opt_resgid: | 1015 | case Opt_resgid: |
1006 | if (match_int(&args[0], &option)) | 1016 | if (match_int(&args[0], &option)) |
1007 | return 0; | 1017 | return 0; |
1008 | sbi->s_resgid = option; | 1018 | gid = make_kgid(current_user_ns(), option); |
1019 | if (!gid_valid(gid)) { | ||
1020 | ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option); | ||
1021 | return -1; | ||
1022 | } | ||
1023 | sbi->s_resgid = gid; | ||
1009 | break; | 1024 | break; |
1010 | case Opt_sb: | 1025 | case Opt_sb: |
1011 | /* handled by get_sb_block() instead of here */ | 1026 | /* handled by get_sb_block() instead of here */ |
@@ -1651,8 +1666,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1651 | } | 1666 | } |
1652 | sb->s_fs_info = sbi; | 1667 | sb->s_fs_info = sbi; |
1653 | sbi->s_mount_opt = 0; | 1668 | sbi->s_mount_opt = 0; |
1654 | sbi->s_resuid = EXT3_DEF_RESUID; | 1669 | sbi->s_resuid = make_kuid(&init_user_ns, EXT3_DEF_RESUID); |
1655 | sbi->s_resgid = EXT3_DEF_RESGID; | 1670 | sbi->s_resgid = make_kgid(&init_user_ns, EXT3_DEF_RESGID); |
1656 | sbi->s_sb_block = sb_block; | 1671 | sbi->s_sb_block = sb_block; |
1657 | 1672 | ||
1658 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); | 1673 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); |
@@ -1716,8 +1731,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1716 | else | 1731 | else |
1717 | set_opt(sbi->s_mount_opt, ERRORS_RO); | 1732 | set_opt(sbi->s_mount_opt, ERRORS_RO); |
1718 | 1733 | ||
1719 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); | 1734 | sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid)); |
1720 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); | 1735 | sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid)); |
1721 | 1736 | ||
1722 | /* enable barriers by default */ | 1737 | /* enable barriers by default */ |
1723 | set_opt(sbi->s_mount_opt, BARRIER); | 1738 | set_opt(sbi->s_mount_opt, BARRIER); |