diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2011-11-17 02:20:58 -0500 |
|---|---|---|
| committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-04-07 20:11:46 -0400 |
| commit | 7b44ab978b77a91b327058a0f4db7e6fcdb90b92 (patch) | |
| tree | 632c872f0b88d001f1bddce2c0aacd77bf062454 /include/linux | |
| parent | 5673a94c14574d7c6495c320c6b0e480673d54bd (diff) | |
userns: Disassociate user_struct from the user_namespace.
Modify alloc_uid to take a kuid and make the user hash table global.
Stop holding a reference to the user namespace in struct user_struct.
This simplifies the code and makes the per user accounting not
care about which user namespace a uid happens to appear in.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/sched.h | 8 | ||||
| -rw-r--r-- | include/linux/user_namespace.h | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6867ae9bc8a0..5fdc1ebbcbc4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -90,6 +90,7 @@ struct sched_param { | |||
| 90 | #include <linux/latencytop.h> | 90 | #include <linux/latencytop.h> |
| 91 | #include <linux/cred.h> | 91 | #include <linux/cred.h> |
| 92 | #include <linux/llist.h> | 92 | #include <linux/llist.h> |
| 93 | #include <linux/uidgid.h> | ||
| 93 | 94 | ||
| 94 | #include <asm/processor.h> | 95 | #include <asm/processor.h> |
| 95 | 96 | ||
| @@ -728,8 +729,7 @@ struct user_struct { | |||
| 728 | 729 | ||
| 729 | /* Hash table maintenance information */ | 730 | /* Hash table maintenance information */ |
| 730 | struct hlist_node uidhash_node; | 731 | struct hlist_node uidhash_node; |
| 731 | uid_t uid; | 732 | kuid_t uid; |
| 732 | struct user_namespace *_user_ns; /* Don't use will be removed soon */ | ||
| 733 | 733 | ||
| 734 | #ifdef CONFIG_PERF_EVENTS | 734 | #ifdef CONFIG_PERF_EVENTS |
| 735 | atomic_long_t locked_vm; | 735 | atomic_long_t locked_vm; |
| @@ -738,7 +738,7 @@ struct user_struct { | |||
| 738 | 738 | ||
| 739 | extern int uids_sysfs_init(void); | 739 | extern int uids_sysfs_init(void); |
| 740 | 740 | ||
| 741 | extern struct user_struct *find_user(uid_t); | 741 | extern struct user_struct *find_user(kuid_t); |
| 742 | 742 | ||
| 743 | extern struct user_struct root_user; | 743 | extern struct user_struct root_user; |
| 744 | #define INIT_USER (&root_user) | 744 | #define INIT_USER (&root_user) |
| @@ -2177,7 +2177,7 @@ extern struct task_struct *find_task_by_pid_ns(pid_t nr, | |||
| 2177 | extern void __set_special_pids(struct pid *pid); | 2177 | extern void __set_special_pids(struct pid *pid); |
| 2178 | 2178 | ||
| 2179 | /* per-UID process charging. */ | 2179 | /* per-UID process charging. */ |
| 2180 | extern struct user_struct * alloc_uid(struct user_namespace *, uid_t); | 2180 | extern struct user_struct * alloc_uid(kuid_t); |
| 2181 | static inline struct user_struct *get_uid(struct user_struct *u) | 2181 | static inline struct user_struct *get_uid(struct user_struct *u) |
| 2182 | { | 2182 | { |
| 2183 | atomic_inc(&u->__count); | 2183 | atomic_inc(&u->__count); |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index dc2d85a76376..d767508db4f9 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
| @@ -6,12 +6,8 @@ | |||
| 6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 7 | #include <linux/err.h> | 7 | #include <linux/err.h> |
| 8 | 8 | ||
| 9 | #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 7) | ||
| 10 | #define UIDHASH_SZ (1 << UIDHASH_BITS) | ||
| 11 | |||
| 12 | struct user_namespace { | 9 | struct user_namespace { |
| 13 | struct kref kref; | 10 | struct kref kref; |
| 14 | struct hlist_head uidhash_table[UIDHASH_SZ]; | ||
| 15 | struct user_namespace *parent; | 11 | struct user_namespace *parent; |
| 16 | struct user_struct *creator; | 12 | struct user_struct *creator; |
| 17 | struct work_struct destroyer; | 13 | struct work_struct destroyer; |
