[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081126165948.GA15755@redhat.com>
Date: Wed, 26 Nov 2008 17:59:48 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Ingo Molnar <mingo@...e.hu>
Cc: eranian@...glemail.com, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org, x86@...nel.org, andi@...stfloor.org,
eranian@...il.com, sfr@...b.auug.org.au,
Roland McGrath <roland@...hat.com>
Subject: Re: [patch 20/24] perfmon: system calls interface
On 11/26, Ingo Molnar wrote:
>
> * eranian@...glemail.com <eranian@...glemail.com> wrote:
>
> > +static int pfm_task_incompatible(struct pfm_context *ctx,
> > + struct task_struct *task)
> > +{
> > + /*
> > + * cannot attach to a kernel thread
> > + */
> > + if (!task->mm) {
> > + PFM_DBG("cannot attach to kernel thread [%d]", task->pid);
> > + return -EPERM;
> > + }
> > +
> > + /*
> > + * cannot attach to a zombie task
> > + */
> > + if (task->exit_state == EXIT_ZOMBIE || task->exit_state == EXIT_DEAD) {
> > + PFM_DBG("cannot attach to zombie/dead task [%d]", task->pid);
> > + return -EBUSY;
> > + }
> > + return 0;
> > +}
I agree with Ingo these checks are pointless. Without the locks
the ->mm or ->exit_state can be changed right after the check.
And, as Ingo pointed out, you don't need this function at all,
if ptrace_check_attach() succeeds the task must have ->mm and
its ->exit_state == 0.
But, please note that the task can be SIGKILL'ed right after
ptrace_check_attach(), it can drop ->mm, it can be released.
(i don't understand the patch, perhaps this doesn't matter for
you, just in case).
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists