diff options
| -rw-r--r-- | fs/namespace.c | 13 | ||||
| -rw-r--r-- | fs/proc/internal.h | 5 | ||||
| -rw-r--r-- | fs/proc/namespaces.c | 7 | ||||
| -rw-r--r-- | include/linux/proc_ns.h | 9 | ||||
| -rw-r--r-- | kernel/nsproxy.c | 4 | ||||
| -rw-r--r-- | net/core/net_namespace.c | 4 |
6 files changed, 15 insertions, 27 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index f815218f92d3..9dfb4cac0c41 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
| @@ -1570,16 +1570,7 @@ static bool is_mnt_ns_file(struct dentry *dentry) | |||
| 1570 | { | 1570 | { |
| 1571 | /* Is this a proxy for a mount namespace? */ | 1571 | /* Is this a proxy for a mount namespace? */ |
| 1572 | struct inode *inode = dentry->d_inode; | 1572 | struct inode *inode = dentry->d_inode; |
| 1573 | struct proc_ns *ei; | 1573 | return proc_ns_inode(inode) && dentry->d_fsdata == &mntns_operations; |
| 1574 | |||
| 1575 | if (!proc_ns_inode(inode)) | ||
| 1576 | return false; | ||
| 1577 | |||
| 1578 | ei = get_proc_ns(inode); | ||
| 1579 | if (ei->ns_ops != &mntns_operations) | ||
| 1580 | return false; | ||
| 1581 | |||
| 1582 | return true; | ||
| 1583 | } | 1574 | } |
| 1584 | 1575 | ||
| 1585 | struct mnt_namespace *to_mnt_ns(struct ns_common *ns) | 1576 | struct mnt_namespace *to_mnt_ns(struct ns_common *ns) |
| @@ -1596,7 +1587,7 @@ static bool mnt_ns_loop(struct dentry *dentry) | |||
| 1596 | if (!is_mnt_ns_file(dentry)) | 1587 | if (!is_mnt_ns_file(dentry)) |
| 1597 | return false; | 1588 | return false; |
| 1598 | 1589 | ||
| 1599 | mnt_ns = to_mnt_ns(get_proc_ns(dentry->d_inode)->ns); | 1590 | mnt_ns = to_mnt_ns(get_proc_ns(dentry->d_inode)); |
| 1600 | return current->nsproxy->mnt_ns->seq >= mnt_ns->seq; | 1591 | return current->nsproxy->mnt_ns->seq >= mnt_ns->seq; |
| 1601 | } | 1592 | } |
| 1602 | 1593 | ||
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index aa7a0ee182e1..0fabc48d905f 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
| @@ -57,6 +57,11 @@ union proc_op { | |||
| 57 | struct task_struct *task); | 57 | struct task_struct *task); |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | struct proc_ns { | ||
| 61 | struct ns_common *ns; | ||
| 62 | const struct proc_ns_operations *ns_ops; | ||
| 63 | }; | ||
| 64 | |||
| 60 | struct proc_inode { | 65 | struct proc_inode { |
| 61 | struct pid *pid; | 66 | struct pid *pid; |
| 62 | int fd; | 67 | int fd; |
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index 995e8e98237d..18fc1cf899de 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c | |||
| @@ -45,7 +45,7 @@ static const struct inode_operations ns_inode_operations = { | |||
| 45 | static char *ns_dname(struct dentry *dentry, char *buffer, int buflen) | 45 | static char *ns_dname(struct dentry *dentry, char *buffer, int buflen) |
| 46 | { | 46 | { |
| 47 | struct inode *inode = dentry->d_inode; | 47 | struct inode *inode = dentry->d_inode; |
| 48 | const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns.ns_ops; | 48 | const struct proc_ns_operations *ns_ops = dentry->d_fsdata; |
| 49 | 49 | ||
| 50 | return dynamic_dname(dentry, buffer, buflen, "%s:[%lu]", | 50 | return dynamic_dname(dentry, buffer, buflen, "%s:[%lu]", |
| 51 | ns_ops->name, inode->i_ino); | 51 | ns_ops->name, inode->i_ino); |
| @@ -75,6 +75,7 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb, | |||
| 75 | ns_ops->put(ns); | 75 | ns_ops->put(ns); |
| 76 | return ERR_PTR(-ENOMEM); | 76 | return ERR_PTR(-ENOMEM); |
| 77 | } | 77 | } |
| 78 | dentry->d_fsdata = (void *)ns_ops; | ||
| 78 | 79 | ||
| 79 | inode = iget_locked(sb, ns->inum); | 80 | inode = iget_locked(sb, ns->inum); |
| 80 | if (!inode) { | 81 | if (!inode) { |
| @@ -286,9 +287,9 @@ out_invalid: | |||
| 286 | return ERR_PTR(-EINVAL); | 287 | return ERR_PTR(-EINVAL); |
| 287 | } | 288 | } |
| 288 | 289 | ||
| 289 | struct proc_ns *get_proc_ns(struct inode *inode) | 290 | struct ns_common *get_proc_ns(struct inode *inode) |
| 290 | { | 291 | { |
| 291 | return &PROC_I(inode)->ns; | 292 | return PROC_I(inode)->ns.ns; |
| 292 | } | 293 | } |
| 293 | 294 | ||
| 294 | bool proc_ns_inode(struct inode *inode) | 295 | bool proc_ns_inode(struct inode *inode) |
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index f5780ee7f8f7..2837ff41cfe3 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
| @@ -16,11 +16,6 @@ struct proc_ns_operations { | |||
| 16 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); | 16 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | struct proc_ns { | ||
| 20 | struct ns_common *ns; | ||
| 21 | const struct proc_ns_operations *ns_ops; | ||
| 22 | }; | ||
| 23 | |||
| 24 | extern const struct proc_ns_operations netns_operations; | 19 | extern const struct proc_ns_operations netns_operations; |
| 25 | extern const struct proc_ns_operations utsns_operations; | 20 | extern const struct proc_ns_operations utsns_operations; |
| 26 | extern const struct proc_ns_operations ipcns_operations; | 21 | extern const struct proc_ns_operations ipcns_operations; |
| @@ -44,7 +39,7 @@ enum { | |||
| 44 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | 39 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); |
| 45 | extern void pid_ns_release_proc(struct pid_namespace *ns); | 40 | extern void pid_ns_release_proc(struct pid_namespace *ns); |
| 46 | extern struct file *proc_ns_fget(int fd); | 41 | extern struct file *proc_ns_fget(int fd); |
| 47 | extern struct proc_ns *get_proc_ns(struct inode *); | 42 | extern struct ns_common *get_proc_ns(struct inode *); |
| 48 | extern int proc_alloc_inum(unsigned int *pino); | 43 | extern int proc_alloc_inum(unsigned int *pino); |
| 49 | extern void proc_free_inum(unsigned int inum); | 44 | extern void proc_free_inum(unsigned int inum); |
| 50 | extern bool proc_ns_inode(struct inode *inode); | 45 | extern bool proc_ns_inode(struct inode *inode); |
| @@ -59,7 +54,7 @@ static inline struct file *proc_ns_fget(int fd) | |||
| 59 | return ERR_PTR(-EINVAL); | 54 | return ERR_PTR(-EINVAL); |
| 60 | } | 55 | } |
| 61 | 56 | ||
| 62 | static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; } | 57 | static inline struct ns_common *get_proc_ns(struct inode *inode) { return NULL; } |
| 63 | 58 | ||
| 64 | static inline int proc_alloc_inum(unsigned int *inum) | 59 | static inline int proc_alloc_inum(unsigned int *inum) |
| 65 | { | 60 | { |
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 87c37221cb7f..49746c81ad8d 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
| @@ -222,7 +222,6 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype) | |||
| 222 | { | 222 | { |
| 223 | struct task_struct *tsk = current; | 223 | struct task_struct *tsk = current; |
| 224 | struct nsproxy *new_nsproxy; | 224 | struct nsproxy *new_nsproxy; |
| 225 | struct proc_ns *ei; | ||
| 226 | struct file *file; | 225 | struct file *file; |
| 227 | struct ns_common *ns; | 226 | struct ns_common *ns; |
| 228 | int err; | 227 | int err; |
| @@ -232,8 +231,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype) | |||
| 232 | return PTR_ERR(file); | 231 | return PTR_ERR(file); |
| 233 | 232 | ||
| 234 | err = -EINVAL; | 233 | err = -EINVAL; |
| 235 | ei = get_proc_ns(file_inode(file)); | 234 | ns = get_proc_ns(file_inode(file)); |
| 236 | ns = ei->ns; | ||
| 237 | if (nstype && (ns->ops->type != nstype)) | 235 | if (nstype && (ns->ops->type != nstype)) |
| 238 | goto out; | 236 | goto out; |
| 239 | 237 | ||
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 4d4acaf7b498..ce780c722e48 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
| @@ -337,7 +337,6 @@ EXPORT_SYMBOL_GPL(__put_net); | |||
| 337 | 337 | ||
| 338 | struct net *get_net_ns_by_fd(int fd) | 338 | struct net *get_net_ns_by_fd(int fd) |
| 339 | { | 339 | { |
| 340 | struct proc_ns *ei; | ||
| 341 | struct file *file; | 340 | struct file *file; |
| 342 | struct ns_common *ns; | 341 | struct ns_common *ns; |
| 343 | struct net *net; | 342 | struct net *net; |
| @@ -346,8 +345,7 @@ struct net *get_net_ns_by_fd(int fd) | |||
| 346 | if (IS_ERR(file)) | 345 | if (IS_ERR(file)) |
| 347 | return ERR_CAST(file); | 346 | return ERR_CAST(file); |
| 348 | 347 | ||
| 349 | ei = get_proc_ns(file_inode(file)); | 348 | ns = get_proc_ns(file_inode(file)); |
| 350 | ns = ei->ns; | ||
| 351 | if (ns->ops == &netns_operations) | 349 | if (ns->ops == &netns_operations) |
| 352 | net = get_net(container_of(ns, struct net, ns)); | 350 | net = get_net(container_of(ns, struct net, ns)); |
| 353 | else | 351 | else |
