diff options
Diffstat (limited to 'include/linux/nsproxy.h')
| -rw-r--r-- | include/linux/nsproxy.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index 033a648709b6..0e66b57631fc 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h | |||
| @@ -32,8 +32,39 @@ struct nsproxy { | |||
| 32 | }; | 32 | }; |
| 33 | extern struct nsproxy init_nsproxy; | 33 | extern struct nsproxy init_nsproxy; |
| 34 | 34 | ||
| 35 | /* | ||
| 36 | * the namespaces access rules are: | ||
| 37 | * | ||
| 38 | * 1. only current task is allowed to change tsk->nsproxy pointer or | ||
| 39 | * any pointer on the nsproxy itself | ||
| 40 | * | ||
| 41 | * 2. when accessing (i.e. reading) current task's namespaces - no | ||
| 42 | * precautions should be taken - just dereference the pointers | ||
| 43 | * | ||
| 44 | * 3. the access to other task namespaces is performed like this | ||
| 45 | * rcu_read_lock(); | ||
| 46 | * nsproxy = task_nsproxy(tsk); | ||
| 47 | * if (nsproxy != NULL) { | ||
| 48 | * / * | ||
| 49 | * * work with the namespaces here | ||
| 50 | * * e.g. get the reference on one of them | ||
| 51 | * * / | ||
| 52 | * } / * | ||
| 53 | * * NULL task_nsproxy() means that this task is | ||
| 54 | * * almost dead (zombie) | ||
| 55 | * * / | ||
| 56 | * rcu_read_unlock(); | ||
| 57 | * | ||
| 58 | */ | ||
| 59 | |||
| 60 | static inline struct nsproxy *task_nsproxy(struct task_struct *tsk) | ||
| 61 | { | ||
| 62 | return rcu_dereference(tsk->nsproxy); | ||
| 63 | } | ||
| 64 | |||
| 35 | int copy_namespaces(unsigned long flags, struct task_struct *tsk); | 65 | int copy_namespaces(unsigned long flags, struct task_struct *tsk); |
| 36 | void get_task_namespaces(struct task_struct *tsk); | 66 | void exit_task_namespaces(struct task_struct *tsk); |
| 67 | void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new); | ||
| 37 | void free_nsproxy(struct nsproxy *ns); | 68 | void free_nsproxy(struct nsproxy *ns); |
| 38 | int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, | 69 | int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, |
| 39 | struct fs_struct *); | 70 | struct fs_struct *); |
| @@ -45,14 +76,15 @@ static inline void put_nsproxy(struct nsproxy *ns) | |||
| 45 | } | 76 | } |
| 46 | } | 77 | } |
| 47 | 78 | ||
| 48 | static inline void exit_task_namespaces(struct task_struct *p) | 79 | static inline void get_nsproxy(struct nsproxy *ns) |
| 49 | { | 80 | { |
| 50 | struct nsproxy *ns = p->nsproxy; | 81 | atomic_inc(&ns->count); |
| 51 | if (ns) { | ||
| 52 | task_lock(p); | ||
| 53 | p->nsproxy = NULL; | ||
| 54 | task_unlock(p); | ||
| 55 | put_nsproxy(ns); | ||
| 56 | } | ||
| 57 | } | 82 | } |
| 83 | |||
| 84 | #ifdef CONFIG_CGROUP_NS | ||
| 85 | int ns_cgroup_clone(struct task_struct *tsk); | ||
| 86 | #else | ||
| 87 | static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; } | ||
| 88 | #endif | ||
| 89 | |||
| 58 | #endif | 90 | #endif |
