diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:19:25 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-21 06:13:05 -0400 |
commit | a0eb3a05a8cbe9cd1a41dde3d1b2e5bcc10634f2 (patch) | |
tree | 61caa3f975dfd2fcf14646822bfb5784e113936e /fs | |
parent | 91fa2ccaa87368314527ea7518c545063662d67f (diff) |
userns: Convert hugetlbfs to use kuid/kgid where appropriate
Note sysctl_hugetlb_shm_group can only be written in the root user
in the initial user namespace, so we can assume sysctl_hugetlb_shm_group
is in the initial user namespace.
Cc: William Irwin <wli@holomorphy.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/hugetlbfs/inode.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 8349a899912e..6e572c4fbf68 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -42,8 +42,8 @@ static const struct inode_operations hugetlbfs_dir_inode_operations; | |||
42 | static const struct inode_operations hugetlbfs_inode_operations; | 42 | static const struct inode_operations hugetlbfs_inode_operations; |
43 | 43 | ||
44 | struct hugetlbfs_config { | 44 | struct hugetlbfs_config { |
45 | uid_t uid; | 45 | kuid_t uid; |
46 | gid_t gid; | 46 | kgid_t gid; |
47 | umode_t mode; | 47 | umode_t mode; |
48 | long nr_blocks; | 48 | long nr_blocks; |
49 | long nr_inodes; | 49 | long nr_inodes; |
@@ -785,13 +785,17 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig) | |||
785 | case Opt_uid: | 785 | case Opt_uid: |
786 | if (match_int(&args[0], &option)) | 786 | if (match_int(&args[0], &option)) |
787 | goto bad_val; | 787 | goto bad_val; |
788 | pconfig->uid = option; | 788 | pconfig->uid = make_kuid(current_user_ns(), option); |
789 | if (!uid_valid(pconfig->uid)) | ||
790 | goto bad_val; | ||
789 | break; | 791 | break; |
790 | 792 | ||
791 | case Opt_gid: | 793 | case Opt_gid: |
792 | if (match_int(&args[0], &option)) | 794 | if (match_int(&args[0], &option)) |
793 | goto bad_val; | 795 | goto bad_val; |
794 | pconfig->gid = option; | 796 | pconfig->gid = make_kgid(current_user_ns(), option); |
797 | if (!gid_valid(pconfig->gid)) | ||
798 | goto bad_val; | ||
795 | break; | 799 | break; |
796 | 800 | ||
797 | case Opt_mode: | 801 | case Opt_mode: |
@@ -924,7 +928,9 @@ static struct vfsmount *hugetlbfs_vfsmount; | |||
924 | 928 | ||
925 | static int can_do_hugetlb_shm(void) | 929 | static int can_do_hugetlb_shm(void) |
926 | { | 930 | { |
927 | return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group); | 931 | kgid_t shm_group; |
932 | shm_group = make_kgid(&init_user_ns, sysctl_hugetlb_shm_group); | ||
933 | return capable(CAP_IPC_LOCK) || in_group_p(shm_group); | ||
928 | } | 934 | } |
929 | 935 | ||
930 | struct file *hugetlb_file_setup(const char *name, unsigned long addr, | 936 | struct file *hugetlb_file_setup(const char *name, unsigned long addr, |