aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/shmem_fs.h4
-rw-r--r--init/Kconfig1
-rw-r--r--mm/shmem.c22
3 files changed, 18 insertions, 9 deletions
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 79ab2555b3b..bef2cf00b3b 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -28,8 +28,8 @@ struct shmem_sb_info {
28 unsigned long max_inodes; /* How many inodes are allowed */ 28 unsigned long max_inodes; /* How many inodes are allowed */
29 unsigned long free_inodes; /* How many are left for allocation */ 29 unsigned long free_inodes; /* How many are left for allocation */
30 spinlock_t stat_lock; /* Serialize shmem_sb_info changes */ 30 spinlock_t stat_lock; /* Serialize shmem_sb_info changes */
31 uid_t uid; /* Mount uid for root directory */ 31 kuid_t uid; /* Mount uid for root directory */
32 gid_t gid; /* Mount gid for root directory */ 32 kgid_t gid; /* Mount gid for root directory */
33 umode_t mode; /* Mount mode for root directory */ 33 umode_t mode; /* Mount mode for root directory */
34 struct mempolicy *mpol; /* default memory policy for mappings */ 34 struct mempolicy *mpol; /* default memory policy for mappings */
35}; 35};
diff --git a/init/Kconfig b/init/Kconfig
index 908e61cd0b0..7a5ccb2e9e0 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -953,7 +953,6 @@ config UIDGID_CONVERTED
953 depends on REISERFS_FS = n 953 depends on REISERFS_FS = n
954 depends on SQUASHFS = n 954 depends on SQUASHFS = n
955 depends on SYSV_FS = n 955 depends on SYSV_FS = n
956 depends on TMPFS = n
957 depends on UBIFS_FS = n 956 depends on UBIFS_FS = n
958 depends on UDF_FS = n 957 depends on UDF_FS = n
959 depends on UFS_FS = n 958 depends on UFS_FS = n
diff --git a/mm/shmem.c b/mm/shmem.c
index f99ff3e50bd..d7b433a1ef5 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}