aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index f99ff3e50bd6..d7b433a1ef5e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2075,6 +2075,8 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
2075 bool remount) 2075 bool remount)
2076{ 2076{
2077 char *this_char, *value, *rest; 2077 char *this_char, *value, *rest;
2078 uid_t uid;
2079 gid_t gid;
2078 2080
2079 while (options != NULL) { 2081 while (options != NULL) {
2080 this_char = options; 2082 this_char = options;
@@ -2134,15 +2136,21 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
2134 } else if (!strcmp(this_char,"uid")) { 2136 } else if (!strcmp(this_char,"uid")) {
2135 if (remount) 2137 if (remount)
2136 continue; 2138 continue;
2137 sbinfo->uid = simple_strtoul(value, &rest, 0); 2139 uid = simple_strtoul(value, &rest, 0);
2138 if (*rest) 2140 if (*rest)
2139 goto bad_val; 2141 goto bad_val;
2142 sbinfo->uid = make_kuid(current_user_ns(), uid);
2143 if (!uid_valid(sbinfo->uid))
2144 goto bad_val;
2140 } else if (!strcmp(this_char,"gid")) { 2145 } else if (!strcmp(this_char,"gid")) {
2141 if (remount) 2146 if (remount)
2142 continue; 2147 continue;
2143 sbinfo->gid = simple_strtoul(value, &rest, 0); 2148 gid = simple_strtoul(value, &rest, 0);
2144 if (*rest) 2149 if (*rest)
2145 goto bad_val; 2150 goto bad_val;
2151 sbinfo->gid = make_kgid(current_user_ns(), gid);
2152 if (!gid_valid(sbinfo->gid))
2153 goto bad_val;
2146 } else if (!strcmp(this_char,"mpol")) { 2154 } else if (!strcmp(this_char,"mpol")) {
2147 if (mpol_parse_str(value, &sbinfo->mpol, 1)) 2155 if (mpol_parse_str(value, &sbinfo->mpol, 1))
2148 goto bad_val; 2156 goto bad_val;
@@ -2210,10 +2218,12 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
2210 seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); 2218 seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
2211 if (sbinfo->mode != (S_IRWXUGO | S_ISVTX)) 2219 if (sbinfo->mode != (S_IRWXUGO | S_ISVTX))
2212 seq_printf(seq, ",mode=%03ho", sbinfo->mode); 2220 seq_printf(seq, ",mode=%03ho", sbinfo->mode);
2213 if (sbinfo->uid != 0) 2221 if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID))
2214 seq_printf(seq, ",uid=%u", sbinfo->uid); 2222 seq_printf(seq, ",uid=%u",
2215 if (sbinfo->gid != 0) 2223 from_kuid_munged(&init_user_ns, sbinfo->uid));
2216 seq_printf(seq, ",gid=%u", sbinfo->gid); 2224 if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID))
2225 seq_printf(seq, ",gid=%u",
2226 from_kgid_munged(&init_user_ns, sbinfo->gid));
2217 shmem_show_mpol(seq, sbinfo->mpol); 2227 shmem_show_mpol(seq, sbinfo->mpol);
2218 return 0; 2228 return 0;
2219} 2229}