Re: [PATCH 5/5] ptrace: implement PTRACE_LISTEN

From: Matt Fleming
Date: Fri Sep 23 2011 - 07:17:55 EST


On Tue, 2011-06-14 at 11:20 +0200, Tejun Heo wrote:

[...]

> + case PTRACE_LISTEN:
> + /*
> + * Listen for events. Tracee must be in STOP. It's not
> + * resumed per-se but is not considered to be in TRACED by
> + * wait(2) or ptrace(2). If an async event (e.g. group
> + * stop state change) happens, tracee will enter STOP trap
> + * again. Alternatively, ptracer can issue INTERRUPT to
> + * finish listening and re-trap tracee into STOP.
> + */
> + if (unlikely(!seized || !lock_task_sighand(child, &flags)))
> + break;
> +
> + si = child->last_siginfo;
> + if (unlikely(!si || si->si_code >> 8 != PTRACE_EVENT_STOP))
> + break;

I've only just noticed this. You really don't want to break out of the
switch while holding sighand->siglock. This should read,

if (unlikely(!si || si->si_code >> 8 != PTRACE_EVENT_STOP)) {
unlock_task_sighand(child, &flags);
break;
}

--
Matt Fleming, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/