public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] tst-setcontext10.c: Undef _FORTIFY_SOURCE
@ 2023-12-19 18:02 H.J. Lu
  2023-12-19 20:28 ` Florian Weimer
  2023-12-19 21:22 ` Siddhesh Poyarekar
  0 siblings, 2 replies; 10+ messages in thread
From: H.J. Lu @ 2023-12-19 18:02 UTC (permalink / raw)
  To: libc-alpha; +Cc: adhemerval.zanella

When _FORTIFY_SOURCE is defined to 2, ____longjmp_chk is called,
instead of longjmp.  ____longjmp_chk compares the relative stack
values to decide if it is called from a stack frame which called
setjmp.  If not, ____longjmp_chk assumes that an alternate signal
stack is used.  Since comparing the relative stack values isn't
reliable with user context, when there is no signal, ____longjmp_chk
will fail.  Undefine _FORTIFY_SOURCE to avoid ____longjmp_chk in
user context test.
---
 stdlib/tst-setcontext10.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 2926753cb1..d714563742 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -16,6 +16,15 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+/* When _FORTIFY_SOURCE is defined to 2, ____longjmp_chk is called,
+   instead of longjmp.  ____longjmp_chk compares the relative stack
+   values to decide if it is called from a stack frame which called
+   setjmp.  If not, ____longjmp_chk assumes that an alternate signal
+   stack is used.  Since comparing the relative stack values isn't
+   reliable with user context, when there is no signal, ____longjmp_chk
+   will fail.  Undefine _FORTIFY_SOURCE to avoid ____longjmp_chk.  */
+#undef _FORTIFY_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-20 19:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 18:02 [PATCH] tst-setcontext10.c: Undef _FORTIFY_SOURCE H.J. Lu
2023-12-19 20:28 ` Florian Weimer
2023-12-19 21:03   ` H.J. Lu
2023-12-20  7:57     ` Florian Weimer
2023-12-20 12:54       ` H.J. Lu
2023-12-20 19:06         ` H.J. Lu
2023-12-19 21:22 ` Siddhesh Poyarekar
2023-12-19 21:31   ` H.J. Lu
2023-12-19 21:38     ` Siddhesh Poyarekar
2023-12-19 21:40       ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).