With a user_ns reference in struct cred the only user of the user namespace reference in struct user_struct is to keep the uid hash table alive. The user_namespace reference in struct user_struct will be going away soon, and I have removed all of the references. Rename the field from user_ns to _user_ns so that the compiler can verify nothing follows the user struct to the user namespace anymore.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -58,7 +58,7 @@ struct user_struct root_user = { · 57 unmodified lines | |||
| 58 | .files = ATOMIC_INIT(0), | 58 | .files = ATOMIC_INIT(0), |
| 59 | .sigpending = ATOMIC_INIT(0), | 59 | .sigpending = ATOMIC_INIT(0), |
| 60 | .locked_shm = 0, | 60 | .locked_shm = 0, |
| 61 | .user_ns = &init_user_ns, | 61 | ._user_ns = &init_user_ns, |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | /* | 64 | /* |
| @@ -72,7 +72,7 @@ static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent) · 7 unmodified lines | |||
| 72 | static void uid_hash_remove(struct user_struct *up) | 72 | static void uid_hash_remove(struct user_struct *up) |
| 73 | { | 73 | { |
| 74 | hlist_del_init(&up->uidhash_node); | 74 | hlist_del_init(&up->uidhash_node); |
| 75 | put_user_ns(up->user_ns); | 75 | put_user_ns(up->_user_ns); /* It is safe to free the uid hash table now */ |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | static struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent) | 78 | static struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent) |
| @@ -153,7 +153,7 @@ struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid) · 74 unmodified lines | |||
| 153 | new->uid = uid; | 153 | new->uid = uid; |
| 154 | atomic_set(&new->__count, 1); | 154 | atomic_set(&new->__count, 1); |
| 155 | 155 | ||
| 156 | new->user_ns = get_user_ns(ns); | 156 | new->_user_ns = get_user_ns(ns); |
| 157 | 157 | ||
| 158 | /* | 158 | /* |
| 159 | * Before adding this, check whether we raced | 159 | * Before adding this, check whether we raced |