Re: [PATCH 08/11] ptrace: move fallback JOBCTL_TRAPPING clearingto get_signal_to_deliver()

From: Oleg Nesterov
Date: Wed May 11 2011 - 11:51:50 EST


On 05/08, Tejun Heo wrote:
>
> Move the fallback clearing to the end of get_signal_to_deliver() so
> that TRAPPING is maintained while tracee is inside signal delivery
> path. When killed, tracee is guaranteed to leave signal delivery path
> in finite amount of time and thus TRAPPING is still guaranteed to be
> cleared on kill.

Mostly yes, but we can race with freeze_processes() and deadlock.

> @@ -1978,9 +1981,6 @@ retry:
> goto retry;
> }
>
> - /* PTRACE_ATTACH might have raced with task killing, clear trapping */
> - task_clear_jobctl_trapping(current);
> -
> spin_unlock_irq(&current->sighand->siglock);
>
> tracehook_finish_jctl();
> @@ -2226,6 +2226,13 @@ relock:
> do_group_exit(info->si_signo);
> /* NOTREACHED */
> }
> +
> + /*
> + * PTRACE_ATTACH might have raced with task killing. Make sure
> + * trapping is clear before leaving signal delivery path.
> + */
> + task_clear_jobctl_trapping(current);

before the tracee does this, it returns from do_signal_stop(), goes to
relock:, and calls try_to_freeze(). If it becomes frozen,
try_to_freeze_tasks() can't succeed because the tracer waits for
!JOBCTL_TRAPPING.

And. The main problem is that "leave signal delivery path" is not true
at all. When the tracee dequeues SIGKILL it calls do_group_exit() inside
the main loop.

So far this all looks easily fixeable though...

Oleg.

--
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/