* [hurd,commited]: Fix static initialization with -fstack-protector-strong
@ 2017-08-27 20:32 Samuel Thibault
2017-09-15 16:38 ` Nick Alcock
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2017-08-27 20:32 UTC (permalink / raw)
To: libc-alpha
When linked statically, TLS initialization is not achieved before
mach_init and alike, so ssp accesses to tcbhead's stack_guard would
crash. We can just avoid using ssp in the few functions needed before
TLS is set up.
* mach/Makefile (CFLAGS-mach_init.o, CFLAGS-RPC_vm_statistics.o,
CFLAGS-RPC_vm_map.o, CFLAGS-RPC_vm_protect.o,
CFLAGS-RPC_i386_set_gdt.o, CFLAGS-RPC_i386_set_ldt.o,
CFLAGS-RPC_task_get_special_port.o): Add $(no-stack-protector).
* hurd/Makefile (CFLAGS-hurdstartup.o,
CFLAGS-RPC_exec_startup_get_info.o): Add $(no-stack-protector).
diff --git a/hurd/Makefile b/hurd/Makefile
index 9205822b24..b44b9b80c6 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
@@ -81,6 +81,10 @@ $(inlines:%=$(objpfx)%.c): $(objpfx)%-inlines.c: %.h
echo '#include "$<"') > $@-new
mv -f $@-new $@
generated += $(inlines:=.c)
+
+# Avoid ssp before TLS is initialized.
+CFLAGS-hurdstartup.o = $(no-stack-protector)
+CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector)
\f
include ../mach/Machrules
include ../Rules
diff --git a/mach/Makefile b/mach/Makefile
index 127cad00ca..b4f18b1525 100644
--- a/mach/Makefile
+++ b/mach/Makefile
@@ -53,6 +53,15 @@ server-interfaces := mach/exc
# Clear any environment value.
generated =
+
+# Avoid ssp before TLS is initialized.
+CFLAGS-mach_init.o = $(no-stack-protector)
+CFLAGS-RPC_vm_statistics.o = $(no-stack-protector)
+CFLAGS-RPC_vm_map.o = $(no-stack-protector)
+CFLAGS-RPC_vm_protect.o = $(no-stack-protector)
+CFLAGS-RPC_i386_set_gdt.o = $(no-stack-protector)
+CFLAGS-RPC_i386_set_ldt.o = $(no-stack-protector)
+CFLAGS-RPC_task_get_special_port.o = $(no-stack-protector)
\f
# Translate GNU names for CPUs into the names used in Mach header files.
mach-machine = $(patsubst powerpc,ppc,$(base-machine))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [hurd,commited]: Fix static initialization with -fstack-protector-strong
2017-08-27 20:32 [hurd,commited]: Fix static initialization with -fstack-protector-strong Samuel Thibault
@ 2017-09-15 16:38 ` Nick Alcock
2017-09-15 21:22 ` Samuel Thibault
0 siblings, 1 reply; 3+ messages in thread
From: Nick Alcock @ 2017-09-15 16:38 UTC (permalink / raw)
To: Samuel Thibault; +Cc: libc-alpha
On 27 Aug 2017, Samuel Thibault outgrape:
> When linked statically, TLS initialization is not achieved before
> mach_init and alike, so ssp accesses to tcbhead's stack_guard would
> crash. We can just avoid using ssp in the few functions needed before
> TLS is set up.
Oh blast I forgot all about Hurd didn't I.
Sorry.
> diff --git a/hurd/Makefile b/hurd/Makefile
> index 9205822b24..b44b9b80c6 100644
> --- a/hurd/Makefile
> +++ b/hurd/Makefile
> @@ -81,6 +81,10 @@ $(inlines:%=$(objpfx)%.c): $(objpfx)%-inlines.c: %.h
> echo '#include "$<"') > $@-new
> mv -f $@-new $@
> generated += $(inlines:=.c)
> +
> +# Avoid ssp before TLS is initialized.
> +CFLAGS-hurdstartup.o = $(no-stack-protector)
> +CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector)
This certainly looks like the right sort of thing to be doing, though I
don't have anything I can test it on right now.
-fstack-protector-all might well comb out some more cases.
--
NULL && (void)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [hurd,commited]: Fix static initialization with -fstack-protector-strong
2017-09-15 16:38 ` Nick Alcock
@ 2017-09-15 21:22 ` Samuel Thibault
0 siblings, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2017-09-15 21:22 UTC (permalink / raw)
To: Nick Alcock; +Cc: libc-alpha
Nick Alcock, on ven. 15 sept. 2017 17:38:38 +0100, wrote:
> On 27 Aug 2017, Samuel Thibault outgrape:
> > When linked statically, TLS initialization is not achieved before
> > mach_init and alike, so ssp accesses to tcbhead's stack_guard would
> > crash. We can just avoid using ssp in the few functions needed before
> > TLS is set up.
>
> Oh blast I forgot all about Hurd didn't I.
>
> Sorry.
No problem. Determining which functions need it is not trivial anyway :)
Samuel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-15 21:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-27 20:32 [hurd,commited]: Fix static initialization with -fstack-protector-strong Samuel Thibault
2017-09-15 16:38 ` Nick Alcock
2017-09-15 21:22 ` 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).