|
|
2be09a |
commit ea5814467a02c9d2d7608b6445c5d60e2a81d3ee
|
|
|
2be09a |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
2be09a |
Date: Fri Dec 10 13:00:09 2021 -0800
|
|
|
2be09a |
|
|
|
2be09a |
x86-64: Remove LD_PREFER_MAP_32BIT_EXEC support [BZ #28656]
|
|
|
2be09a |
|
|
|
2be09a |
Remove the LD_PREFER_MAP_32BIT_EXEC environment variable support since
|
|
|
2be09a |
the first PT_LOAD segment is no longer executable due to defaulting to
|
|
|
2be09a |
-z separate-code.
|
|
|
2be09a |
|
|
|
2be09a |
This fixes [BZ #28656].
|
|
|
2be09a |
|
|
|
2be09a |
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
|
|
2be09a |
|
|
|
2be09a |
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
|
|
|
2be09a |
deleted file mode 100644
|
|
|
2be09a |
index 5b9696e2de8e5482..0000000000000000
|
|
|
2be09a |
--- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
|
|
|
2be09a |
+++ /dev/null
|
|
|
2be09a |
@@ -1,45 +0,0 @@
|
|
|
2be09a |
-/* Optional code to distinguish library flavours. x86-64 version.
|
|
|
2be09a |
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
|
|
|
2be09a |
- This file is part of the GNU C Library.
|
|
|
2be09a |
-
|
|
|
2be09a |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
2be09a |
- modify it under the terms of the GNU Lesser General Public
|
|
|
2be09a |
- License as published by the Free Software Foundation; either
|
|
|
2be09a |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
2be09a |
-
|
|
|
2be09a |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
2be09a |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2be09a |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2be09a |
- Lesser General Public License for more details.
|
|
|
2be09a |
-
|
|
|
2be09a |
- You should have received a copy of the GNU Lesser General Public
|
|
|
2be09a |
- License along with the GNU C Library; if not, see
|
|
|
2be09a |
- <https://www.gnu.org/licenses/>. */
|
|
|
2be09a |
-
|
|
|
2be09a |
-#ifndef _DL_LIBRECON_H
|
|
|
2be09a |
-
|
|
|
2be09a |
-#include <sysdeps/unix/sysv/linux/dl-librecon.h>
|
|
|
2be09a |
-
|
|
|
2be09a |
-/* Recognizing extra environment variables. For 64-bit applications,
|
|
|
2be09a |
- branch prediction performance may be negatively impacted when the
|
|
|
2be09a |
- target of a branch is more than 4GB away from the branch. Add the
|
|
|
2be09a |
- Prefer_MAP_32BIT_EXEC bit so that mmap will try to map executable
|
|
|
2be09a |
- pages with MAP_32BIT first. NB: MAP_32BIT will map to lower 2GB,
|
|
|
2be09a |
- not lower 4GB, address. Prefer_MAP_32BIT_EXEC reduces bits available
|
|
|
2be09a |
- for address space layout randomization (ASLR). Prefer_MAP_32BIT_EXEC
|
|
|
2be09a |
- is always disabled for SUID programs and can be enabled by setting
|
|
|
2be09a |
- environment variable, LD_PREFER_MAP_32BIT_EXEC. */
|
|
|
2be09a |
-#define EXTRA_LD_ENVVARS \
|
|
|
2be09a |
- case 21: \
|
|
|
2be09a |
- if (!__libc_enable_secure \
|
|
|
2be09a |
- && memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0) \
|
|
|
2be09a |
- GLRO(dl_x86_cpu_features).preferred[index_arch_Prefer_MAP_32BIT_EXEC] \
|
|
|
2be09a |
- |= bit_arch_Prefer_MAP_32BIT_EXEC; \
|
|
|
2be09a |
- break;
|
|
|
2be09a |
-
|
|
|
2be09a |
-/* Extra unsecure variables. The names are all stuffed in a single
|
|
|
2be09a |
- string which means they have to be terminated with a '\0' explicitly. */
|
|
|
2be09a |
-#define EXTRA_UNSECURE_ENVVARS \
|
|
|
2be09a |
- "LD_PREFER_MAP_32BIT_EXEC\0"
|
|
|
2be09a |
-
|
|
|
2be09a |
-#endif /* dl-librecon.h */
|
|
|
2be09a |
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h b/sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h
|
|
|
2be09a |
deleted file mode 100644
|
|
|
2be09a |
index 18177d2cb3ae645f..0000000000000000
|
|
|
2be09a |
--- a/sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h
|
|
|
2be09a |
+++ /dev/null
|
|
|
2be09a |
@@ -1,42 +0,0 @@
|
|
|
2be09a |
-/* Linux mmap system call. x86-64 version.
|
|
|
2be09a |
- Copyright (C) 2015-2021 Free Software Foundation, Inc.
|
|
|
2be09a |
-
|
|
|
2be09a |
- This file is part of the GNU C Library.
|
|
|
2be09a |
-
|
|
|
2be09a |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
2be09a |
- modify it under the terms of the GNU Lesser General Public License as
|
|
|
2be09a |
- published by the Free Software Foundation; either version 2.1 of the
|
|
|
2be09a |
- License, or (at your option) any later version.
|
|
|
2be09a |
-
|
|
|
2be09a |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
2be09a |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2be09a |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2be09a |
- Lesser General Public License for more details.
|
|
|
2be09a |
-
|
|
|
2be09a |
- You should have received a copy of the GNU Lesser General Public
|
|
|
2be09a |
- License along with the GNU C Library; if not, see
|
|
|
2be09a |
- <https://www.gnu.org/licenses/>. */
|
|
|
2be09a |
-
|
|
|
2be09a |
-#ifndef MMAP_X86_64_INTERNAL_H
|
|
|
2be09a |
-#define MMAP_X86_64_INTERNAL_H
|
|
|
2be09a |
-
|
|
|
2be09a |
-#include <ldsodefs.h>
|
|
|
2be09a |
-
|
|
|
2be09a |
-/* If the Prefer_MAP_32BIT_EXEC bit is set, try to map executable pages
|
|
|
2be09a |
- with MAP_32BIT first. */
|
|
|
2be09a |
-#define MMAP_PREPARE(addr, len, prot, flags, fd, offset) \
|
|
|
2be09a |
- if ((addr) == NULL \
|
|
|
2be09a |
- && ((prot) & PROT_EXEC) != 0 \
|
|
|
2be09a |
- && HAS_ARCH_FEATURE (Prefer_MAP_32BIT_EXEC)) \
|
|
|
2be09a |
- { \
|
|
|
2be09a |
- void *ret = (void*) INLINE_SYSCALL_CALL (mmap, (addr), (len), \
|
|
|
2be09a |
- (prot), \
|
|
|
2be09a |
- (flags) | MAP_32BIT, \
|
|
|
2be09a |
- (fd), (offset)); \
|
|
|
2be09a |
- if (ret != MAP_FAILED) \
|
|
|
2be09a |
- return ret; \
|
|
|
2be09a |
- }
|
|
|
2be09a |
-
|
|
|
2be09a |
-#include_next <mmap_internal.h>
|
|
|
2be09a |
-
|
|
|
2be09a |
-#endif
|
|
|
2be09a |
diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c
|
|
|
2be09a |
index 00fe5045eb56eb07..58f2fad4323d5d91 100644
|
|
|
2be09a |
--- a/sysdeps/x86/cpu-tunables.c
|
|
|
2be09a |
+++ b/sysdeps/x86/cpu-tunables.c
|
|
|
2be09a |
@@ -260,13 +260,6 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
|
|
|
2be09a |
20);
|
|
|
2be09a |
}
|
|
|
2be09a |
break;
|
|
|
2be09a |
- case 21:
|
|
|
2be09a |
- {
|
|
|
2be09a |
- CHECK_GLIBC_IFUNC_PREFERRED_BOTH (n, cpu_features,
|
|
|
2be09a |
- Prefer_MAP_32BIT_EXEC,
|
|
|
2be09a |
- disable, 21);
|
|
|
2be09a |
- }
|
|
|
2be09a |
- break;
|
|
|
2be09a |
case 23:
|
|
|
2be09a |
{
|
|
|
2be09a |
CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH
|
|
|
2be09a |
diff --git a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
|
|
|
2be09a |
index d7c93f00c5928a30..3bdc76cf71007948 100644
|
|
|
2be09a |
--- a/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
|
|
|
2be09a |
+++ b/sysdeps/x86/include/cpu-features-preferred_feature_index_1.def
|
|
|
2be09a |
@@ -26,7 +26,6 @@ BIT (I586)
|
|
|
2be09a |
BIT (I686)
|
|
|
2be09a |
BIT (Slow_SSE4_2)
|
|
|
2be09a |
BIT (AVX_Fast_Unaligned_Load)
|
|
|
2be09a |
-BIT (Prefer_MAP_32BIT_EXEC)
|
|
|
2be09a |
BIT (Prefer_No_VZEROUPPER)
|
|
|
2be09a |
BIT (Prefer_ERMS)
|
|
|
2be09a |
BIT (Prefer_No_AVX512)
|