8a8cfb
commit d5dfad4326fc683c813df1e37bbf5cf920591c8e
8a8cfb
Author: Marcin Koƛcielnicki <mwk@0x04.net>
8a8cfb
Date:   Thu Nov 21 00:20:15 2019 +0100
8a8cfb
8a8cfb
    rtld: Check __libc_enable_secure before honoring LD_PREFER_MAP_32BIT_EXEC (CVE-2019-19126) [BZ #25204]
8a8cfb
    
8a8cfb
    The problem was introduced in glibc 2.23, in commit
8a8cfb
    b9eb92ab05204df772eb4929eccd018637c9f3e9
8a8cfb
    ("Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT").
8a8cfb
8a8cfb
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
8a8cfb
index 194369174df08946..ac694c032e7baf87 100644
8a8cfb
--- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
8a8cfb
+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
8a8cfb
@@ -31,7 +31,8 @@
8a8cfb
    environment variable, LD_PREFER_MAP_32BIT_EXEC.  */
8a8cfb
 #define EXTRA_LD_ENVVARS \
8a8cfb
   case 21:								  \
8a8cfb
-    if (memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
8a8cfb
+    if (!__libc_enable_secure						  \
8a8cfb
+	&& memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
8a8cfb
       GLRO(dl_x86_cpu_features).feature[index_arch_Prefer_MAP_32BIT_EXEC] \
8a8cfb
 	|= bit_arch_Prefer_MAP_32BIT_EXEC;				  \
8a8cfb
     break;