userns: Convert proc to use kuid/kgid where appropriate
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
@@ -191,8 +191,14 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
|||||||
task_tgid_nr_ns(p, ns),
|
task_tgid_nr_ns(p, ns),
|
||||||
pid_nr_ns(pid, ns),
|
pid_nr_ns(pid, ns),
|
||||||
ppid, tpid,
|
ppid, tpid,
|
||||||
cred->uid, cred->euid, cred->suid, cred->fsuid,
|
from_kuid_munged(user_ns, cred->uid),
|
||||||
cred->gid, cred->egid, cred->sgid, cred->fsgid);
|
from_kuid_munged(user_ns, cred->euid),
|
||||||
|
from_kuid_munged(user_ns, cred->suid),
|
||||||
|
from_kuid_munged(user_ns, cred->fsuid),
|
||||||
|
from_kgid_munged(user_ns, cred->gid),
|
||||||
|
from_kgid_munged(user_ns, cred->egid),
|
||||||
|
from_kgid_munged(user_ns, cred->sgid),
|
||||||
|
from_kgid_munged(user_ns, cred->fsgid));
|
||||||
|
|
||||||
task_lock(p);
|
task_lock(p);
|
||||||
if (p->files)
|
if (p->files)
|
||||||
|
@@ -1562,8 +1562,8 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
|
|||||||
generic_fillattr(inode, stat);
|
generic_fillattr(inode, stat);
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
stat->uid = 0;
|
stat->uid = GLOBAL_ROOT_UID;
|
||||||
stat->gid = 0;
|
stat->gid = GLOBAL_ROOT_GID;
|
||||||
task = pid_task(proc_pid(inode), PIDTYPE_PID);
|
task = pid_task(proc_pid(inode), PIDTYPE_PID);
|
||||||
if (task) {
|
if (task) {
|
||||||
if (!has_pid_permissions(pid, task, 2)) {
|
if (!has_pid_permissions(pid, task, 2)) {
|
||||||
@@ -1623,8 +1623,8 @@ int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
|
|||||||
inode->i_gid = cred->egid;
|
inode->i_gid = cred->egid;
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
} else {
|
} else {
|
||||||
inode->i_uid = 0;
|
inode->i_uid = GLOBAL_ROOT_UID;
|
||||||
inode->i_gid = 0;
|
inode->i_gid = GLOBAL_ROOT_GID;
|
||||||
}
|
}
|
||||||
inode->i_mode &= ~(S_ISUID | S_ISGID);
|
inode->i_mode &= ~(S_ISUID | S_ISGID);
|
||||||
security_task_to_inode(task, inode);
|
security_task_to_inode(task, inode);
|
||||||
@@ -1811,8 +1811,8 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
|
|||||||
inode->i_gid = cred->egid;
|
inode->i_gid = cred->egid;
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
} else {
|
} else {
|
||||||
inode->i_uid = 0;
|
inode->i_uid = GLOBAL_ROOT_UID;
|
||||||
inode->i_gid = 0;
|
inode->i_gid = GLOBAL_ROOT_GID;
|
||||||
}
|
}
|
||||||
inode->i_mode &= ~(S_ISUID | S_ISGID);
|
inode->i_mode &= ~(S_ISUID | S_ISGID);
|
||||||
security_task_to_inode(task, inode);
|
security_task_to_inode(task, inode);
|
||||||
@@ -2061,8 +2061,8 @@ static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd)
|
|||||||
inode->i_gid = cred->egid;
|
inode->i_gid = cred->egid;
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
} else {
|
} else {
|
||||||
inode->i_uid = 0;
|
inode->i_uid = GLOBAL_ROOT_UID;
|
||||||
inode->i_gid = 0;
|
inode->i_gid = GLOBAL_ROOT_GID;
|
||||||
}
|
}
|
||||||
security_task_to_inode(task, inode);
|
security_task_to_inode(task, inode);
|
||||||
status = 1;
|
status = 1;
|
||||||
|
@@ -108,8 +108,8 @@ static int proc_show_options(struct seq_file *seq, struct dentry *root)
|
|||||||
struct super_block *sb = root->d_sb;
|
struct super_block *sb = root->d_sb;
|
||||||
struct pid_namespace *pid = sb->s_fs_info;
|
struct pid_namespace *pid = sb->s_fs_info;
|
||||||
|
|
||||||
if (pid->pid_gid)
|
if (!gid_eq(pid->pid_gid, GLOBAL_ROOT_GID))
|
||||||
seq_printf(seq, ",gid=%lu", (unsigned long)pid->pid_gid);
|
seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, pid->pid_gid));
|
||||||
if (pid->hide_pid != 0)
|
if (pid->hide_pid != 0)
|
||||||
seq_printf(seq, ",hidepid=%u", pid->hide_pid);
|
seq_printf(seq, ",hidepid=%u", pid->hide_pid);
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ static int proc_parse_options(char *options, struct pid_namespace *pid)
|
|||||||
case Opt_gid:
|
case Opt_gid:
|
||||||
if (match_int(&args[0], &option))
|
if (match_int(&args[0], &option))
|
||||||
return 0;
|
return 0;
|
||||||
pid->pid_gid = option;
|
pid->pid_gid = make_kgid(current_user_ns(), option);
|
||||||
break;
|
break;
|
||||||
case Opt_hidepid:
|
case Opt_hidepid:
|
||||||
if (match_int(&args[0], &option))
|
if (match_int(&args[0], &option))
|
||||||
|
@@ -31,7 +31,7 @@ struct pid_namespace {
|
|||||||
#ifdef CONFIG_BSD_PROCESS_ACCT
|
#ifdef CONFIG_BSD_PROCESS_ACCT
|
||||||
struct bsd_acct_struct *bacct;
|
struct bsd_acct_struct *bacct;
|
||||||
#endif
|
#endif
|
||||||
gid_t pid_gid;
|
kgid_t pid_gid;
|
||||||
int hide_pid;
|
int hide_pid;
|
||||||
int reboot; /* group exit code if this pidns was rebooted */
|
int reboot; /* group exit code if this pidns was rebooted */
|
||||||
};
|
};
|
||||||
|
@@ -52,8 +52,8 @@ struct proc_dir_entry {
|
|||||||
unsigned int low_ino;
|
unsigned int low_ino;
|
||||||
umode_t mode;
|
umode_t mode;
|
||||||
nlink_t nlink;
|
nlink_t nlink;
|
||||||
uid_t uid;
|
kuid_t uid;
|
||||||
gid_t gid;
|
kgid_t gid;
|
||||||
loff_t size;
|
loff_t size;
|
||||||
const struct inode_operations *proc_iops;
|
const struct inode_operations *proc_iops;
|
||||||
/*
|
/*
|
||||||
|
@@ -948,7 +948,6 @@ config UIDGID_CONVERTED
|
|||||||
depends on NTFS_FS = n
|
depends on NTFS_FS = n
|
||||||
depends on OCFS2_FS = n
|
depends on OCFS2_FS = n
|
||||||
depends on OMFS_FS = n
|
depends on OMFS_FS = n
|
||||||
depends on PROC_FS = n
|
|
||||||
depends on PROC_SYSCTL = n
|
depends on PROC_SYSCTL = n
|
||||||
depends on QNX4FS_FS = n
|
depends on QNX4FS_FS = n
|
||||||
depends on QNX6FS_FS = n
|
depends on QNX6FS_FS = n
|
||||||
|
Reference in New Issue
Block a user