Re: [PATCH 08/14] ptrace: make do_signal_stop() use ptrace_stop()if the task is being ptraced

From: Oleg Nesterov
Date: Sun Nov 28 2010 - 16:00:26 EST


On 11/28, Jan Kratochvil wrote:
>
> On Sun, 28 Nov 2010 20:54:42 +0100, Oleg Nesterov wrote:
> > To simplify, suppose that we have a single-thread tracee, and
> > debugger "acks" SIGSTOP, say, it does ptrace(PTRACE_CONT, SIGSTOP).
>
> I do not find this case useful.

OK, thanks.

> It happens with current GDB:
> (gdb) handle SIGSTOP
> Signal Stop Print Pass to program Description
> SIGSTOP Yes Yes Yes Stopped (signal)
> ^^^
> But it behaves weird anyway:
>
> ptrace(PTRACE_CONT, 11799, 0x1, SIGSTOP) = 0
> wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], WNOHANG, NULL) = 11799
> [...]
> ptrace(PTRACE_CONT, 11799, 0x1, SIGSTOP) = 0
> <no new signal received>:
> State: S (sleeping)
> TracerPid: 11797
>
> So the first time it immediately gets reported and the second time it gets
> lost. (kernel-2.6.35.6-48.fc14.x86_64)

This is correct. (note that I am not saying this looks very nice ;)

The second ptrace(PTRACE_CONT, SIGSTOP) is equal to ptrace(CONT, 0),
exactly because ->last_siginfo is NULL, we do not have the signal
context. (Well, this explanation is not exactly right technically).

And. IIRC, something in user-space relies on the current behaviour.
At least, I do remember it was said that ->last_siginfo != NULL
check (PTRACE_GETSIGINFO fails or not should help to detect the
jctl stop.

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/