* [PATCH 1/1] cr: credentials: fix some refcounting
@ 2009-05-14 22:32 Serge E. Hallyn
0 siblings, 0 replies; only message in thread
From: Serge E. Hallyn @ 2009-05-14 22:32 UTC (permalink / raw)
To: Oren Laadan; +Cc: Linux Containers
Creds and user namespaces both need one more ref taken.
A new user_ns needs a ref to remain pinned by its root user.
current_user_ns needs an extra ref bc objhash drops two on
restart.
cred needs a ref for the real credentials because commit_creds
eats one ref.
Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
checkpoint/process.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/checkpoint/process.c b/checkpoint/process.c
index 5047944..74872ba 100644
--- a/checkpoint/process.c
+++ b/checkpoint/process.c
@@ -601,7 +601,8 @@ static struct user_namespace *restore_read_userns(struct ckpt_ctx *ctx)
return ERR_PTR(PTR_ERR(h));
if (h->flags & CKPT_USERNS_INIT) {
ckpt_hdr_put(ctx, h);
- return current_user_ns();
+ /* grab an extra ref bc objhash will drop an extra */
+ return get_user_ns(current_user_ns());
}
creator = ckpt_obj_fetch(ctx, h->creator_ref, CKPT_OBJ_USER);
ckpt_hdr_put(ctx, h);
@@ -616,6 +617,10 @@ static struct user_namespace *restore_read_userns(struct ckpt_ctx *ctx)
/* new_user_ns() doesn't bump creator's refcount */
get_uid(creator);
+ /* objhash will drop new_ns refcount, but new_root
+ * should hold a ref */
+ get_user_ns(ns);
+
return ns;
}
@@ -1088,6 +1093,10 @@ static int restore_creds(struct ckpt_ctx *ctx, struct cred *rcred,
int ret;
const struct cred *old;
+ /* commit_creds will take one ref for the eff creds, but
+ * expects us to hold a ref for the obj creds, so take a
+ * ref here */
+ get_cred(rcred);
ret = commit_creds(rcred);
if (ret)
return ret;
--
1.6.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-14 22:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-14 22:32 [PATCH 1/1] cr: credentials: fix some refcounting Serge E. Hallyn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.