提交 8751e039 编写于 作者: E Eric W. Biederman

userns: Convert tmpfs to use kuid and kgid where appropriate

Acked-by: NSerge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
上级 ab27b91b
...@@ -28,8 +28,8 @@ struct shmem_sb_info { ...@@ -28,8 +28,8 @@ struct shmem_sb_info {
unsigned long max_inodes; /* How many inodes are allowed */ unsigned long max_inodes; /* How many inodes are allowed */
unsigned long free_inodes; /* How many are left for allocation */ unsigned long free_inodes; /* How many are left for allocation */
spinlock_t stat_lock; /* Serialize shmem_sb_info changes */ spinlock_t stat_lock; /* Serialize shmem_sb_info changes */
uid_t uid; /* Mount uid for root directory */ kuid_t uid; /* Mount uid for root directory */
gid_t gid; /* Mount gid for root directory */ kgid_t gid; /* Mount gid for root directory */
umode_t mode; /* Mount mode for root directory */ umode_t mode; /* Mount mode for root directory */
struct mempolicy *mpol; /* default memory policy for mappings */ struct mempolicy *mpol; /* default memory policy for mappings */
}; };
......
...@@ -953,7 +953,6 @@ config UIDGID_CONVERTED ...@@ -953,7 +953,6 @@ config UIDGID_CONVERTED
depends on REISERFS_FS = n depends on REISERFS_FS = n
depends on SQUASHFS = n depends on SQUASHFS = n
depends on SYSV_FS = n depends on SYSV_FS = n
depends on TMPFS = n
depends on UBIFS_FS = n depends on UBIFS_FS = n
depends on UDF_FS = n depends on UDF_FS = n
depends on UFS_FS = n depends on UFS_FS = n
......
...@@ -2075,6 +2075,8 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo, ...@@ -2075,6 +2075,8 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
bool remount) bool remount)
{ {
char *this_char, *value, *rest; char *this_char, *value, *rest;
uid_t uid;
gid_t gid;
while (options != NULL) { while (options != NULL) {
this_char = options; this_char = options;
...@@ -2134,15 +2136,21 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo, ...@@ -2134,15 +2136,21 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
} else if (!strcmp(this_char,"uid")) { } else if (!strcmp(this_char,"uid")) {
if (remount) if (remount)
continue; continue;
sbinfo->uid = simple_strtoul(value, &rest, 0); uid = simple_strtoul(value, &rest, 0);
if (*rest) if (*rest)
goto bad_val; goto bad_val;
sbinfo->uid = make_kuid(current_user_ns(), uid);
if (!uid_valid(sbinfo->uid))
goto bad_val;
} else if (!strcmp(this_char,"gid")) { } else if (!strcmp(this_char,"gid")) {
if (remount) if (remount)
continue; continue;
sbinfo->gid = simple_strtoul(value, &rest, 0); gid = simple_strtoul(value, &rest, 0);
if (*rest) if (*rest)
goto bad_val; goto bad_val;
sbinfo->gid = make_kgid(current_user_ns(), gid);
if (!gid_valid(sbinfo->gid))
goto bad_val;
} else if (!strcmp(this_char,"mpol")) { } else if (!strcmp(this_char,"mpol")) {
if (mpol_parse_str(value, &sbinfo->mpol, 1)) if (mpol_parse_str(value, &sbinfo->mpol, 1))
goto bad_val; goto bad_val;
...@@ -2210,10 +2218,12 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root) ...@@ -2210,10 +2218,12 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
if (sbinfo->mode != (S_IRWXUGO | S_ISVTX)) if (sbinfo->mode != (S_IRWXUGO | S_ISVTX))
seq_printf(seq, ",mode=%03ho", sbinfo->mode); seq_printf(seq, ",mode=%03ho", sbinfo->mode);
if (sbinfo->uid != 0) if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID))
seq_printf(seq, ",uid=%u", sbinfo->uid); seq_printf(seq, ",uid=%u",
if (sbinfo->gid != 0) from_kuid_munged(&init_user_ns, sbinfo->uid));
seq_printf(seq, ",gid=%u", sbinfo->gid); if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID))
seq_printf(seq, ",gid=%u",
from_kgid_munged(&init_user_ns, sbinfo->gid));
shmem_show_mpol(seq, sbinfo->mpol); shmem_show_mpol(seq, sbinfo->mpol);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册