|
From: John R.
|
>> - You then do "stack--", which moves "stack" down one frame unit. Now
>> it overlaps with the kernel-constructed sigframe.
>
> No... the signal handler is called on a different stack than the one the
> thread... (sigaction is called with SA_ONSTACK flag)
The code was not clear enough; it fooled at least a couple analysts.
Add a comment at the receiving end which documents the expectations.
For example:
-----
void handler_new( int signo, siginfo_t* xx, void* uc)
{
ucontext_t* ctx = (ucontext_t*)uc;
printf("in handler2, setting EIP to %p\n", (void*)&diversion);
stack = (struct stack_layout*)ctx->uc_mcontext.gregs[REG_ESP];
stack--; /* push the stack_layout structure */
/* handler_new was established with SA_ONSTACK. So we
are on the alternate stack, while 'stack' points to
the user stack, which the kernel left undisturbed.
*/
-----
--
|