userns: Convert debugfs to use kuid/kgid where appropriate.
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
c9235f4872
commit
7dc05881b6
@ -128,8 +128,8 @@ static inline int debugfs_positive(struct dentry *dentry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct debugfs_mount_opts {
|
struct debugfs_mount_opts {
|
||||||
uid_t uid;
|
kuid_t uid;
|
||||||
gid_t gid;
|
kgid_t gid;
|
||||||
umode_t mode;
|
umode_t mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,6 +156,8 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
|
|||||||
substring_t args[MAX_OPT_ARGS];
|
substring_t args[MAX_OPT_ARGS];
|
||||||
int option;
|
int option;
|
||||||
int token;
|
int token;
|
||||||
|
kuid_t uid;
|
||||||
|
kgid_t gid;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
opts->mode = DEBUGFS_DEFAULT_MODE;
|
opts->mode = DEBUGFS_DEFAULT_MODE;
|
||||||
@ -169,12 +171,18 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
|
|||||||
case Opt_uid:
|
case Opt_uid:
|
||||||
if (match_int(&args[0], &option))
|
if (match_int(&args[0], &option))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
opts->uid = option;
|
uid = make_kuid(current_user_ns(), option);
|
||||||
|
if (!uid_valid(uid))
|
||||||
|
return -EINVAL;
|
||||||
|
opts->uid = uid;
|
||||||
break;
|
break;
|
||||||
case Opt_gid:
|
case Opt_gid:
|
||||||
if (match_octal(&args[0], &option))
|
if (match_octal(&args[0], &option))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
opts->gid = option;
|
gid = make_kgid(current_user_ns(), option);
|
||||||
|
if (!gid_valid(gid))
|
||||||
|
return -EINVAL;
|
||||||
|
opts->gid = gid;
|
||||||
break;
|
break;
|
||||||
case Opt_mode:
|
case Opt_mode:
|
||||||
if (match_octal(&args[0], &option))
|
if (match_octal(&args[0], &option))
|
||||||
@ -226,10 +234,12 @@ static int debugfs_show_options(struct seq_file *m, struct dentry *root)
|
|||||||
struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
|
struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
|
||||||
struct debugfs_mount_opts *opts = &fsi->mount_opts;
|
struct debugfs_mount_opts *opts = &fsi->mount_opts;
|
||||||
|
|
||||||
if (opts->uid != 0)
|
if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
|
||||||
seq_printf(m, ",uid=%u", opts->uid);
|
seq_printf(m, ",uid=%u",
|
||||||
if (opts->gid != 0)
|
from_kuid_munged(&init_user_ns, opts->uid));
|
||||||
seq_printf(m, ",gid=%u", opts->gid);
|
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
|
||||||
|
seq_printf(m, ",gid=%u",
|
||||||
|
from_kgid_munged(&init_user_ns, opts->gid));
|
||||||
if (opts->mode != DEBUGFS_DEFAULT_MODE)
|
if (opts->mode != DEBUGFS_DEFAULT_MODE)
|
||||||
seq_printf(m, ",mode=%o", opts->mode);
|
seq_printf(m, ",mode=%o", opts->mode);
|
||||||
|
|
||||||
|
@ -964,7 +964,6 @@ config UIDGID_CONVERTED
|
|||||||
depends on CODA_FS = n
|
depends on CODA_FS = n
|
||||||
depends on CONFIGFS_FS = n
|
depends on CONFIGFS_FS = n
|
||||||
depends on CRAMFS = n
|
depends on CRAMFS = n
|
||||||
depends on DEBUG_FS = n
|
|
||||||
depends on ECRYPT_FS = n
|
depends on ECRYPT_FS = n
|
||||||
depends on EFS_FS = n
|
depends on EFS_FS = n
|
||||||
depends on EXOFS_FS = n
|
depends on EXOFS_FS = n
|
||||||
|
Loading…
Reference in New Issue
Block a user