diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/fs.h | 1 | ||||
| -rw-r--r-- | include/linux/ipc_namespace.h | 3 | ||||
| -rw-r--r-- | include/linux/namei.h | 25 | ||||
| -rw-r--r-- | include/linux/ns_common.h | 12 | ||||
| -rw-r--r-- | include/linux/pid_namespace.h | 3 | ||||
| -rw-r--r-- | include/linux/proc_ns.h | 43 | ||||
| -rw-r--r-- | include/linux/user_namespace.h | 3 | ||||
| -rw-r--r-- | include/linux/utsname.h | 3 |
8 files changed, 46 insertions, 47 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index eeaccd37184f..f90c0282c114 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -2176,7 +2176,6 @@ static inline int sb_is_blkdev_sb(struct super_block *sb) | |||
| 2176 | extern int sync_filesystem(struct super_block *); | 2176 | extern int sync_filesystem(struct super_block *); |
| 2177 | extern const struct file_operations def_blk_fops; | 2177 | extern const struct file_operations def_blk_fops; |
| 2178 | extern const struct file_operations def_chr_fops; | 2178 | extern const struct file_operations def_chr_fops; |
| 2179 | extern const struct file_operations bad_sock_fops; | ||
| 2180 | #ifdef CONFIG_BLOCK | 2179 | #ifdef CONFIG_BLOCK |
| 2181 | extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); | 2180 | extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); |
| 2182 | extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); | 2181 | extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); |
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index e365d5ec69cb..1eee6bcfcf76 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <linux/rwsem.h> | 6 | #include <linux/rwsem.h> |
| 7 | #include <linux/notifier.h> | 7 | #include <linux/notifier.h> |
| 8 | #include <linux/nsproxy.h> | 8 | #include <linux/nsproxy.h> |
| 9 | #include <linux/ns_common.h> | ||
| 9 | 10 | ||
| 10 | struct user_namespace; | 11 | struct user_namespace; |
| 11 | 12 | ||
| @@ -58,7 +59,7 @@ struct ipc_namespace { | |||
| 58 | /* user_ns which owns the ipc ns */ | 59 | /* user_ns which owns the ipc ns */ |
| 59 | struct user_namespace *user_ns; | 60 | struct user_namespace *user_ns; |
| 60 | 61 | ||
| 61 | unsigned int proc_inum; | 62 | struct ns_common ns; |
| 62 | }; | 63 | }; |
| 63 | 64 | ||
| 64 | extern struct ipc_namespace init_ipc_ns; | 65 | extern struct ipc_namespace init_ipc_ns; |
diff --git a/include/linux/namei.h b/include/linux/namei.h index 492de72560fa..c8990779f0c3 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h | |||
| @@ -7,21 +7,10 @@ | |||
| 7 | #include <linux/path.h> | 7 | #include <linux/path.h> |
| 8 | 8 | ||
| 9 | struct vfsmount; | 9 | struct vfsmount; |
| 10 | struct nameidata; | ||
| 10 | 11 | ||
| 11 | enum { MAX_NESTED_LINKS = 8 }; | 12 | enum { MAX_NESTED_LINKS = 8 }; |
| 12 | 13 | ||
| 13 | struct nameidata { | ||
| 14 | struct path path; | ||
| 15 | struct qstr last; | ||
| 16 | struct path root; | ||
| 17 | struct inode *inode; /* path.dentry.d_inode */ | ||
| 18 | unsigned int flags; | ||
| 19 | unsigned seq, m_seq; | ||
| 20 | int last_type; | ||
| 21 | unsigned depth; | ||
| 22 | char *saved_names[MAX_NESTED_LINKS + 1]; | ||
| 23 | }; | ||
| 24 | |||
| 25 | /* | 14 | /* |
| 26 | * Type of the last component on LOOKUP_PARENT | 15 | * Type of the last component on LOOKUP_PARENT |
| 27 | */ | 16 | */ |
| @@ -82,16 +71,8 @@ extern struct dentry *lock_rename(struct dentry *, struct dentry *); | |||
| 82 | extern void unlock_rename(struct dentry *, struct dentry *); | 71 | extern void unlock_rename(struct dentry *, struct dentry *); |
| 83 | 72 | ||
| 84 | extern void nd_jump_link(struct nameidata *nd, struct path *path); | 73 | extern void nd_jump_link(struct nameidata *nd, struct path *path); |
| 85 | 74 | extern void nd_set_link(struct nameidata *nd, char *path); | |
| 86 | static inline void nd_set_link(struct nameidata *nd, char *path) | 75 | extern char *nd_get_link(struct nameidata *nd); |
| 87 | { | ||
| 88 | nd->saved_names[nd->depth] = path; | ||
| 89 | } | ||
| 90 | |||
| 91 | static inline char *nd_get_link(struct nameidata *nd) | ||
| 92 | { | ||
| 93 | return nd->saved_names[nd->depth]; | ||
| 94 | } | ||
| 95 | 76 | ||
| 96 | static inline void nd_terminate_link(void *name, size_t len, size_t maxlen) | 77 | static inline void nd_terminate_link(void *name, size_t len, size_t maxlen) |
| 97 | { | 78 | { |
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h new file mode 100644 index 000000000000..85a5c8c16be9 --- /dev/null +++ b/include/linux/ns_common.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #ifndef _LINUX_NS_COMMON_H | ||
| 2 | #define _LINUX_NS_COMMON_H | ||
| 3 | |||
| 4 | struct proc_ns_operations; | ||
| 5 | |||
| 6 | struct ns_common { | ||
| 7 | atomic_long_t stashed; | ||
| 8 | const struct proc_ns_operations *ops; | ||
| 9 | unsigned int inum; | ||
| 10 | }; | ||
| 11 | |||
| 12 | #endif | ||
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index 1997ffc295a7..b9cf6c51b181 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <linux/threads.h> | 8 | #include <linux/threads.h> |
| 9 | #include <linux/nsproxy.h> | 9 | #include <linux/nsproxy.h> |
| 10 | #include <linux/kref.h> | 10 | #include <linux/kref.h> |
| 11 | #include <linux/ns_common.h> | ||
| 11 | 12 | ||
| 12 | struct pidmap { | 13 | struct pidmap { |
| 13 | atomic_t nr_free; | 14 | atomic_t nr_free; |
| @@ -43,7 +44,7 @@ struct pid_namespace { | |||
| 43 | kgid_t pid_gid; | 44 | kgid_t pid_gid; |
| 44 | int hide_pid; | 45 | int hide_pid; |
| 45 | int reboot; /* group exit code if this pidns was rebooted */ | 46 | int reboot; /* group exit code if this pidns was rebooted */ |
| 46 | unsigned int proc_inum; | 47 | struct ns_common ns; |
| 47 | }; | 48 | }; |
| 48 | 49 | ||
| 49 | extern struct pid_namespace init_pid_ns; | 50 | extern struct pid_namespace init_pid_ns; |
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 34a1e105bef4..42dfc615dbf8 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
| @@ -4,21 +4,18 @@ | |||
| 4 | #ifndef _LINUX_PROC_NS_H | 4 | #ifndef _LINUX_PROC_NS_H |
| 5 | #define _LINUX_PROC_NS_H | 5 | #define _LINUX_PROC_NS_H |
| 6 | 6 | ||
| 7 | #include <linux/ns_common.h> | ||
| 8 | |||
| 7 | struct pid_namespace; | 9 | struct pid_namespace; |
| 8 | struct nsproxy; | 10 | struct nsproxy; |
| 11 | struct path; | ||
| 9 | 12 | ||
| 10 | struct proc_ns_operations { | 13 | struct proc_ns_operations { |
| 11 | const char *name; | 14 | const char *name; |
| 12 | int type; | 15 | int type; |
| 13 | void *(*get)(struct task_struct *task); | 16 | struct ns_common *(*get)(struct task_struct *task); |
| 14 | void (*put)(void *ns); | 17 | void (*put)(struct ns_common *ns); |
| 15 | int (*install)(struct nsproxy *nsproxy, void *ns); | 18 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); |
| 16 | unsigned int (*inum)(void *ns); | ||
| 17 | }; | ||
| 18 | |||
| 19 | struct proc_ns { | ||
| 20 | void *ns; | ||
| 21 | const struct proc_ns_operations *ns_ops; | ||
| 22 | }; | 19 | }; |
| 23 | 20 | ||
| 24 | extern const struct proc_ns_operations netns_operations; | 21 | extern const struct proc_ns_operations netns_operations; |
| @@ -43,32 +40,38 @@ enum { | |||
| 43 | 40 | ||
| 44 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | 41 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); |
| 45 | extern void pid_ns_release_proc(struct pid_namespace *ns); | 42 | extern void pid_ns_release_proc(struct pid_namespace *ns); |
| 46 | extern struct file *proc_ns_fget(int fd); | ||
| 47 | extern struct proc_ns *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); | ||
| 51 | 45 | ||
| 52 | #else /* CONFIG_PROC_FS */ | 46 | #else /* CONFIG_PROC_FS */ |
| 53 | 47 | ||
| 54 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } | 48 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } |
| 55 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} | 49 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} |
| 56 | 50 | ||
| 57 | static inline struct file *proc_ns_fget(int fd) | ||
| 58 | { | ||
| 59 | return ERR_PTR(-EINVAL); | ||
| 60 | } | ||
| 61 | |||
| 62 | static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; } | ||
| 63 | |||
| 64 | static inline int proc_alloc_inum(unsigned int *inum) | 51 | static inline int proc_alloc_inum(unsigned int *inum) |
| 65 | { | 52 | { |
| 66 | *inum = 1; | 53 | *inum = 1; |
| 67 | return 0; | 54 | return 0; |
| 68 | } | 55 | } |
| 69 | static inline void proc_free_inum(unsigned int inum) {} | 56 | static inline void proc_free_inum(unsigned int inum) {} |
| 70 | static inline bool proc_ns_inode(struct inode *inode) { return false; } | ||
| 71 | 57 | ||
| 72 | #endif /* CONFIG_PROC_FS */ | 58 | #endif /* CONFIG_PROC_FS */ |
| 73 | 59 | ||
| 60 | static inline int ns_alloc_inum(struct ns_common *ns) | ||
| 61 | { | ||
| 62 | atomic_long_set(&ns->stashed, 0); | ||
| 63 | return proc_alloc_inum(&ns->inum); | ||
| 64 | } | ||
| 65 | |||
| 66 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) | ||
| 67 | |||
| 68 | extern struct file *proc_ns_fget(int fd); | ||
| 69 | #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private) | ||
| 70 | extern void *ns_get_path(struct path *path, struct task_struct *task, | ||
| 71 | const struct proc_ns_operations *ns_ops); | ||
| 72 | |||
| 73 | extern int ns_get_name(char *buf, size_t size, struct task_struct *task, | ||
| 74 | const struct proc_ns_operations *ns_ops); | ||
| 75 | extern void nsfs_init(void); | ||
| 76 | |||
| 74 | #endif /* _LINUX_PROC_NS_H */ | 77 | #endif /* _LINUX_PROC_NS_H */ |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index e95372654f09..4cf06c140e21 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <linux/kref.h> | 4 | #include <linux/kref.h> |
| 5 | #include <linux/nsproxy.h> | 5 | #include <linux/nsproxy.h> |
| 6 | #include <linux/ns_common.h> | ||
| 6 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
| 7 | #include <linux/err.h> | 8 | #include <linux/err.h> |
| 8 | 9 | ||
| @@ -26,7 +27,7 @@ struct user_namespace { | |||
| 26 | int level; | 27 | int level; |
| 27 | kuid_t owner; | 28 | kuid_t owner; |
| 28 | kgid_t group; | 29 | kgid_t group; |
| 29 | unsigned int proc_inum; | 30 | struct ns_common ns; |
| 30 | 31 | ||
| 31 | /* Register of per-UID persistent keyrings for this namespace */ | 32 | /* Register of per-UID persistent keyrings for this namespace */ |
| 32 | #ifdef CONFIG_PERSISTENT_KEYRINGS | 33 | #ifdef CONFIG_PERSISTENT_KEYRINGS |
diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 239e27733d6c..5093f58ae192 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
| 6 | #include <linux/kref.h> | 6 | #include <linux/kref.h> |
| 7 | #include <linux/nsproxy.h> | 7 | #include <linux/nsproxy.h> |
| 8 | #include <linux/ns_common.h> | ||
| 8 | #include <linux/err.h> | 9 | #include <linux/err.h> |
| 9 | #include <uapi/linux/utsname.h> | 10 | #include <uapi/linux/utsname.h> |
| 10 | 11 | ||
| @@ -23,7 +24,7 @@ struct uts_namespace { | |||
| 23 | struct kref kref; | 24 | struct kref kref; |
| 24 | struct new_utsname name; | 25 | struct new_utsname name; |
| 25 | struct user_namespace *user_ns; | 26 | struct user_namespace *user_ns; |
| 26 | unsigned int proc_inum; | 27 | struct ns_common ns; |
| 27 | }; | 28 | }; |
| 28 | extern struct uts_namespace init_uts_ns; | 29 | extern struct uts_namespace init_uts_ns; |
| 29 | 30 | ||
