Re: [PATCH] Set TIF_IRET in more places

Linus Torvalds (torvalds@transmeta.com)
Mon, 6 Jan 2003 08:04:48 -0800 (PST)


On Mon, 6 Jan 2003, Luca Barbieri wrote:
>
> This patch adds code to set TIF_IRET in sigsuspend and rt_sigsuspend
> (since they change registers to invoke signal handlers) and ptrace
> setregs. This prevents clobbering of %ecx and %edx.

Hmm.. I explicitly thought about signals for sysenter, and I don't think
any of these are needed. In particular, here's my logic:

- ptrace only acts on a child that is stopped in the signal handling
path, so if signal handling i scorrect, then so is ptrace. So no
special case handling needed in ptrace.c

- [rt_]sigsuspend() has two exit cases: (a) the signal handler we
invoced, and (b) the point that signal handler will eventually return
to (ie the system call return point)

In the eventual return case, we don't care about ecx/edx, since
they will have been saved on the stack by the trampoline anyway.

In the signal handler we invoce, we also don't care about ecx/edx,
since they aren't part of the calling convention, and will in fact
have random values anyway (do_signal() will re-initialize the FP
state, but leaves the integer regs untouched.

- note that for normal asynchronous signals, it _is_ important that we
return with all registers saved, but right now that is handled by the
fact that the signal trampoline we build in do_signal() will always use
"int 0x80" for the sys_sigreturn() call, and will thus use "iret" when
restoring the registers. The synchronous "[rt_]sigsuspend()" really is
a special case in that respect.

So I _think_ these are all unnecessary, but I may have missed something.
So patch not applied, but you can certainly convince me otherwise. And
even if I'm right, maybe it needs a comment?

Linus

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