about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/i386/__longjmp.S
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-07-18 15:08:03 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-07-18 15:08:03 +0200
commit115bcf921a52005b89ff2859ccae4a8fc6d6deed (patch)
treef29c4f3cd3674f5102885e19d7ee70235c709edf /sysdeps/mach/hurd/i386/__longjmp.S
parente9422236a2dd4cf2b7e900af5e84706da68bd43e (diff)
downloadglibc-115bcf921a52005b89ff2859ccae4a8fc6d6deed.tar.gz
glibc-115bcf921a52005b89ff2859ccae4a8fc6d6deed.tar.xz
glibc-115bcf921a52005b89ff2859ccae4a8fc6d6deed.zip
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.
Diffstat (limited to 'sysdeps/mach/hurd/i386/__longjmp.S')
-rw-r--r--sysdeps/mach/hurd/i386/__longjmp.S9
1 files changed, 8 insertions, 1 deletions
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