diff options
Diffstat (limited to 'fs/nsfs.c')
-rw-r--r-- | fs/nsfs.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/seq_file.h> | 7 | #include <linux/seq_file.h> |
8 | #include <linux/user_namespace.h> | 8 | #include <linux/user_namespace.h> |
9 | #include <linux/nsfs.h> | 9 | #include <linux/nsfs.h> |
10 | #include <linux/uaccess.h> | ||
10 | 11 | ||
11 | static struct vfsmount *nsfs_mnt; | 12 | static struct vfsmount *nsfs_mnt; |
12 | 13 | ||
@@ -163,7 +164,10 @@ int open_related_ns(struct ns_common *ns, | |||
163 | static long ns_ioctl(struct file *filp, unsigned int ioctl, | 164 | static long ns_ioctl(struct file *filp, unsigned int ioctl, |
164 | unsigned long arg) | 165 | unsigned long arg) |
165 | { | 166 | { |
167 | struct user_namespace *user_ns; | ||
166 | struct ns_common *ns = get_proc_ns(file_inode(filp)); | 168 | struct ns_common *ns = get_proc_ns(file_inode(filp)); |
169 | uid_t __user *argp; | ||
170 | uid_t uid; | ||
167 | 171 | ||
168 | switch (ioctl) { | 172 | switch (ioctl) { |
169 | case NS_GET_USERNS: | 173 | case NS_GET_USERNS: |
@@ -172,6 +176,15 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, | |||
172 | if (!ns->ops->get_parent) | 176 | if (!ns->ops->get_parent) |
173 | return -EINVAL; | 177 | return -EINVAL; |
174 | return open_related_ns(ns, ns->ops->get_parent); | 178 | return open_related_ns(ns, ns->ops->get_parent); |
179 | case NS_GET_NSTYPE: | ||
180 | return ns->ops->type; | ||
181 | case NS_GET_OWNER_UID: | ||
182 | if (ns->ops->type != CLONE_NEWUSER) | ||
183 | return -EINVAL; | ||
184 | user_ns = container_of(ns, struct user_namespace, ns); | ||
185 | argp = (uid_t __user *) arg; | ||
186 | uid = from_kuid_munged(current_user_ns(), user_ns->owner); | ||
187 | return put_user(uid, argp); | ||
175 | default: | 188 | default: |
176 | return -ENOTTY; | 189 | return -ENOTTY; |
177 | } | 190 | } |