elf replace nsid with args.nsid [BZ #27609]

This commit is contained in:
liqingqing_1229 2021-12-27 09:27:05 +08:00
parent 9f6df5c5cb
commit 980c1e01c2
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 1e1ecea62e899acb58c3fdf3b320a0833ddd0dff Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 30 Sep 2021 10:29:17 -0700
Subject: [PATCH] elf: Replace nsid with args.nsid [BZ #27609]
commit ec935dea6332cb22f9881cd1162bad156173f4b0
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Apr 24 22:31:15 2020 +0200
elf: Implement __libc_early_init
has
@@ -856,6 +876,11 @@ no more namespaces available for dlmopen()"));
/* See if an error occurred during loading. */
if (__glibc_unlikely (exception.errstring != NULL))
{
+ /* Avoid keeping around a dangling reference to the libc.so link
+ map in case it has been cached in libc_map. */
+ if (!args.libc_already_loaded)
+ GL(dl_ns)[nsid].libc_map = NULL;
+
do_dlopen calls _dl_open with nsid == __LM_ID_CALLER (-2), which calls
dl_open_worker with args.nsid = nsid. dl_open_worker updates args.nsid
if it is __LM_ID_CALLER. After dl_open_worker returns, it is wrong to
use nsid.
Replace nsid with args.nsid after dl_open_worker returns. This fixes
BZ #27609.
---
elf/dl-open.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elf/dl-open.c b/elf/dl-open.c
index a25443f..5295e93 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -886,7 +886,7 @@ no more namespaces available for dlmopen()"));
/* Avoid keeping around a dangling reference to the libc.so link
map in case it has been cached in libc_map. */
if (!args.libc_already_loaded)
- GL(dl_ns)[nsid].libc_map = NULL;
+ GL(dl_ns)[args.nsid].libc_map = NULL;
/* Remove the object from memory. It may be in an inconsistent
state if relocation failed, for example. */
--
1.8.3.1

View File

@ -65,7 +65,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 37 Release: 38
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -145,6 +145,7 @@ Patch58: nptl-Add-one-more-barrier-to-nptl-tst-create1.patch
Patch59: io-Fix-ftw-internal-realloc-buffer-BZ-28126.patch Patch59: io-Fix-ftw-internal-realloc-buffer-BZ-28126.patch
Patch60: Do-not-define-tgmath.h-fmaxmag-fminmag-macros-for-C2.patch Patch60: Do-not-define-tgmath.h-fmaxmag-fminmag-macros-for-C2.patch
Patch61: ld.so-Don-t-fill-the-DT_DEBUG-entry-in-ld.so-BZ-2812.patch Patch61: ld.so-Don-t-fill-the-DT_DEBUG-entry-in-ld.so-BZ-2812.patch
Patch62: elf-Replace-nsid-with-args.nsid-BZ-27609.patch
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.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 Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1341,6 +1342,9 @@ fi
%endif %endif
%changelog %changelog
* Mon Dec 27 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-38
- elf: replace nsid with args.nsid [BZ #27609]
* Sat Dec 25 2021 liusirui <liusirui@huawei.com> - 2.34-37 * Sat Dec 25 2021 liusirui <liusirui@huawei.com> - 2.34-37
- ld.so: Don't fill the DT_DEBUG entry in ld.so [BZ #28129] - ld.so: Don't fill the DT_DEBUG entry in ld.so [BZ #28129]