glibc/glibc-nosymlink-3.patch

132 lines
4.8 KiB
Diff
Raw Normal View History

Patch series proposed upstream:
<https://sourceware.org/pipermail/libc-alpha/2021-June/127473.html>
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Jun 9 14:12:46 2021 +0200
elf: Generalize name-based DSO recognition in ldconfig
This introduces <dl-is_dso.h> and the _dl_is_dso function. A
test ensures that the official names of libc.so, ld.so, and their
versioned names are recognized.
Auto-sync with upstream branch master Upstream commit: 2c16cb88a6e5ace0fb7cedca86860ea7bde522a7 - Linux: Move timer helper routines from librt to libc - Linux: Move mq_unlink from librt to libc - Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc - Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc - Linux: Move mq_open, __mq_open_2 from librt to libc - Linux: Move mq_notify from librt to libc - Linux: Move mq_getattr from librt to libc - Linux: Move mq_setattr from librt to libc - Linux: Move mq_close from librt to libc - Linux: Move lio_listio, lio_listio64 from librt to libc - rt: Rework lio_listio implementation - Linux: Move aio_write, aio_write64 into libc - Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc - Linux: Move aio_return, aio_return64 into libc - Linux: Move aio_read, aio_read64 into libc - Linux: Move aio_fsync, aio_fsync64 into libc - Linux: Move aio_error, aio_error64 into libc - Linux: Move aio_cancel, aio_cancel64 into libc - Linux: Move aio_init from librt into libc - support: Fix xclone build failures on ia64 and hppa - elf: Disable most of TLS modid gaps processing [BZ #27135] - elf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046] - * NEWS: Clarify _TIME_BITS change. - x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S - String: Add three more overflow tests cases to test-strnlen.c - Consolidate pthread_atfork - posix: Do not clobber errno by atfork handlers - posix: Consolidate fork implementation - support: Add xclone - x86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873) - x86: Copy IBT and SHSTK usable only if CET is enabled - x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974] - x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974] - String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974] - x86-64: Add wcslen optimize for sse4.1 - x86-64: Move strlen.S to multiarch/strlen-vec.S - hurd: Fix build after 52a5fe70a2 - nptl: Use SA_RESTART for SIGCANCEL handler - doc: _TIME_BITS defaults may change - More mcheck -> malloc-check refactoring - Add NEWS item for gconv-modules.d change - Handle DT_UNKNOWN in gconv-modules.d - iconvconfig: Use common gconv module parsing function - gconv_conf: Split out configuration file processing - gconv_conf: Remove unused variables - iconv: Remove alloca use in gconv-modules configuration parsing - Remove unsused symbols from nptl/Versions - linux: Only use 64-bit syscall if required for clock_nanosleep - linux: Only use 64-bit syscall if required for internal futex - linux: Only use 64-bit syscall if required for utimensat family - linux: Only use 64-bit syscall if required for sigtimedwait - linux: Only use 64-bit syscall if required for mq_timedsend - linux: Only use 64-bit syscall if required for mq_timedreceive - linux: Only use 64-bit syscall if required for timerfd_settime - linux: Only use 64-bit syscall if required for semtimedop - linux: timerfd_gettime minor cleanup - linux: Remove time64-support - linux: Remove supports_time64 () from clock_gettime - linux: Remove supports_time64 () from clock_getres - linux: Only use 64-bit syscall if required for select - linux: Only use 64-bit syscall if required for pselect - linux: Only use 64-bit syscall if required for ppoll - support: Add support_create_timer - Use 64 bit time_t stat internally - malloc: Drop __malloc_initialized from Versions - tst-mcheck: Rename to tst-malloc-check - Add hidden prototypes for fsync, fdatasync - nptl: Move pthreadP.h into sysdeps directory - rt: Move generic implementation from sysdeps/pthread to rt - rt: Move shm_unlink into libc - rt: Move shm_open into libc - rt: Replace generic stub of shm_unlink with the posix version - rt: Replace generic stub of shm_open with the posix version - Fix librt-routines-var issues for !PTHREAD_IN_LIBC - rt: Lexicographically sort Versions file; librt-routines in Makefile - elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646] - Makeconfig: Fix time64-compat.mk target
2021-06-27 14:02:30 +00:00
diff --git a/elf/Makefile b/elf/Makefile
Auto-sync with upstream branch master Upstream commit: 2c16cb88a6e5ace0fb7cedca86860ea7bde522a7 - Linux: Move timer helper routines from librt to libc - Linux: Move mq_unlink from librt to libc - Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc - Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc - Linux: Move mq_open, __mq_open_2 from librt to libc - Linux: Move mq_notify from librt to libc - Linux: Move mq_getattr from librt to libc - Linux: Move mq_setattr from librt to libc - Linux: Move mq_close from librt to libc - Linux: Move lio_listio, lio_listio64 from librt to libc - rt: Rework lio_listio implementation - Linux: Move aio_write, aio_write64 into libc - Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc - Linux: Move aio_return, aio_return64 into libc - Linux: Move aio_read, aio_read64 into libc - Linux: Move aio_fsync, aio_fsync64 into libc - Linux: Move aio_error, aio_error64 into libc - Linux: Move aio_cancel, aio_cancel64 into libc - Linux: Move aio_init from librt into libc - support: Fix xclone build failures on ia64 and hppa - elf: Disable most of TLS modid gaps processing [BZ #27135] - elf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046] - * NEWS: Clarify _TIME_BITS change. - x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S - String: Add three more overflow tests cases to test-strnlen.c - Consolidate pthread_atfork - posix: Do not clobber errno by atfork handlers - posix: Consolidate fork implementation - support: Add xclone - x86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873) - x86: Copy IBT and SHSTK usable only if CET is enabled - x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974] - x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974] - String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974] - x86-64: Add wcslen optimize for sse4.1 - x86-64: Move strlen.S to multiarch/strlen-vec.S - hurd: Fix build after 52a5fe70a2 - nptl: Use SA_RESTART for SIGCANCEL handler - doc: _TIME_BITS defaults may change - More mcheck -> malloc-check refactoring - Add NEWS item for gconv-modules.d change - Handle DT_UNKNOWN in gconv-modules.d - iconvconfig: Use common gconv module parsing function - gconv_conf: Split out configuration file processing - gconv_conf: Remove unused variables - iconv: Remove alloca use in gconv-modules configuration parsing - Remove unsused symbols from nptl/Versions - linux: Only use 64-bit syscall if required for clock_nanosleep - linux: Only use 64-bit syscall if required for internal futex - linux: Only use 64-bit syscall if required for utimensat family - linux: Only use 64-bit syscall if required for sigtimedwait - linux: Only use 64-bit syscall if required for mq_timedsend - linux: Only use 64-bit syscall if required for mq_timedreceive - linux: Only use 64-bit syscall if required for timerfd_settime - linux: Only use 64-bit syscall if required for semtimedop - linux: timerfd_gettime minor cleanup - linux: Remove time64-support - linux: Remove supports_time64 () from clock_gettime - linux: Remove supports_time64 () from clock_getres - linux: Only use 64-bit syscall if required for select - linux: Only use 64-bit syscall if required for pselect - linux: Only use 64-bit syscall if required for ppoll - support: Add support_create_timer - Use 64 bit time_t stat internally - malloc: Drop __malloc_initialized from Versions - tst-mcheck: Rename to tst-malloc-check - Add hidden prototypes for fsync, fdatasync - nptl: Move pthreadP.h into sysdeps directory - rt: Move generic implementation from sysdeps/pthread to rt - rt: Move shm_unlink into libc - rt: Move shm_open into libc - rt: Replace generic stub of shm_unlink with the posix version - rt: Replace generic stub of shm_open with the posix version - Fix librt-routines-var issues for !PTHREAD_IN_LIBC - rt: Lexicographically sort Versions file; librt-routines in Makefile - elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646] - Makeconfig: Fix time64-compat.mk target
2021-06-27 14:02:30 +00:00
index 38d08e03b8979a81..62f7e8a22544ab9d 100644
--- a/elf/Makefile
+++ b/elf/Makefile
Auto-sync with upstream branch master Upstream commit: 2c16cb88a6e5ace0fb7cedca86860ea7bde522a7 - Linux: Move timer helper routines from librt to libc - Linux: Move mq_unlink from librt to libc - Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc - Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc - Linux: Move mq_open, __mq_open_2 from librt to libc - Linux: Move mq_notify from librt to libc - Linux: Move mq_getattr from librt to libc - Linux: Move mq_setattr from librt to libc - Linux: Move mq_close from librt to libc - Linux: Move lio_listio, lio_listio64 from librt to libc - rt: Rework lio_listio implementation - Linux: Move aio_write, aio_write64 into libc - Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc - Linux: Move aio_return, aio_return64 into libc - Linux: Move aio_read, aio_read64 into libc - Linux: Move aio_fsync, aio_fsync64 into libc - Linux: Move aio_error, aio_error64 into libc - Linux: Move aio_cancel, aio_cancel64 into libc - Linux: Move aio_init from librt into libc - support: Fix xclone build failures on ia64 and hppa - elf: Disable most of TLS modid gaps processing [BZ #27135] - elf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046] - * NEWS: Clarify _TIME_BITS change. - x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S - String: Add three more overflow tests cases to test-strnlen.c - Consolidate pthread_atfork - posix: Do not clobber errno by atfork handlers - posix: Consolidate fork implementation - support: Add xclone - x86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873) - x86: Copy IBT and SHSTK usable only if CET is enabled - x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974] - x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974] - String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974] - x86-64: Add wcslen optimize for sse4.1 - x86-64: Move strlen.S to multiarch/strlen-vec.S - hurd: Fix build after 52a5fe70a2 - nptl: Use SA_RESTART for SIGCANCEL handler - doc: _TIME_BITS defaults may change - More mcheck -> malloc-check refactoring - Add NEWS item for gconv-modules.d change - Handle DT_UNKNOWN in gconv-modules.d - iconvconfig: Use common gconv module parsing function - gconv_conf: Split out configuration file processing - gconv_conf: Remove unused variables - iconv: Remove alloca use in gconv-modules configuration parsing - Remove unsused symbols from nptl/Versions - linux: Only use 64-bit syscall if required for clock_nanosleep - linux: Only use 64-bit syscall if required for internal futex - linux: Only use 64-bit syscall if required for utimensat family - linux: Only use 64-bit syscall if required for sigtimedwait - linux: Only use 64-bit syscall if required for mq_timedsend - linux: Only use 64-bit syscall if required for mq_timedreceive - linux: Only use 64-bit syscall if required for timerfd_settime - linux: Only use 64-bit syscall if required for semtimedop - linux: timerfd_gettime minor cleanup - linux: Remove time64-support - linux: Remove supports_time64 () from clock_gettime - linux: Remove supports_time64 () from clock_getres - linux: Only use 64-bit syscall if required for select - linux: Only use 64-bit syscall if required for pselect - linux: Only use 64-bit syscall if required for ppoll - support: Add support_create_timer - Use 64 bit time_t stat internally - malloc: Drop __malloc_initialized from Versions - tst-mcheck: Rename to tst-malloc-check - Add hidden prototypes for fsync, fdatasync - nptl: Move pthreadP.h into sysdeps directory - rt: Move generic implementation from sysdeps/pthread to rt - rt: Move shm_unlink into libc - rt: Move shm_open into libc - rt: Replace generic stub of shm_unlink with the posix version - rt: Replace generic stub of shm_open with the posix version - Fix librt-routines-var issues for !PTHREAD_IN_LIBC - rt: Lexicographically sort Versions file; librt-routines in Makefile - elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646] - Makeconfig: Fix time64-compat.mk target
2021-06-27 14:02:30 +00:00
@@ -223,7 +223,8 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
tst-single_threaded tst-single_threaded-pthread \
tst-tls-ie tst-tls-ie-dlmopen argv0test \
tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \
Auto-sync with upstream branch master Upstream commit: 2c16cb88a6e5ace0fb7cedca86860ea7bde522a7 - Linux: Move timer helper routines from librt to libc - Linux: Move mq_unlink from librt to libc - Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc - Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc - Linux: Move mq_open, __mq_open_2 from librt to libc - Linux: Move mq_notify from librt to libc - Linux: Move mq_getattr from librt to libc - Linux: Move mq_setattr from librt to libc - Linux: Move mq_close from librt to libc - Linux: Move lio_listio, lio_listio64 from librt to libc - rt: Rework lio_listio implementation - Linux: Move aio_write, aio_write64 into libc - Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc - Linux: Move aio_return, aio_return64 into libc - Linux: Move aio_read, aio_read64 into libc - Linux: Move aio_fsync, aio_fsync64 into libc - Linux: Move aio_error, aio_error64 into libc - Linux: Move aio_cancel, aio_cancel64 into libc - Linux: Move aio_init from librt into libc - support: Fix xclone build failures on ia64 and hppa - elf: Disable most of TLS modid gaps processing [BZ #27135] - elf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046] - * NEWS: Clarify _TIME_BITS change. - x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S - String: Add three more overflow tests cases to test-strnlen.c - Consolidate pthread_atfork - posix: Do not clobber errno by atfork handlers - posix: Consolidate fork implementation - support: Add xclone - x86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873) - x86: Copy IBT and SHSTK usable only if CET is enabled - x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974] - x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974] - String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974] - x86-64: Add wcslen optimize for sse4.1 - x86-64: Move strlen.S to multiarch/strlen-vec.S - hurd: Fix build after 52a5fe70a2 - nptl: Use SA_RESTART for SIGCANCEL handler - doc: _TIME_BITS defaults may change - More mcheck -> malloc-check refactoring - Add NEWS item for gconv-modules.d change - Handle DT_UNKNOWN in gconv-modules.d - iconvconfig: Use common gconv module parsing function - gconv_conf: Split out configuration file processing - gconv_conf: Remove unused variables - iconv: Remove alloca use in gconv-modules configuration parsing - Remove unsused symbols from nptl/Versions - linux: Only use 64-bit syscall if required for clock_nanosleep - linux: Only use 64-bit syscall if required for internal futex - linux: Only use 64-bit syscall if required for utimensat family - linux: Only use 64-bit syscall if required for sigtimedwait - linux: Only use 64-bit syscall if required for mq_timedsend - linux: Only use 64-bit syscall if required for mq_timedreceive - linux: Only use 64-bit syscall if required for timerfd_settime - linux: Only use 64-bit syscall if required for semtimedop - linux: timerfd_gettime minor cleanup - linux: Remove time64-support - linux: Remove supports_time64 () from clock_gettime - linux: Remove supports_time64 () from clock_getres - linux: Only use 64-bit syscall if required for select - linux: Only use 64-bit syscall if required for pselect - linux: Only use 64-bit syscall if required for ppoll - support: Add support_create_timer - Use 64 bit time_t stat internally - malloc: Drop __malloc_initialized from Versions - tst-mcheck: Rename to tst-malloc-check - Add hidden prototypes for fsync, fdatasync - nptl: Move pthreadP.h into sysdeps directory - rt: Move generic implementation from sysdeps/pthread to rt - rt: Move shm_unlink into libc - rt: Move shm_open into libc - rt: Replace generic stub of shm_unlink with the posix version - rt: Replace generic stub of shm_open with the posix version - Fix librt-routines-var issues for !PTHREAD_IN_LIBC - rt: Lexicographically sort Versions file; librt-routines in Makefile - elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646] - Makeconfig: Fix time64-compat.mk target
2021-06-27 14:02:30 +00:00
- tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dlmopen-gethostbyname
+ tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dlmopen-gethostbyname \
+ tst-dl-is_dso
# reldep9
tests-internal += loadtest unload unload2 circleload1 \
neededtest neededtest2 neededtest3 neededtest4 \
diff --git a/elf/dl-is_dso.h b/elf/dl-is_dso.h
new file mode 100644
index 0000000000000000..94e00966a16e0df5
--- /dev/null
+++ b/elf/dl-is_dso.h
@@ -0,0 +1,33 @@
+/* Heuristic for recognizing DSO file names.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <string.h>
+
+/* Returns true if the file name looks like a DSO name. */
+static bool
+_dl_is_dso (const char *name)
+{
+ /* Recognize lib*.so*, ld-*.so*, ld.so.*, ld64.so.*. ld-*.so*
+ matches both platform dynamic linker names like ld-linux.so.2,
+ and versioned dynamic loader names like ld-2.12.so. */
+ return (((strncmp (name, "lib", 3) == 0 || strncmp (name, "ld-", 3) == 0)
+ && strstr (name, ".so") != NULL)
+ || strncmp (name, "ld.so.", 6) == 0
+ || strncmp (name, "ld64.so.", 8) == 0);
+}
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 96bf7700b2efd37a..1037e8d0cf8d28b6 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -43,6 +43,7 @@
#include <ldconfig.h>
#include <dl-cache.h>
#include <dl-hwcaps.h>
+#include <dl-is_dso.h>
#include <dl-procinfo.h>
@@ -842,9 +843,7 @@ search_dir (const struct dir_entry *entry)
subdirectory (if not already processing a glibc-hwcaps
subdirectory)? The dynamic linker is also considered as
shared library. */
- if (((strncmp (direntry->d_name, "lib", 3) != 0
- && strncmp (direntry->d_name, "ld-", 3) != 0)
- || strstr (direntry->d_name, ".so") == NULL)
+ if (!_dl_is_dso (direntry->d_name)
&& (direntry->d_type == DT_REG
|| (entry->hwcaps == NULL
&& !is_hwcap_platform (direntry->d_name))))
diff --git a/elf/tst-dl-is_dso.c b/elf/tst-dl-is_dso.c
new file mode 100644
index 0000000000000000..48d2cc9fbe9edbc6
--- /dev/null
+++ b/elf/tst-dl-is_dso.c
@@ -0,0 +1,35 @@
+/* Test heuristic for recognizing DSO file names.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <dl-is_dso.h>
+#include <gnu/lib-names.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+ /* Official ABI names. */
+ TEST_VERIFY (_dl_is_dso (LIBC_SO));
+ TEST_VERIFY (_dl_is_dso (LD_SO));
+ /* Version-based names. The version number does not matter. */
+ TEST_VERIFY (_dl_is_dso ("libc-2.12.so"));
+ TEST_VERIFY (_dl_is_dso ("ld-2.12.so"));
+ return 0;
+}
+
+#include <support/test-driver.c>