mailing list of musl libc
 help / color / mirror / code / Atom feed
* [RFC PATCH v2 3/4] support dynamic linking with SafeStack
@ 2016-10-28 20:02 LeMay, Michael
  0 siblings, 0 replies; only message in thread
From: LeMay, Michael @ 2016-10-28 20:02 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-28 20:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28 20:02 [RFC PATCH v2 3/4] support dynamic linking with SafeStack LeMay, Michael

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