From: "LeMay, Michael" <michael.lemay@intel.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: [RFC PATCH v2 3/4] support dynamic linking with SafeStack
Date: Fri, 28 Oct 2016 20:02:32 +0000 [thread overview]
Message-ID: <390CE752059EB848A71F4F676EBAB76D3AC2637F@ORSMSX114.amr.corp.intel.com> (raw)
This patch initializes SafeStack during dynamic linker initialization.
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
---
ldso/dynlink.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index e458f38..f9a381f 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1324,9 +1324,17 @@ static void update_tls_size()
* linker itself, but some of the relocations performed may need to be
* replaced later due to copy relocations in the main program. */
+#if SAFE_STACK
+void __preinit_unsafe_stack(void);
+__attribute__((no_sanitize("safe-stack")))
+#endif
__attribute__((__visibility__("hidden")))
void __dls2(unsigned char *base, size_t *sp)
{
+#if SAFE_STACK
+ __preinit_unsafe_stack();
+#endif
+
if (DL_FDPIC) {
void *p1 = (void *)sp[-2];
void *p2 = (void *)sp[-1];
@@ -1388,6 +1396,10 @@ void __dls2(unsigned char *base, size_t *sp)
* process dependencies and relocations for the main application and
* transfer control to its entry point. */
+#if SAFE_STACK
+void __init_unsafe_stack(void);
+__attribute__((no_sanitize("safe-stack")))
+#endif
_Noreturn void __dls3(size_t *sp)
{
static struct dso app, vdso;
@@ -1420,6 +1432,10 @@ _Noreturn void __dls3(size_t *sp)
a_crash();
}
+#if SAFE_STACK
+ __init_unsafe_stack();
+#endif
+
/* Only trust user/env if kernel says we're not suid/sgid */
if (!libc.secure) {
env_path = getenv("LD_LIBRARY_PATH");
--
2.7.4
reply other threads:[~2016-10-28 20:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=390CE752059EB848A71F4F676EBAB76D3AC2637F@ORSMSX114.amr.corp.intel.com \
--to=michael.lemay@intel.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).