public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Unconditionally define __stack_chk_guard [BZ #26817]
@ 2021-01-11  3:12 Fangrui Song
  2021-01-11  9:39 ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Fangrui Song @ 2021-01-11  3:12 UTC (permalink / raw)
  To: libc-alpha; +Cc: Fangrui Song

This makes -mstack-protector-guard=global work even if
-mstack-protector-guard=tls is the default.
---
 csu/libc-start.c | 8 ++------
 elf/rtld.c       | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/csu/libc-start.c b/csu/libc-start.c
index db859c3bed..e46d402664 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -33,11 +33,8 @@ extern void __libc_init_first (int argc, char **argv, char **envp);
 #include <tls.h>
 #ifndef SHARED
 # include <dl-osinfo.h>
-# ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
-   in thread local area.  */
+/* Also export to architectures which prefer -mstack-protector-guard=tls.  */
 uintptr_t __stack_chk_guard attribute_relro;
-# endif
 # ifndef  THREAD_SET_POINTER_GUARD
 /* Only exported for architectures that don't store the pointer guard
    value in thread local area.  */
@@ -206,9 +203,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
   uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
 # ifdef THREAD_SET_STACK_GUARD
   THREAD_SET_STACK_GUARD (stack_chk_guard);
-# else
+# endif
   __stack_chk_guard = stack_chk_guard;
-# endif
 
 # ifdef DL_SYSDEP_OSCHECK
   {
diff --git a/elf/rtld.c b/elf/rtld.c
index 8d9add90e3..cd70428c46 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -154,11 +154,8 @@ unsigned int _dl_skip_args attribute_relro attribute_hidden;
 #endif
 rtld_hidden_data_def (_dl_argv)
 
-#ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
-   in thread local area.  */
+/* Also export to architectures which prefer -mstack-protector-guard=tls.  */
 uintptr_t __stack_chk_guard attribute_relro;
-#endif
 
 /* Only exported for architectures that don't store the pointer guard
    value in thread local area.  */
@@ -865,9 +862,8 @@ security_init (void)
   uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
 #ifdef THREAD_SET_STACK_GUARD
   THREAD_SET_STACK_GUARD (stack_chk_guard);
-#else
+#endif
   __stack_chk_guard = stack_chk_guard;
-#endif
 
   /* Set up the pointer guard as well, if necessary.  */
   uintptr_t pointer_chk_guard
-- 
2.30.0.284.gd98b1dd5eaa7-goog


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

end of thread, other threads:[~2021-01-14 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11  3:12 [PATCH] Unconditionally define __stack_chk_guard [BZ #26817] Fangrui Song
2021-01-11  9:39 ` Florian Weimer
2021-01-11 17:40   ` Fāng-ruì Sòng
2021-01-11 17:49     ` Florian Weimer
2021-01-12  7:58       ` Fāng-ruì Sòng
2021-01-14 10:09         ` Florian Weimer

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