This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Help with implementing ____longjmp_chk for Hurd


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

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]