Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <390CE752059EB848A71F4F676EBAB76D3AC2637F@ORSMSX114.amr.corp.intel.com>
Date: Fri, 28 Oct 2016 20:02:32 +0000
From: "LeMay, Michael" <michael.lemay@...el.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: [RFC PATCH v2 3/4] support dynamic linking with SafeStack

This patch initializes SafeStack during dynamic linker initialization.

Signed-off-by: Michael LeMay <michael.lemay@...el.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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.