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