diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 18:41:49 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-15 17:59:27 -0400 |
commit | 08cefc7ab839cf3ece44b8033968a4732eac06d8 (patch) | |
tree | 7264efb33cb3d1249f7be3a7ea6dd12d30c313c1 /fs/ext4/super.c | |
parent | 1523299d5817773e344d135d4b1c485f269400bc (diff) |
userns: Convert ext4 to user 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/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ceebaf853beb..9d8eba0de27d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1448,6 +1448,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, | |||
1448 | { | 1448 | { |
1449 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1449 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1450 | const struct mount_opts *m; | 1450 | const struct mount_opts *m; |
1451 | kuid_t uid; | ||
1452 | kgid_t gid; | ||
1451 | int arg = 0; | 1453 | int arg = 0; |
1452 | 1454 | ||
1453 | if (args->from && match_int(args, &arg)) | 1455 | if (args->from && match_int(args, &arg)) |
@@ -1464,10 +1466,20 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, | |||
1464 | "Ignoring removed %s option", opt); | 1466 | "Ignoring removed %s option", opt); |
1465 | return 1; | 1467 | return 1; |
1466 | case Opt_resuid: | 1468 | case Opt_resuid: |
1467 | sbi->s_resuid = arg; | 1469 | uid = make_kuid(current_user_ns(), arg); |
1470 | if (!uid_valid(uid)) { | ||
1471 | ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg); | ||
1472 | return -1; | ||
1473 | } | ||
1474 | sbi->s_resuid = uid; | ||
1468 | return 1; | 1475 | return 1; |
1469 | case Opt_resgid: | 1476 | case Opt_resgid: |
1470 | sbi->s_resgid = arg; | 1477 | gid = make_kgid(current_user_ns(), arg); |
1478 | if (!gid_valid(gid)) { | ||
1479 | ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg); | ||
1480 | return -1; | ||
1481 | } | ||
1482 | sbi->s_resgid = gid; | ||
1471 | return 1; | 1483 | return 1; |
1472 | case Opt_abort: | 1484 | case Opt_abort: |
1473 | sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; | 1485 | sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; |
@@ -1732,12 +1744,14 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, | |||
1732 | SEQ_OPTS_PRINT("%s", token2str(m->token)); | 1744 | SEQ_OPTS_PRINT("%s", token2str(m->token)); |
1733 | } | 1745 | } |
1734 | 1746 | ||
1735 | if (nodefs || sbi->s_resuid != EXT4_DEF_RESUID || | 1747 | if (nodefs || !uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT4_DEF_RESUID)) || |
1736 | le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID) | 1748 | le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID) |
1737 | SEQ_OPTS_PRINT("resuid=%u", sbi->s_resuid); | 1749 | SEQ_OPTS_PRINT("resuid=%u", |
1738 | if (nodefs || sbi->s_resgid != EXT4_DEF_RESGID || | 1750 | from_kuid_munged(&init_user_ns, sbi->s_resuid)); |
1751 | if (nodefs || !gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT4_DEF_RESGID)) || | ||
1739 | le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID) | 1752 | le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID) |
1740 | SEQ_OPTS_PRINT("resgid=%u", sbi->s_resgid); | 1753 | SEQ_OPTS_PRINT("resgid=%u", |
1754 | from_kgid_munged(&init_user_ns, sbi->s_resgid)); | ||
1741 | def_errors = nodefs ? -1 : le16_to_cpu(es->s_errors); | 1755 | def_errors = nodefs ? -1 : le16_to_cpu(es->s_errors); |
1742 | if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO) | 1756 | if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO) |
1743 | SEQ_OPTS_PUTS("errors=remount-ro"); | 1757 | SEQ_OPTS_PUTS("errors=remount-ro"); |
@@ -2996,8 +3010,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2996 | } | 3010 | } |
2997 | sb->s_fs_info = sbi; | 3011 | sb->s_fs_info = sbi; |
2998 | sbi->s_mount_opt = 0; | 3012 | sbi->s_mount_opt = 0; |
2999 | sbi->s_resuid = EXT4_DEF_RESUID; | 3013 | sbi->s_resuid = make_kuid(&init_user_ns, EXT4_DEF_RESUID); |
3000 | sbi->s_resgid = EXT4_DEF_RESGID; | 3014 | sbi->s_resgid = make_kgid(&init_user_ns, EXT4_DEF_RESGID); |
3001 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; | 3015 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; |
3002 | sbi->s_sb_block = sb_block; | 3016 | sbi->s_sb_block = sb_block; |
3003 | if (sb->s_bdev->bd_part) | 3017 | if (sb->s_bdev->bd_part) |
@@ -3076,8 +3090,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3076 | if (def_mount_opts & EXT4_DEFM_DISCARD) | 3090 | if (def_mount_opts & EXT4_DEFM_DISCARD) |
3077 | set_opt(sb, DISCARD); | 3091 | set_opt(sb, DISCARD); |
3078 | 3092 | ||
3079 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); | 3093 | sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid)); |
3080 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); | 3094 | sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid)); |
3081 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; | 3095 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; |
3082 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; | 3096 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; |
3083 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | 3097 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; |
@@ -4229,8 +4243,8 @@ static int ext4_unfreeze(struct super_block *sb) | |||
4229 | struct ext4_mount_options { | 4243 | struct ext4_mount_options { |
4230 | unsigned long s_mount_opt; | 4244 | unsigned long s_mount_opt; |
4231 | unsigned long s_mount_opt2; | 4245 | unsigned long s_mount_opt2; |
4232 | uid_t s_resuid; | 4246 | kuid_t s_resuid; |
4233 | gid_t s_resgid; | 4247 | kgid_t s_resgid; |
4234 | unsigned long s_commit_interval; | 4248 | unsigned long s_commit_interval; |
4235 | u32 s_min_batch_time, s_max_batch_time; | 4249 | u32 s_min_batch_time, s_max_batch_time; |
4236 | #ifdef CONFIG_QUOTA | 4250 | #ifdef CONFIG_QUOTA |