public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: libc-alpha@sourceware.org
Cc: Fangrui Song <maskray@google.com>
Subject: [PATCH] Unconditionally define __stack_chk_guard [BZ #26817]
Date: Sun, 10 Jan 2021 19:12:10 -0800	[thread overview]
Message-ID: <20210111031210.4020603-1-maskray@google.com> (raw)

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


             reply	other threads:[~2021-01-11  3:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11  3:12 Fangrui Song [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111031210.4020603-1-maskray@google.com \
    --to=maskray@google.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).