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