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)
This commit is contained in:
shixuantong 2024-11-29 11:01:00 +08:00 committed by openeuler-sync-bot
parent 0180751415
commit 0b68e30fad
3 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 2abfa1907218c5ec9d52bb81bee3f1af652f67c7 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
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

View File

@ -0,0 +1,44 @@
From 8e572067976ea700e5ef750458c42c47328fe459 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
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

View File

@ -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 <shixuantong1@huawei.com> - 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 <liqingqing3@huawei.com> - 2.34-161
- try to enable system thp ability when LD_HUGEPAGE_LIB=2