From ed768104cf76ae6754c0908a9b24d951580feccc Mon Sep 17 00:00:00 2001 From: shixuantong Date: Fri, 29 Nov 2024 11:01:00 +0800 Subject: [PATCH] sync some patches: elf: avoid jumping over a needed declaration elf: Move __rtld_malloc_init_stubs call into _dl_start_final (cherry picked from commit 6b2ec1fa1524750b9d8282baf3e13e739a0d5d80) --- ...malloc_init_stubs-call-into-_dl_star.patch | 42 ++++++++++++++++++ ...id-jumping-over-a-needed-declaration.patch | 44 +++++++++++++++++++ glibc.spec | 11 ++++- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch create mode 100644 backport-elf-avoid-jumping-over-a-needed-declaration.patch diff --git a/backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch b/backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch new file mode 100644 index 0000000..c705825 --- /dev/null +++ b/backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch @@ -0,0 +1,42 @@ +From 2abfa1907218c5ec9d52bb81bee3f1af652f67c7 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 24 Sep 2024 13:23:10 +0200 +Subject: [PATCH] elf: Move __rtld_malloc_init_stubs call into _dl_start_final + +Reference:https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2abfa1907218c5ec9d52bb81bee3f1af652f67c7 +Conflict:NA + +Calling an extern function in a different translation unit before +self-relocation is brittle. The compiler may load the address +at an earlier point in _dl_start, before self-relocation. In +_dl_start_final, the call is behind a compiler barrier, so this +cannot happen. +--- + elf/rtld.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/elf/rtld.c b/elf/rtld.c +index 13b4134b..5a82c1ab 100644 +--- a/elf/rtld.c ++++ b/elf/rtld.c +@@ -449,6 +449,8 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) + { + ElfW(Addr) start_addr; + ++ __rtld_malloc_init_stubs (); ++ + /* If it hasn't happen yet record the startup time. */ + rtld_timer_start (&start_time); + #if !defined DONT_USE_BOOTSTRAP_MAP +@@ -574,7 +576,6 @@ _dl_start (void *arg) + function, that way the compiler cannot put accesses to the GOT + before ELF_DYNAMIC_RELOCATE. */ + +- __rtld_malloc_init_stubs (); + + { + #ifdef DONT_USE_BOOTSTRAP_MAP +-- +2.33.0 + + diff --git a/backport-elf-avoid-jumping-over-a-needed-declaration.patch b/backport-elf-avoid-jumping-over-a-needed-declaration.patch new file mode 100644 index 0000000..dba8273 --- /dev/null +++ b/backport-elf-avoid-jumping-over-a-needed-declaration.patch @@ -0,0 +1,44 @@ +From 8e572067976ea700e5ef750458c42c47328fe459 Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Wed, 6 Nov 2024 21:40:35 -0500 +Subject: [PATCH] elf: avoid jumping over a needed declaration + +Reference:https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8e572067976ea700e5ef750458c42c47328fe459 +Conflict:NA + +The declaration of found_other_class could be jumped +over via the goto just above it, but the code jumped +to uses found_other_class. Move the declaration +up a bit to ensure it's properly declared and initialized. +--- + elf/dl-load.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/elf/dl-load.c b/elf/dl-load.c +index ac8e217a7f..335b34c56d 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -1931,6 +1931,9 @@ _dl_map_object (struct link_map *loader, const char *name, + : "\nfile=%s [%lu]; dynamically loaded by %s [%lu]\n", + name, nsid, DSO_FILENAME (loader->l_name), loader->l_ns); + ++ /* Will be true if we found a DSO which is of the other ELF class. */ ++ bool found_other_class = false; ++ + #ifdef SHARED + /* Give the auditing libraries a chance to change the name before we + try anything. */ +@@ -1948,9 +1951,6 @@ _dl_map_object (struct link_map *loader, const char *name, + } + #endif + +- /* Will be true if we found a DSO which is of the other ELF class. */ +- bool found_other_class = false; +- + if (strchr (name, '/') == NULL) + { + /* Search for NAME in several places. */ +-- +2.33.0 + + diff --git a/glibc.spec b/glibc.spec index bd9c36e..d65b427 100644 --- a/glibc.spec +++ b/glibc.spec @@ -71,7 +71,7 @@ ############################################################################## Name: glibc Version: 2.34 -Release: 161 +Release: 162 Summary: The GNU libc libraries License: %{all_license} URL: http://www.gnu.org/software/glibc/ @@ -311,6 +311,8 @@ Patch219: backport-elf-execve-statically-linked-programs-instead-of-cra.patch Patch220: backport-elf-Use-errcode-instead-of-unset-errno-in-rtld_chain.patch Patch221: backport-resolv-track-single-request-fallback-flags.patch Patch222: backport-resolv-allow-short-error-response-to-match-any-query.patch +Patch223: backport-elf-avoid-jumping-over-a-needed-declaration.patch +Patch224: backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch @@ -1541,6 +1543,13 @@ fi %endif %changelog +* Fri Nov 29 2024 shixuantong - 2.34-162 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:elf: avoid jumping over a needed declaration + elf: Move __rtld_malloc_init_stubs call into _dl_start_final + * Thu Nov 21 2024 Qingqing Li - 2.34-161 - try to enable system thp ability when LD_HUGEPAGE_LIB=2 -- Gitee