public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] hurd: Fix longjmp early in initialization
@ 2020-07-18 13:11 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2020-07-18 13:11 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=115bcf921a52005b89ff2859ccae4a8fc6d6deed

commit 115bcf921a52005b89ff2859ccae4a8fc6d6deed
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sat Jul 18 15:08:03 2020 +0200

    hurd: Fix longjmp early in initialization
    
    When e.g. an LD_PRELOAD fails, _dl_signal_exception/error longjmps, but TLS
    is not initialized yet, let along signal state.  We thus mustn't look at
    them within __longjmp.
    
    * sysdeps/mach/hurd/i386/____longjmp_chk.S,__longjmp.S: Check for
    initialized value of %gs, and that sigstate is non-NULL.

Diff:
---
 sysdeps/mach/hurd/i386/____longjmp_chk.S | 9 ++++++++-
 sysdeps/mach/hurd/i386/__longjmp.S       | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/sysdeps/mach/hurd/i386/____longjmp_chk.S b/sysdeps/mach/hurd/i386/____longjmp_chk.S
index 4d3a331728..5131386c60 100644
--- a/sysdeps/mach/hurd/i386/____longjmp_chk.S
+++ b/sysdeps/mach/hurd/i386/____longjmp_chk.S
@@ -60,7 +60,14 @@ ENTRY (____longjmp_chk)
 	PTR_DEMANGLE (%ecx)
 #endif
 
-	movl	%gs:SIGSTATE_OFFSET,%edi
+	movw	%ds, %si
+	movw	%gs, %di
+	cmpw	%si, %di
+	jz	.Lok		/* TLS not initialized yet */
+
+	movl	%gs:SIGSTATE_OFFSET, %edi
+	testl	%edi, %edi
+	jnz	.Lok		/* sigstate not initialized yet */
 
 	testl	$SS_ONSTACK, (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_FLAGS__OFFSET)(%edi)
 	jnz	.Lonstack
diff --git a/sysdeps/mach/hurd/i386/__longjmp.S b/sysdeps/mach/hurd/i386/__longjmp.S
index d123c214c9..73bbff9826 100644
--- a/sysdeps/mach/hurd/i386/__longjmp.S
+++ b/sysdeps/mach/hurd/i386/__longjmp.S
@@ -38,7 +38,14 @@ ENTRY (__longjmp)
 	PTR_DEMANGLE (%ecx)
 #endif
 
-	movl	%gs:SIGSTATE_OFFSET,%edi
+	movw	%ds, %si
+	movw	%gs, %di
+	cmpw	%si, %di
+	jz	.Lok		/* TLS not initialized yet */
+
+	movl	%gs:SIGSTATE_OFFSET, %edi
+	testl	%edi, %edi
+	jnz	.Lok		/* sigstate not initialized yet */
 
 	testl	$SS_ONSTACK, (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_FLAGS__OFFSET)(%edi)
 	jz	.Lok


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-18 13:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-18 13:11 [glibc] hurd: Fix longjmp early in initialization Samuel Thibault

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).