diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/init_task.h | 2 | ||||
| -rw-r--r-- | include/linux/nsproxy.h | 1 | ||||
| -rw-r--r-- | include/linux/sched.h | 3 | ||||
| -rw-r--r-- | include/linux/user_namespace.h | 57 |
4 files changed, 62 insertions, 1 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 276ccaa2670c..cab741c2d603 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <linux/lockdep.h> | 8 | #include <linux/lockdep.h> |
| 9 | #include <linux/ipc.h> | 9 | #include <linux/ipc.h> |
| 10 | #include <linux/pid_namespace.h> | 10 | #include <linux/pid_namespace.h> |
| 11 | #include <linux/user_namespace.h> | ||
| 11 | 12 | ||
| 12 | #define INIT_FDTABLE \ | 13 | #define INIT_FDTABLE \ |
| 13 | { \ | 14 | { \ |
| @@ -78,6 +79,7 @@ extern struct nsproxy init_nsproxy; | |||
| 78 | .uts_ns = &init_uts_ns, \ | 79 | .uts_ns = &init_uts_ns, \ |
| 79 | .mnt_ns = NULL, \ | 80 | .mnt_ns = NULL, \ |
| 80 | INIT_IPC_NS(ipc_ns) \ | 81 | INIT_IPC_NS(ipc_ns) \ |
| 82 | .user_ns = &init_user_ns, \ | ||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | #define INIT_SIGHAND(sighand) { \ | 85 | #define INIT_SIGHAND(sighand) { \ |
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index 189e0dc993ab..6d179a397bfb 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h | |||
| @@ -28,6 +28,7 @@ struct nsproxy { | |||
| 28 | struct ipc_namespace *ipc_ns; | 28 | struct ipc_namespace *ipc_ns; |
| 29 | struct mnt_namespace *mnt_ns; | 29 | struct mnt_namespace *mnt_ns; |
| 30 | struct pid_namespace *pid_ns; | 30 | struct pid_namespace *pid_ns; |
| 31 | struct user_namespace *user_ns; | ||
| 31 | }; | 32 | }; |
| 32 | extern struct nsproxy init_nsproxy; | 33 | extern struct nsproxy init_nsproxy; |
| 33 | 34 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index b579624477f4..c667255d70db 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -287,6 +287,7 @@ extern signed long schedule_timeout_uninterruptible(signed long timeout); | |||
| 287 | asmlinkage void schedule(void); | 287 | asmlinkage void schedule(void); |
| 288 | 288 | ||
| 289 | struct nsproxy; | 289 | struct nsproxy; |
| 290 | struct user_namespace; | ||
| 290 | 291 | ||
| 291 | /* Maximum number of active map areas.. This is a random (large) number */ | 292 | /* Maximum number of active map areas.. This is a random (large) number */ |
| 292 | #define DEFAULT_MAX_MAP_COUNT 65536 | 293 | #define DEFAULT_MAX_MAP_COUNT 65536 |
| @@ -1408,7 +1409,7 @@ extern struct task_struct *find_task_by_pid_type(int type, int pid); | |||
| 1408 | extern void __set_special_pids(pid_t session, pid_t pgrp); | 1409 | extern void __set_special_pids(pid_t session, pid_t pgrp); |
| 1409 | 1410 | ||
| 1410 | /* per-UID process charging. */ | 1411 | /* per-UID process charging. */ |
| 1411 | extern struct user_struct * alloc_uid(uid_t); | 1412 | extern struct user_struct * alloc_uid(struct user_namespace *, uid_t); |
| 1412 | static inline struct user_struct *get_uid(struct user_struct *u) | 1413 | static inline struct user_struct *get_uid(struct user_struct *u) |
| 1413 | { | 1414 | { |
| 1414 | atomic_inc(&u->__count); | 1415 | atomic_inc(&u->__count); |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h new file mode 100644 index 000000000000..92a45867ecfb --- /dev/null +++ b/include/linux/user_namespace.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #ifndef _LINUX_USER_NAMESPACE_H | ||
| 2 | #define _LINUX_USER_NAMESPACE_H | ||
| 3 | |||
| 4 | #include <linux/kref.h> | ||
| 5 | #include <linux/nsproxy.h> | ||
| 6 | #include <linux/sched.h> | ||
| 7 | |||
| 8 | #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8) | ||
| 9 | #define UIDHASH_SZ (1 << UIDHASH_BITS) | ||
| 10 | |||
| 11 | struct user_namespace { | ||
| 12 | struct kref kref; | ||
| 13 | struct list_head uidhash_table[UIDHASH_SZ]; | ||
| 14 | struct user_struct *root_user; | ||
| 15 | }; | ||
| 16 | |||
| 17 | extern struct user_namespace init_user_ns; | ||
| 18 | |||
| 19 | #ifdef CONFIG_USER_NS | ||
| 20 | |||
| 21 | static inline struct user_namespace *get_user_ns(struct user_namespace *ns) | ||
| 22 | { | ||
| 23 | if (ns) | ||
| 24 | kref_get(&ns->kref); | ||
| 25 | return ns; | ||
| 26 | } | ||
| 27 | |||
| 28 | extern struct user_namespace *copy_user_ns(int flags, | ||
| 29 | struct user_namespace *old_ns); | ||
| 30 | extern void free_user_ns(struct kref *kref); | ||
| 31 | |||
| 32 | static inline void put_user_ns(struct user_namespace *ns) | ||
| 33 | { | ||
| 34 | if (ns) | ||
| 35 | kref_put(&ns->kref, free_user_ns); | ||
| 36 | } | ||
| 37 | |||
| 38 | #else | ||
| 39 | |||
| 40 | static inline struct user_namespace *get_user_ns(struct user_namespace *ns) | ||
| 41 | { | ||
| 42 | return &init_user_ns; | ||
| 43 | } | ||
| 44 | |||
| 45 | static inline struct user_namespace *copy_user_ns(int flags, | ||
| 46 | struct user_namespace *old_ns) | ||
| 47 | { | ||
| 48 | return NULL; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline void put_user_ns(struct user_namespace *ns) | ||
| 52 | { | ||
| 53 | } | ||
| 54 | |||
| 55 | #endif | ||
| 56 | |||
| 57 | #endif /* _LINUX_USER_H */ | ||
