lkml.org 
[lkml]   [2008]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [patch 20/24] perfmon: system calls interface
    On 11/26, Ingo Molnar wrote:
    >
    > * eranian@googlemail.com <eranian@googlemail.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.



    \
     
     \ /
      Last update: 2008-11-26 18:05    [from the cache]
    ©2003-2014 Jasper Spaans. hosted at Digital Ocean