Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 65034
b: refs/heads/master
c: 28f300d
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and Linus Torvalds committed Sep 19, 2007
1 parent e4cb267 commit 3109341
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 735de2230f09741077a645a913de0a04b10208bf
refs/heads/master: 28f300d23674fa01ae747c66ce861d4ee6aebe8c
1 change: 1 addition & 0 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ static inline struct user_struct *get_uid(struct user_struct *u)
}
extern void free_uid(struct user_struct *);
extern void switch_uid(struct user_struct *);
extern void release_uids(struct user_namespace *ns);

#include <asm/current.h>

Expand Down
26 changes: 25 additions & 1 deletion trunk/kernel/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static inline void uid_hash_insert(struct user_struct *up, struct hlist_head *ha

static inline void uid_hash_remove(struct user_struct *up)
{
hlist_del(&up->uidhash_node);
hlist_del_init(&up->uidhash_node);
}

static inline struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent)
Expand Down Expand Up @@ -199,6 +199,30 @@ void switch_uid(struct user_struct *new_user)
suid_keys(current);
}

void release_uids(struct user_namespace *ns)
{
int i;
unsigned long flags;
struct hlist_head *head;
struct hlist_node *nd;

spin_lock_irqsave(&uidhash_lock, flags);
/*
* collapse the chains so that the user_struct-s will
* be still alive, but not in hashes. subsequent free_uid()
* will free them.
*/
for (i = 0; i < UIDHASH_SZ; i++) {
head = ns->uidhash_table + i;
while (!hlist_empty(head)) {
nd = head->first;
hlist_del_init(nd);
}
}
spin_unlock_irqrestore(&uidhash_lock, flags);

free_uid(ns->root_user);
}

static int __init uid_cache_init(void)
{
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/user_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void free_user_ns(struct kref *kref)
struct user_namespace *ns;

ns = container_of(kref, struct user_namespace, kref);
free_uid(ns->root_user);
release_uids(ns);
kfree(ns);
}

Expand Down

0 comments on commit 3109341

Please sign in to comment.