Help with implementing ____longjmp_chk for Hurd

Thomas Schwinge tschwinge@gnu.org
Sat Aug 8 16:49:00 GMT 2009


Hello guys!

I'm currently looking into implementing ____longjmp_chk for Hurd on i386.
This function is now OS-specific due to its usage of sigaltstack -- see
sysdeps/unix/sysv/linux/i386/____longjmp_chk.S.

Now, my understanding of both setjmp / longjmp, and Hurd signal stuff in
glibc is not (not yet) the best one, so I'm having a few questions.

In my undestanding, why this function needs to consider sigaltstack in
the first place, is that it may be used to do a longjmp, while executing
on a sigaltstack, back into the ``main stack'' code, and thus the easy
only-jump-to-initialized-stackframe test (``jmp_buf.sp > sp'') may be
wrong.  Correct?

My plan is to use _hurd_self_sigstate()->sigaltstack as a replacement for
the sigaltstack syscall Linux is using.  Correct?

But then, in the aforementioned i386/____longjmp_chk.S file, there's
``testl $1, 4(%esp); jz .Lfail;''; in other words fail if ``!(ss_flags &
SS_ONSTACK)''.  Correct?  And why do that?  Doesn't this mean, that
always when a longjmp_chk is done, SS_ONSTACK has to be set, that is
``the process is currently executing on the alternate signal stack''
(from the sigaltstack manpage, and
<http://opengroup.org/onlinepubs/9699919799/functions/sigaltstack.html>).

And then, the following calculation of addresses, which I translate to
``if (ss_base + ss_size - jmp_buf->sp >= ss_size) then OK else fail;''
also isn't quite intuitive for me.

Help?


Regards,
 Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-help/attachments/20090808/9fb86162/attachment.sig>


More information about the Libc-help mailing list