Re: [PATCH] Fix sigaltstack corruption among cloned threads

From: Jakub Jelinek
Date: Mon Mar 13 2006 - 10:28:13 EST


On Mon, Mar 13, 2006 at 07:16:17AM -0800, Ulrich Drepper wrote:
> On 3/13/06, GOTO Masanori <gotom@xxxxxxxxxx> wrote:
> > + * sigaltstack should be cleared when CLONE_SIGHAND (and CLONE_VM) is
> > + * specified.
> > + */
> > + if (clone_flags & CLONE_SIGHAND)
> > + p->sas_ss_sp = p->sas_ss_size = 0;
>
> I agree in general, but why base it on CLONE_SIGHAND? The problem
> results from using the same address space. So it should be
>
> if (clone_flags & CLONE_VM)
>
> The fact that both these flags are used at the same time in all cases
> today shouldn't hide the real reason for this requirement which is
> sharing the address space.

Because vfork also sets CLONE_VM and vfork isn't supposed to reset
alternate stack setting. For vfork that's not a problem, as the parent task
will not continue until the vfork child execve's. So, if you want to use
CLONE_VM bit, you'd need to use
if ((clone_flags & (CLONE_VM | CLONE_VFORK)) == CLONE_VM)
p->sas_ss_sp = p->sas_ss_size = 0;

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