From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oren Laadan Subject: Re: [PATCH 4/6] cr: checkpoint and restore task credentials Date: Thu, 21 May 2009 10:02:20 -0400 Message-ID: <4A155EEC.9070509@cs.columbia.edu> References: <20090519014446.GA28277@us.ibm.com> <20090519014538.GD28312@us.ibm.com> <4A1435E0.3010306@cs.columbia.edu> <20090520214027.GA3517@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20090520214027.GA3517-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: "Serge E. Hallyn" Cc: Linux Containers , David Howells List-Id: containers.vger.kernel.org Serge E. Hallyn wrote: > Quoting Oren Laadan (orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org): >>> /* dump the task_struct of a given task */ >>> static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t) >>> { >>> struct ckpt_hdr_task *h; >>> int ret; >>> + int realcred_ref, ecred_ref; >>> + >>> + realcred_ref = checkpoint_obj(ctx, t->real_cred, CKPT_OBJ_CRED); >>> + if (realcred_ref < 0) >>> + return realcred_ref; >>> + >>> + ecred_ref = checkpoint_obj(ctx, t->cred, CKPT_OBJ_CRED); >>> + if (ecred_ref < 0) >>> + return ecred_ref; >> Is this safe even if the checkpointed task's state changes ? >> (e.g. unfrozen - yes, I know there is a patch in the works to >> prevent this; but if we ever want to checkpoint STOPPED tasks... >> for instance). >> >> Would incrementing the refcount on t->{cred,real_cred} help ? > > Doesn't checkpoint_obj already do that through obj_new? > No, it does not. There is a (potentially long) window of opportunity between the callback invoked from checkpoint_obj() - where the pointer is used, and when checkpoint_obj() later takes the extra reference. See for comparison checkpoint_mm_obj(), it safely grabs the task->mm (with a reference) around the invocation of checkpoint_obj(). Oren.