Sync with upstream branch release/2.34/master
Upstream commit: 71326f1f2fd09dafb9c34404765fb88129e94237 - nptl: Fix pthread_cancel cancelhandling atomic operations - mips: Fix mips64n32 64 bit time_t stat support (BZ#29069) - hurd: Fix arbitrary error code - nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029) - S390: Add new s390 platform z16. - NEWS: Update fixed bug list for LD_AUDIT backports. - hppa: Fix bind-now audit (BZ #28857) - elf: Replace tst-audit24bmod2.so with tst-audit24bmod2 - Fix elf/tst-audit25a with default bind now toolchains - elf: Fix runtime linker auditing on aarch64 (BZ #26643) - elf: Issue la_symbind for bind-now (BZ #23734) - elf: Fix initial-exec TLS access on audit modules (BZ #28096) - elf: Add la_activity during application exit - elf: Do not fail for failed dlmopen on audit modules (BZ #28061) - elf: Issue audit la_objopen for vDSO - elf: Add audit tests for modules with TLSDESC - elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533) - elf: Add _dl_audit_pltexit - elf: Add _dl_audit_pltenter - elf: Add _dl_audit_preinit - elf: Add _dl_audit_symbind_alt and _dl_audit_symbind - elf: Add _dl_audit_objclose - elf: Add _dl_audit_objsearch - elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid - elf: Add _dl_audit_objopen - elf: Move la_activity (LA_ACT_ADD) after _dl_add_to_namespace_list() (BZ #28062) - elf: Move LAV_CURRENT to link_lavcurrent.h - elf: Fix elf_get_dynamic_info() for bootstrap - elf: Fix dynamic-link.h usage on rtld.c - elf: Fix elf_get_dynamic_info definition - elf: Avoid nested functions in the loader [BZ #27220] - powerpc: Delete unneeded ELF_MACHINE_BEFORE_RTLD_RELOC - hppa: Use END instead of PSEUDO_END in swapcontext.S - hppa: Implement swapcontext in assembler (bug 28960) Reviewed-by: Florian Weimer <fweimer at redhat.com>
This commit is contained in:
parent
abcc04a5bf
commit
a8db42ba53
178
glibc-upstream-2.34-133.patch
Normal file
178
glibc-upstream-2.34-133.patch
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
commit 738ee53f0ce5e39b9b7a6777f5d3057afbaac498
|
||||||
|
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||||
|
Date: Tue Mar 15 23:12:37 2022 +0000
|
||||||
|
|
||||||
|
hppa: Implement swapcontext in assembler (bug 28960)
|
||||||
|
|
||||||
|
When swapcontext.c is compiled without -g, the following error occurs:
|
||||||
|
Error: CFI instruction used without previous .cfi_startproc
|
||||||
|
|
||||||
|
Fix by converting swapcontext routine to assembler.
|
||||||
|
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.S b/sysdeps/unix/sysv/linux/hppa/swapcontext.S
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..94b164dc6375563e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/sysdeps/unix/sysv/linux/hppa/swapcontext.S
|
||||||
|
@@ -0,0 +1,72 @@
|
||||||
|
+/* Swap to new context.
|
||||||
|
+ Copyright (C) 2008-2022 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 <sysdep.h>
|
||||||
|
+#include "ucontext_i.h"
|
||||||
|
+
|
||||||
|
+ .text
|
||||||
|
+ENTRY(__swapcontext)
|
||||||
|
+
|
||||||
|
+ /* Copy rp to ret0 (r28). */
|
||||||
|
+ copy %rp,%ret0
|
||||||
|
+
|
||||||
|
+ /* Create a frame. */
|
||||||
|
+ ldo 64(%sp),%sp
|
||||||
|
+ .cfi_def_cfa_offset -64
|
||||||
|
+
|
||||||
|
+ /* Save the current machine context to oucp. */
|
||||||
|
+ bl __getcontext,%rp
|
||||||
|
+
|
||||||
|
+ /* Copy oucp to register ret1 (r29). __getcontext saves and
|
||||||
|
+ restores it on a normal return. It is restored from oR29
|
||||||
|
+ on reactivation. */
|
||||||
|
+ copy %r26,%ret1
|
||||||
|
+
|
||||||
|
+ /* Pop frame. */
|
||||||
|
+ ldo -64(%sp),%sp
|
||||||
|
+ .cfi_def_cfa_offset 0
|
||||||
|
+
|
||||||
|
+ /* Load return pointer from oR28. */
|
||||||
|
+ ldw oR28(%ret1),%rp
|
||||||
|
+
|
||||||
|
+ /* Return if error. */
|
||||||
|
+ or,= %r0,%ret0,%r0
|
||||||
|
+ bv,n %r0(%rp)
|
||||||
|
+
|
||||||
|
+ /* Load sc_sar flag. */
|
||||||
|
+ ldb oSAR(%ret1),%r20
|
||||||
|
+
|
||||||
|
+ /* Return if oucp context has been reactivated. */
|
||||||
|
+ or,= %r0,%r20,%r0
|
||||||
|
+ bv,n %r0(%rp)
|
||||||
|
+
|
||||||
|
+ /* Mark sc_sar flag. */
|
||||||
|
+ ldi 1,%r20
|
||||||
|
+ stb %r20,oSAR(%ret1)
|
||||||
|
+
|
||||||
|
+ /* Activate the machine context in ucp. */
|
||||||
|
+ bl __setcontext,%rp
|
||||||
|
+ ldw oR25(%ret1),%r26
|
||||||
|
+
|
||||||
|
+ /* Load return pointer. */
|
||||||
|
+ ldw oR28(%ret1),%rp
|
||||||
|
+ bv,n %r0(%rp)
|
||||||
|
+
|
||||||
|
+PSEUDO_END(__swapcontext)
|
||||||
|
+
|
||||||
|
+weak_alias (__swapcontext, swapcontext)
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.c b/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||||
|
deleted file mode 100644
|
||||||
|
index 1664f68c7b9982e8..0000000000000000
|
||||||
|
--- a/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,83 +0,0 @@
|
||||||
|
-/* Swap to new context.
|
||||||
|
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
|
||||||
|
- This file is part of the GNU C Library.
|
||||||
|
- Contributed by Helge Deller <deller@gmx.de>, 2008.
|
||||||
|
-
|
||||||
|
- 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 <ucontext.h>
|
||||||
|
-#include "ucontext_i.h"
|
||||||
|
-
|
||||||
|
-extern int __getcontext (ucontext_t *ucp);
|
||||||
|
-extern int __setcontext (const ucontext_t *ucp);
|
||||||
|
-
|
||||||
|
-int
|
||||||
|
-__swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||||
|
-{
|
||||||
|
- /* Save rp for debugger. */
|
||||||
|
- asm ("stw %rp,-20(%sp)");
|
||||||
|
- asm (".cfi_offset 2, -20");
|
||||||
|
-
|
||||||
|
- /* Copy rp to ret0 (r28). */
|
||||||
|
- asm ("copy %rp,%ret0");
|
||||||
|
-
|
||||||
|
- /* Create a frame. */
|
||||||
|
- asm ("ldo 64(%sp),%sp");
|
||||||
|
- asm (".cfi_def_cfa_offset -64");
|
||||||
|
-
|
||||||
|
- /* Save the current machine context to oucp. */
|
||||||
|
- asm ("bl __getcontext,%rp");
|
||||||
|
-
|
||||||
|
- /* Copy oucp to register ret1 (r29). __getcontext saves and restores it
|
||||||
|
- on a normal return. It is restored from oR29 on reactivation. */
|
||||||
|
- asm ("copy %r26,%ret1");
|
||||||
|
-
|
||||||
|
- /* Pop frame. */
|
||||||
|
- asm ("ldo -64(%sp),%sp");
|
||||||
|
- asm (".cfi_def_cfa_offset 0");
|
||||||
|
-
|
||||||
|
- /* Load return pointer from oR28. */
|
||||||
|
- asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28));
|
||||||
|
-
|
||||||
|
- /* Return if error. */
|
||||||
|
- asm ("or,= %r0,%ret0,%r0");
|
||||||
|
- asm ("bv,n %r0(%rp)");
|
||||||
|
-
|
||||||
|
- /* Load sc_sar flag. */
|
||||||
|
- asm ("ldb %0(%%ret1),%%r20" : : "i" (oSAR));
|
||||||
|
-
|
||||||
|
- /* Return if oucp context has been reactivated. */
|
||||||
|
- asm ("or,= %r0,%r20,%r0");
|
||||||
|
- asm ("bv,n %r0(%rp)");
|
||||||
|
-
|
||||||
|
- /* Mark sc_sar flag. */
|
||||||
|
- asm ("1: ldi 1,%r20");
|
||||||
|
- asm ("stb %%r20,%0(%%ret1)" : : "i" (oSAR));
|
||||||
|
-
|
||||||
|
- /* Activate the machine context in ucp. */
|
||||||
|
- asm ("bl __setcontext,%rp");
|
||||||
|
- asm ("ldw %0(%%ret1),%%r26" : : "i" (oR25));
|
||||||
|
-
|
||||||
|
- /* Load return pointer. */
|
||||||
|
- asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28));
|
||||||
|
-
|
||||||
|
- /* A successful call to setcontext does not return. */
|
||||||
|
- asm ("bv,n %r0(%rp)");
|
||||||
|
-
|
||||||
|
- /* Make gcc happy. */
|
||||||
|
- return 0;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-weak_alias (__swapcontext, swapcontext)
|
20
glibc-upstream-2.34-134.patch
Normal file
20
glibc-upstream-2.34-134.patch
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
commit d53b9cc391c72a1011ea8fe7a9f70dc5060a0db2
|
||||||
|
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||||
|
Date: Tue Mar 15 23:04:39 2022 +0000
|
||||||
|
|
||||||
|
hppa: Use END instead of PSEUDO_END in swapcontext.S
|
||||||
|
|
||||||
|
(cherry picked from commit 7a5c440102d4ec7fafd9bbd98eca9bd90ecaaafd)
|
||||||
|
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.S b/sysdeps/unix/sysv/linux/hppa/swapcontext.S
|
||||||
|
index 94b164dc6375563e..fbc22586d1195a0d 100644
|
||||||
|
--- a/sysdeps/unix/sysv/linux/hppa/swapcontext.S
|
||||||
|
+++ b/sysdeps/unix/sysv/linux/hppa/swapcontext.S
|
||||||
|
@@ -67,6 +67,6 @@ ENTRY(__swapcontext)
|
||||||
|
ldw oR28(%ret1),%rp
|
||||||
|
bv,n %r0(%rp)
|
||||||
|
|
||||||
|
-PSEUDO_END(__swapcontext)
|
||||||
|
+END(__swapcontext)
|
||||||
|
|
||||||
|
weak_alias (__swapcontext, swapcontext)
|
35
glibc-upstream-2.34-135.patch
Normal file
35
glibc-upstream-2.34-135.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
commit 4b5b8a1cdf39bed02b8b973717796eccde455ed6
|
||||||
|
Author: Fangrui Song <maskray@google.com>
|
||||||
|
Date: Mon Sep 27 10:12:50 2021 -0700
|
||||||
|
|
||||||
|
powerpc: Delete unneeded ELF_MACHINE_BEFORE_RTLD_RELOC
|
||||||
|
|
||||||
|
Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
|
||||||
|
(cherry picked from commit 8e2557a2b85b2eb0ed50a9016a4ffc6b859b97e6)
|
||||||
|
|
||||||
|
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
|
||||||
|
index ced3a7b659cfcff1..b93cf486b6cda5fd 100644
|
||||||
|
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
|
||||||
|
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
|
||||||
|
@@ -109,8 +109,6 @@ elf_machine_load_address (void)
|
||||||
|
return runtime_dynamic - elf_machine_dynamic ();
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
|
||||||
|
-
|
||||||
|
/* The PLT uses Elf32_Rela relocs. */
|
||||||
|
#define elf_machine_relplt elf_machine_rela
|
||||||
|
|
||||||
|
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
|
||||||
|
index b90f407119efd431..b3f3352bcf5a52b0 100644
|
||||||
|
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
|
||||||
|
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
|
||||||
|
@@ -116,8 +116,6 @@ elf_machine_dynamic (void)
|
||||||
|
return runtime_dynamic - elf_machine_load_address() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
|
||||||
|
-
|
||||||
|
/* The PLT uses Elf64_Rela relocs. */
|
||||||
|
#define elf_machine_relplt elf_machine_rela
|
||||||
|
|
2020
glibc-upstream-2.34-136.patch
Normal file
2020
glibc-upstream-2.34-136.patch
Normal file
File diff suppressed because it is too large
Load Diff
241
glibc-upstream-2.34-137.patch
Normal file
241
glibc-upstream-2.34-137.patch
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
commit c6df39a0bd2aafd2a4280a0000ef201f30273bee
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Mon Oct 11 16:01:49 2021 -0300
|
||||||
|
|
||||||
|
elf: Fix elf_get_dynamic_info definition
|
||||||
|
|
||||||
|
Before to 490e6c62aa31a8a ('elf: Avoid nested functions in the loader
|
||||||
|
[BZ #27220]'), elf_get_dynamic_info() was defined twice on rtld.c: on
|
||||||
|
the first dynamic-link.h include and later within _dl_start(). The
|
||||||
|
former definition did not define DONT_USE_BOOTSTRAP_MAP and it is used
|
||||||
|
on setup_vdso() (since it is a global definition), while the former does
|
||||||
|
define DONT_USE_BOOTSTRAP_MAP and it is used on loader self-relocation.
|
||||||
|
|
||||||
|
With the commit change, the function is now included and defined once
|
||||||
|
instead of defined as a nested function. So rtld.c defines without
|
||||||
|
defining RTLD_BOOTSTRAP and it brokes at least powerpc32.
|
||||||
|
|
||||||
|
This patch fixes by moving the get-dynamic-info.h include out of
|
||||||
|
dynamic-link.h, which then the caller can corirectly set the expected
|
||||||
|
semantic by defining STATIC_PIE_BOOTSTRAP, RTLD_BOOTSTRAP, and/or
|
||||||
|
RESOLVE_MAP.
|
||||||
|
|
||||||
|
It also required to enable some asserts only for the loader bootstrap
|
||||||
|
to avoid issues when called from setup_vdso().
|
||||||
|
|
||||||
|
As a side note, this is another issues with nested functions: it is
|
||||||
|
not clear from pre-processed output (-E -dD) how the function will
|
||||||
|
be build and its semantic (since nested function will be local and
|
||||||
|
extra C defines may change it).
|
||||||
|
|
||||||
|
I checked on x86_64-linux-gnu (w/o --enable-static-pie),
|
||||||
|
i686-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu-power4,
|
||||||
|
aarch64-linux-gnu, arm-linux-gnu, sparc64-linux-gnu, and
|
||||||
|
s390x-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Fangrui Song <maskray@google.com>
|
||||||
|
(cherry picked from commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/rtld.c
|
||||||
|
|
||||||
|
diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c
|
||||||
|
index 5c8e51d19ae095d6..d54356dee3f86ae0 100644
|
||||||
|
--- a/elf/dl-conflict.c
|
||||||
|
+++ b/elf/dl-conflict.c
|
||||||
|
@@ -17,6 +17,7 @@
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <libintl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index 0976977fbdf21902..eea06629a978aaf3 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -58,6 +58,7 @@ struct filebuf
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "dynamic-link.h"
|
||||||
|
+#include "get-dynamic-info.h"
|
||||||
|
#include <abi-tag.h>
|
||||||
|
#include <stackinfo.h>
|
||||||
|
#include <sysdep.h>
|
||||||
|
@@ -1295,7 +1296,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
|
||||||
|
if (l->l_ld != 0)
|
||||||
|
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||||
|
|
||||||
|
- elf_get_dynamic_info (l);
|
||||||
|
+ elf_get_dynamic_info (l, false);
|
||||||
|
|
||||||
|
/* Make sure we are not dlopen'ing an object that has the
|
||||||
|
DF_1_NOOPEN flag set, or a PIE object. */
|
||||||
|
diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c
|
||||||
|
index a52ba8aeb8b573cb..f323b4dd0d5ba279 100644
|
||||||
|
--- a/elf/dl-reloc-static-pie.c
|
||||||
|
+++ b/elf/dl-reloc-static-pie.c
|
||||||
|
@@ -28,6 +28,7 @@
|
||||||
|
#define STATIC_PIE_BOOTSTRAP
|
||||||
|
#define RESOLVE_MAP(map, scope, sym, version, flags) map
|
||||||
|
#include "dynamic-link.h"
|
||||||
|
+#include "get-dynamic-info.h"
|
||||||
|
|
||||||
|
/* Relocate static executable with PIE. */
|
||||||
|
|
||||||
|
@@ -51,7 +52,7 @@ _dl_relocate_static_pie (void)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
- elf_get_dynamic_info (main_map);
|
||||||
|
+ elf_get_dynamic_info (main_map, false);
|
||||||
|
|
||||||
|
# ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
|
||||||
|
ELF_MACHINE_BEFORE_RTLD_RELOC (main_map, main_map->l_info);
|
||||||
|
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
|
||||||
|
index 9d0d941000f6114f..61c260ddb81b586c 100644
|
||||||
|
--- a/elf/dl-runtime.c
|
||||||
|
+++ b/elf/dl-runtime.c
|
||||||
|
@@ -19,6 +19,7 @@
|
||||||
|
#define IN_DL_RUNTIME 1 /* This can be tested in dl-machine.h. */
|
||||||
|
|
||||||
|
#include <alloca.h>
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
|
||||||
|
index 7cc30211649d3820..21cdfc88bbfb89ea 100644
|
||||||
|
--- a/elf/dynamic-link.h
|
||||||
|
+++ b/elf/dynamic-link.h
|
||||||
|
@@ -93,7 +93,6 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
|
||||||
|
|
||||||
|
#include <dl-machine.h>
|
||||||
|
|
||||||
|
-#include "get-dynamic-info.h"
|
||||||
|
|
||||||
|
#ifdef RESOLVE_MAP
|
||||||
|
|
||||||
|
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
|
||||||
|
index 15c316b38c05a90c..d169099fbc9897cf 100644
|
||||||
|
--- a/elf/get-dynamic-info.h
|
||||||
|
+++ b/elf/get-dynamic-info.h
|
||||||
|
@@ -25,7 +25,7 @@
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
|
static inline void __attribute__ ((unused, always_inline))
|
||||||
|
-elf_get_dynamic_info (struct link_map *l)
|
||||||
|
+elf_get_dynamic_info (struct link_map *l, bool check)
|
||||||
|
{
|
||||||
|
#if __ELF_NATIVE_CLASS == 32
|
||||||
|
typedef Elf32_Word d_tag_utype;
|
||||||
|
@@ -112,16 +112,19 @@ elf_get_dynamic_info (struct link_map *l)
|
||||||
|
assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
|
||||||
|
#endif
|
||||||
|
#ifdef RTLD_BOOTSTRAP
|
||||||
|
- /* Only the bind now flags are allowed. */
|
||||||
|
- assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
|
||||||
|
- || (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
|
||||||
|
- /* Flags must not be set for ld.so. */
|
||||||
|
- assert (info[DT_FLAGS] == NULL
|
||||||
|
- || (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
|
||||||
|
-#endif
|
||||||
|
-#if defined RTLD_BOOTSTRAP || defined STATIC_PIE_BOOTSTRAP
|
||||||
|
- assert (info[DT_RUNPATH] == NULL);
|
||||||
|
- assert (info[DT_RPATH] == NULL);
|
||||||
|
+ if (check)
|
||||||
|
+ {
|
||||||
|
+ /* Only the bind now flags are allowed. */
|
||||||
|
+ assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
|
||||||
|
+ || (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
|
||||||
|
+ /* Flags must not be set for ld.so. */
|
||||||
|
+ assert (info[DT_FLAGS] == NULL
|
||||||
|
+ || (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
|
||||||
|
+# ifdef STATIC_PIE_BOOTSTRAP
|
||||||
|
+ assert (info[DT_RUNPATH] == NULL);
|
||||||
|
+ assert (info[DT_RPATH] == NULL);
|
||||||
|
+# endif
|
||||||
|
+ }
|
||||||
|
#else
|
||||||
|
if (info[DT_FLAGS] != NULL)
|
||||||
|
{
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index ee45657aeac14f3c..352d596dedb42e79 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -514,6 +514,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
|
||||||
|
is trivial: always the map of ld.so itself. */
|
||||||
|
#define RTLD_BOOTSTRAP
|
||||||
|
#define RESOLVE_MAP(map, scope, sym, version, flags) map
|
||||||
|
+#include "get-dynamic-info.h"
|
||||||
|
#include "dynamic-link.h"
|
||||||
|
|
||||||
|
static ElfW(Addr) __attribute_used__
|
||||||
|
@@ -549,7 +550,7 @@ _dl_start (void *arg)
|
||||||
|
/* Read our own dynamic section and fill in the info array. */
|
||||||
|
bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic ();
|
||||||
|
bootstrap_map.l_ld_readonly = DL_RO_DYN_SECTION;
|
||||||
|
- elf_get_dynamic_info (&bootstrap_map);
|
||||||
|
+ elf_get_dynamic_info (&bootstrap_map, true);
|
||||||
|
|
||||||
|
#if NO_TLS_OFFSET != 0
|
||||||
|
bootstrap_map.l_tls_offset = NO_TLS_OFFSET;
|
||||||
|
@@ -1653,7 +1654,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
if (! rtld_is_main)
|
||||||
|
{
|
||||||
|
/* Extract the contents of the dynamic section for easy access. */
|
||||||
|
- elf_get_dynamic_info (main_map);
|
||||||
|
+ elf_get_dynamic_info (main_map, false);
|
||||||
|
|
||||||
|
/* If the main map is libc.so, update the base namespace to
|
||||||
|
refer to this map. If libc.so is loaded later, this happens
|
||||||
|
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
|
||||||
|
index f44748bc9858e5fd..6fdffafcca5e9916 100644
|
||||||
|
--- a/elf/setup-vdso.h
|
||||||
|
+++ b/elf/setup-vdso.h
|
||||||
|
@@ -64,7 +64,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
|
||||||
|
l->l_map_end += l->l_addr;
|
||||||
|
l->l_text_end += l->l_addr;
|
||||||
|
l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||||
|
- elf_get_dynamic_info (l);
|
||||||
|
+ elf_get_dynamic_info (l, false);
|
||||||
|
_dl_setup_hash (l);
|
||||||
|
l->l_relocated = 1;
|
||||||
|
|
||||||
|
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
|
||||||
|
index 7e6761bbe87540d5..86f866ca7c17bd9b 100644
|
||||||
|
--- a/sysdeps/arm/dl-machine.h
|
||||||
|
+++ b/sysdeps/arm/dl-machine.h
|
||||||
|
@@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
#define ELF_MACHINE_NAME "ARM"
|
||||||
|
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <tls.h>
|
||||||
|
#include <dl-tlsdesc.h>
|
||||||
|
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
|
||||||
|
index 78ce890c0ff333ca..fa902612ca8557f9 100644
|
||||||
|
--- a/sysdeps/i386/dl-machine.h
|
||||||
|
+++ b/sysdeps/i386/dl-machine.h
|
||||||
|
@@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
#define ELF_MACHINE_NAME "i386"
|
||||||
|
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sysdep.h>
|
||||||
|
#include <tls.h>
|
||||||
|
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
|
||||||
|
index d3fcbb37bf1f4f7c..90c77cfea1de8d63 100644
|
||||||
|
--- a/sysdeps/x86_64/dl-machine.h
|
||||||
|
+++ b/sysdeps/x86_64/dl-machine.h
|
||||||
|
@@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
#define ELF_MACHINE_NAME "x86_64"
|
||||||
|
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sysdep.h>
|
||||||
|
#include <tls.h>
|
1115
glibc-upstream-2.34-138.patch
Normal file
1115
glibc-upstream-2.34-138.patch
Normal file
File diff suppressed because it is too large
Load Diff
221
glibc-upstream-2.34-139.patch
Normal file
221
glibc-upstream-2.34-139.patch
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
commit f6a54a304223666ea4af73260c99c830d7726eca
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Fri Oct 15 14:35:31 2021 -0300
|
||||||
|
|
||||||
|
elf: Fix elf_get_dynamic_info() for bootstrap
|
||||||
|
|
||||||
|
THe d6d89608ac8c broke powerpc for --enable-bind-now because it turned
|
||||||
|
out that different than patch assumption rtld elf_get_dynamic_info()
|
||||||
|
does require to handle RTLD_BOOTSTRAP to avoid DT_FLAGS and
|
||||||
|
DT_RUNPATH (more specially the GLRO usage which is not reallocate
|
||||||
|
yet).
|
||||||
|
|
||||||
|
This patch fixes by passing two arguments to elf_get_dynamic_info()
|
||||||
|
to inform that by rtld (bootstrap) or static pie initialization
|
||||||
|
(static_pie_bootstrap). I think using explicit argument is way more
|
||||||
|
clear and burried C preprocessor, and compiler should remove the
|
||||||
|
dead code.
|
||||||
|
|
||||||
|
I checked on x86_64 and i686 with default options, --enable-bind-now,
|
||||||
|
and --enable-bind-now and --enable--static-pie. I also check on
|
||||||
|
aarch64, armhf, powerpc64, and powerpc with default and
|
||||||
|
--enable-bind-now.
|
||||||
|
|
||||||
|
(cherry picked from commit 5118dcac68c4eadfd6304bb33adde63d062dc07f)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/rtld.c - Manual merge.
|
||||||
|
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index fb3da5aa565908a6..a920b12a906a9dec 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -1296,7 +1296,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
|
||||||
|
if (l->l_ld != 0)
|
||||||
|
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||||
|
|
||||||
|
- elf_get_dynamic_info (l);
|
||||||
|
+ elf_get_dynamic_info (l, false, false);
|
||||||
|
|
||||||
|
/* Make sure we are not dlopen'ing an object that has the
|
||||||
|
DF_1_NOOPEN flag set, or a PIE object. */
|
||||||
|
diff --git a/elf/dl-reloc-static-pie.c b/elf/dl-reloc-static-pie.c
|
||||||
|
index ababafcf98f9945d..757205affe65d9e1 100644
|
||||||
|
--- a/elf/dl-reloc-static-pie.c
|
||||||
|
+++ b/elf/dl-reloc-static-pie.c
|
||||||
|
@@ -25,7 +25,6 @@
|
||||||
|
|
||||||
|
#include <dl-machine.h>
|
||||||
|
|
||||||
|
-#define STATIC_PIE_BOOTSTRAP
|
||||||
|
#define RESOLVE_MAP(map, scope, sym, version, flags) map
|
||||||
|
#include "dynamic-link.h"
|
||||||
|
#include "get-dynamic-info.h"
|
||||||
|
@@ -52,7 +51,7 @@ _dl_relocate_static_pie (void)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
- elf_get_dynamic_info (main_map);
|
||||||
|
+ elf_get_dynamic_info (main_map, false, true);
|
||||||
|
|
||||||
|
# ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
|
||||||
|
ELF_MACHINE_BEFORE_RTLD_RELOC (main_map, main_map->l_info);
|
||||||
|
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
|
||||||
|
index 1ac0663d1ff5de24..f63e07dc6d2cd5e6 100644
|
||||||
|
--- a/elf/get-dynamic-info.h
|
||||||
|
+++ b/elf/get-dynamic-info.h
|
||||||
|
@@ -26,7 +26,8 @@
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
|
static inline void __attribute__ ((unused, always_inline))
|
||||||
|
-elf_get_dynamic_info (struct link_map *l)
|
||||||
|
+elf_get_dynamic_info (struct link_map *l, bool bootstrap,
|
||||||
|
+ bool static_pie_bootstrap)
|
||||||
|
{
|
||||||
|
#if __ELF_NATIVE_CLASS == 32
|
||||||
|
typedef Elf32_Word d_tag_utype;
|
||||||
|
@@ -35,7 +36,7 @@ elf_get_dynamic_info (struct link_map *l)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STATIC_PIE_BOOTSTRAP
|
||||||
|
- if (l->l_ld == NULL)
|
||||||
|
+ if (!bootstrap && l->l_ld == NULL)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -112,47 +113,63 @@ elf_get_dynamic_info (struct link_map *l)
|
||||||
|
if (info[DT_REL] != NULL)
|
||||||
|
assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
|
||||||
|
#endif
|
||||||
|
-#ifdef STATIC_PIE_BOOTSTRAP
|
||||||
|
- assert (info[DT_RUNPATH] == NULL);
|
||||||
|
- assert (info[DT_RPATH] == NULL);
|
||||||
|
-#endif
|
||||||
|
- if (info[DT_FLAGS] != NULL)
|
||||||
|
+ if (bootstrap || static_pie_bootstrap)
|
||||||
|
{
|
||||||
|
- /* Flags are used. Translate to the old form where available.
|
||||||
|
- Since these l_info entries are only tested for NULL pointers it
|
||||||
|
- is ok if they point to the DT_FLAGS entry. */
|
||||||
|
- l->l_flags = info[DT_FLAGS]->d_un.d_val;
|
||||||
|
-
|
||||||
|
- if (l->l_flags & DF_SYMBOLIC)
|
||||||
|
- info[DT_SYMBOLIC] = info[DT_FLAGS];
|
||||||
|
- if (l->l_flags & DF_TEXTREL)
|
||||||
|
- info[DT_TEXTREL] = info[DT_FLAGS];
|
||||||
|
- if (l->l_flags & DF_BIND_NOW)
|
||||||
|
- info[DT_BIND_NOW] = info[DT_FLAGS];
|
||||||
|
+ assert (info[DT_RUNPATH] == NULL);
|
||||||
|
+ assert (info[DT_RPATH] == NULL);
|
||||||
|
}
|
||||||
|
- if (info[VERSYMIDX (DT_FLAGS_1)] != NULL)
|
||||||
|
+ if (bootstrap)
|
||||||
|
{
|
||||||
|
- l->l_flags_1 = info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val;
|
||||||
|
- if (l->l_flags_1 & DF_1_NODELETE)
|
||||||
|
- l->l_nodelete_pending = true;
|
||||||
|
-
|
||||||
|
- /* Only DT_1_SUPPORTED_MASK bits are supported, and we would like
|
||||||
|
- to assert this, but we can't. Users have been setting
|
||||||
|
- unsupported DF_1_* flags for a long time and glibc has ignored
|
||||||
|
- them. Therefore to avoid breaking existing applications the
|
||||||
|
- best we can do is add a warning during debugging with the
|
||||||
|
- intent of notifying the user of the problem. */
|
||||||
|
- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)
|
||||||
|
- && l->l_flags_1 & ~DT_1_SUPPORTED_MASK)
|
||||||
|
- _dl_debug_printf ("\nWARNING: Unsupported flag value(s) of 0x%x in DT_FLAGS_1.\n",
|
||||||
|
- l->l_flags_1 & ~DT_1_SUPPORTED_MASK);
|
||||||
|
-
|
||||||
|
- if (l->l_flags_1 & DF_1_NOW)
|
||||||
|
- info[DT_BIND_NOW] = info[VERSYMIDX (DT_FLAGS_1)];
|
||||||
|
+ /* Only the bind now flags are allowed. */
|
||||||
|
+ assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
|
||||||
|
+ || (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
|
||||||
|
+ /* Flags must not be set for ld.so. */
|
||||||
|
+ assert (info[DT_FLAGS] == NULL
|
||||||
|
+ || (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
|
||||||
|
}
|
||||||
|
- if (info[DT_RUNPATH] != NULL)
|
||||||
|
- /* If both RUNPATH and RPATH are given, the latter is ignored. */
|
||||||
|
- info[DT_RPATH] = NULL;
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ if (info[DT_FLAGS] != NULL)
|
||||||
|
+ {
|
||||||
|
+ /* Flags are used. Translate to the old form where available.
|
||||||
|
+ Since these l_info entries are only tested for NULL pointers it
|
||||||
|
+ is ok if they point to the DT_FLAGS entry. */
|
||||||
|
+ l->l_flags = info[DT_FLAGS]->d_un.d_val;
|
||||||
|
+
|
||||||
|
+ if (l->l_flags & DF_SYMBOLIC)
|
||||||
|
+ info[DT_SYMBOLIC] = info[DT_FLAGS];
|
||||||
|
+ if (l->l_flags & DF_TEXTREL)
|
||||||
|
+ info[DT_TEXTREL] = info[DT_FLAGS];
|
||||||
|
+ if (l->l_flags & DF_BIND_NOW)
|
||||||
|
+ info[DT_BIND_NOW] = info[DT_FLAGS];
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (info[VERSYMIDX (DT_FLAGS_1)] != NULL)
|
||||||
|
+ {
|
||||||
|
+ l->l_flags_1 = info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val;
|
||||||
|
+ if (l->l_flags_1 & DF_1_NODELETE)
|
||||||
|
+ l->l_nodelete_pending = true;
|
||||||
|
+
|
||||||
|
+ /* Only DT_1_SUPPORTED_MASK bits are supported, and we would like
|
||||||
|
+ to assert this, but we can't. Users have been setting
|
||||||
|
+ unsupported DF_1_* flags for a long time and glibc has ignored
|
||||||
|
+ them. Therefore to avoid breaking existing applications the
|
||||||
|
+ best we can do is add a warning during debugging with the
|
||||||
|
+ intent of notifying the user of the problem. */
|
||||||
|
+ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)
|
||||||
|
+ && l->l_flags_1 & ~DT_1_SUPPORTED_MASK)
|
||||||
|
+ _dl_debug_printf ("\nWARNING: Unsupported flag value(s) of 0x%x "
|
||||||
|
+ "in DT_FLAGS_1.\n",
|
||||||
|
+ l->l_flags_1 & ~DT_1_SUPPORTED_MASK);
|
||||||
|
+
|
||||||
|
+ if (l->l_flags_1 & DF_1_NOW)
|
||||||
|
+ info[DT_BIND_NOW] = info[VERSYMIDX (DT_FLAGS_1)];
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (info[DT_RUNPATH] != NULL)
|
||||||
|
+ /* If both RUNPATH and RPATH are given, the latter is ignored. */
|
||||||
|
+ info[DT_RPATH] = NULL;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index 37d28d5a66d7b5d6..ad5ddb2a0ab94e7f 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -549,7 +549,7 @@ _dl_start (void *arg)
|
||||||
|
/* Read our own dynamic section and fill in the info array. */
|
||||||
|
bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic ();
|
||||||
|
bootstrap_map.l_ld_readonly = DL_RO_DYN_SECTION;
|
||||||
|
- elf_get_dynamic_info (&bootstrap_map);
|
||||||
|
+ elf_get_dynamic_info (&bootstrap_map, true, false);
|
||||||
|
|
||||||
|
#if NO_TLS_OFFSET != 0
|
||||||
|
bootstrap_map.l_tls_offset = NO_TLS_OFFSET;
|
||||||
|
@@ -1653,7 +1653,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
if (! rtld_is_main)
|
||||||
|
{
|
||||||
|
/* Extract the contents of the dynamic section for easy access. */
|
||||||
|
- elf_get_dynamic_info (main_map);
|
||||||
|
+ elf_get_dynamic_info (main_map, false, false);
|
||||||
|
|
||||||
|
/* If the main map is libc.so, update the base namespace to
|
||||||
|
refer to this map. If libc.so is loaded later, this happens
|
||||||
|
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
|
||||||
|
index f44748bc9858e5fd..3f20578046de76ed 100644
|
||||||
|
--- a/elf/setup-vdso.h
|
||||||
|
+++ b/elf/setup-vdso.h
|
||||||
|
@@ -64,7 +64,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
|
||||||
|
l->l_map_end += l->l_addr;
|
||||||
|
l->l_text_end += l->l_addr;
|
||||||
|
l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||||
|
- elf_get_dynamic_info (l);
|
||||||
|
+ elf_get_dynamic_info (l, false, false);
|
||||||
|
_dl_setup_hash (l);
|
||||||
|
l->l_relocated = 1;
|
||||||
|
|
69
glibc-upstream-2.34-140.patch
Normal file
69
glibc-upstream-2.34-140.patch
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
commit a31bbe3242266aaea423e5879f38aed69aea1d5e
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Thu Jul 29 11:13:57 2021 -0300
|
||||||
|
|
||||||
|
elf: Move LAV_CURRENT to link_lavcurrent.h
|
||||||
|
|
||||||
|
No functional change.
|
||||||
|
|
||||||
|
(cherry picked from commit 54816ae98d57930b7c945f17485714a5574bfe47)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/Makefile
|
||||||
|
|
||||||
|
diff --git a/bits/link_lavcurrent.h b/bits/link_lavcurrent.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..44fbea1e8060997f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/bits/link_lavcurrent.h
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+/* Data structure for communication from the run-time dynamic linker for
|
||||||
|
+ loaded ELF shared objects. LAV_CURRENT definition.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+#ifndef _LINK_H
|
||||||
|
+# error "Never include <bits/link_lavcurrent.h> directly; use <link.h> instead."
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+/* Version numbers for la_version handshake interface. */
|
||||||
|
+#define LAV_CURRENT 1
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index cd8725c76f4cfb48..7fa80946ff3aae42 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -24,6 +24,7 @@ include ../Makeconfig
|
||||||
|
headers = \
|
||||||
|
bits/elfclass.h \
|
||||||
|
bits/link.h \
|
||||||
|
+ bits/link_lavcurrent.h \
|
||||||
|
elf.h \
|
||||||
|
link.h \
|
||||||
|
# headers
|
||||||
|
diff --git a/elf/link.h b/elf/link.h
|
||||||
|
index ff3a85c847930b9b..21a351686b9bf7c8 100644
|
||||||
|
--- a/elf/link.h
|
||||||
|
+++ b/elf/link.h
|
||||||
|
@@ -96,7 +96,7 @@ struct link_map
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
|
||||||
|
/* Version numbers for la_version handshake interface. */
|
||||||
|
-#define LAV_CURRENT 1
|
||||||
|
+#include <bits/link_lavcurrent.h>
|
||||||
|
|
||||||
|
/* Activity types signaled through la_activity. */
|
||||||
|
enum
|
390
glibc-upstream-2.34-141.patch
Normal file
390
glibc-upstream-2.34-141.patch
Normal file
@ -0,0 +1,390 @@
|
|||||||
|
commit e25fe992132c460fecc1ab9fade185d5dd3f91ff
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Thu Nov 11 09:28:21 2021 -0300
|
||||||
|
|
||||||
|
elf: Move la_activity (LA_ACT_ADD) after _dl_add_to_namespace_list() (BZ #28062)
|
||||||
|
|
||||||
|
It ensures that the the namespace is guaranteed to not be empty.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit ed3ce71f5c64c5f07cbde0ef03554ea8950d8f2c)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/Makefile
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 7fa80946ff3aae42..bf6da98bdd15a18d 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -363,6 +363,7 @@ tests += \
|
||||||
|
tst-audit15 \
|
||||||
|
tst-audit16 \
|
||||||
|
tst-audit17 \
|
||||||
|
+ tst-audit18 \
|
||||||
|
tst-auditmany \
|
||||||
|
tst-auxobj \
|
||||||
|
tst-auxobj-dlopen \
|
||||||
|
@@ -623,6 +624,7 @@ modules-names = \
|
||||||
|
tst-audit12mod2 \
|
||||||
|
tst-audit12mod3 \
|
||||||
|
tst-audit13mod1 \
|
||||||
|
+ tst-audit18mod \
|
||||||
|
tst-auditlogmod-1 \
|
||||||
|
tst-auditlogmod-2 \
|
||||||
|
tst-auditlogmod-3 \
|
||||||
|
@@ -640,6 +642,7 @@ modules-names = \
|
||||||
|
tst-auditmod9b \
|
||||||
|
tst-auditmod11 \
|
||||||
|
tst-auditmod12 \
|
||||||
|
+ tst-auditmod18 \
|
||||||
|
tst-auxvalmod \
|
||||||
|
tst-big-note-lib \
|
||||||
|
tst-deep1mod1 \
|
||||||
|
@@ -1999,6 +2002,10 @@ $(objpfx)tst-auditmod17.so: $(objpfx)tst-auditmod17.os
|
||||||
|
CFLAGS-.os += $(call elide-stack-protector,.os,tst-auditmod17)
|
||||||
|
tst-audit17-ENV = LD_AUDIT=$(objpfx)tst-auditmod17.so
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit18.out: $(objpfx)tst-auditmod18.so \
|
||||||
|
+ $(objpfx)tst-audit18mod.so
|
||||||
|
+tst-audit18-ARGS = -- $(host-test-program-cmd)
|
||||||
|
+
|
||||||
|
# tst-sonamemove links against an older implementation of the library.
|
||||||
|
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
||||||
|
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index a920b12a906a9dec..a8c6df3959f2b331 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -1054,42 +1054,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
|
||||||
|
/* This is the ELF header. We read it in `open_verify'. */
|
||||||
|
header = (void *) fbp->buf;
|
||||||
|
|
||||||
|
- /* Signal that we are going to add new objects. */
|
||||||
|
- if (r->r_state == RT_CONSISTENT)
|
||||||
|
- {
|
||||||
|
-#ifdef SHARED
|
||||||
|
- /* Auditing checkpoint: we are going to add new objects. */
|
||||||
|
- if ((mode & __RTLD_AUDIT) == 0
|
||||||
|
- && __glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
|
||||||
|
- /* Do not call the functions for any auditing object. */
|
||||||
|
- if (head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- afct->activity (&link_map_audit_state (head, cnt)->cookie,
|
||||||
|
- LA_ACT_ADD);
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- /* Notify the debugger we have added some objects. We need to
|
||||||
|
- call _dl_debug_initialize in a static program in case dynamic
|
||||||
|
- linking has not been used before. */
|
||||||
|
- r->r_state = RT_ADD;
|
||||||
|
- _dl_debug_state ();
|
||||||
|
- LIBC_PROBE (map_start, 2, nsid, r);
|
||||||
|
- make_consistent = true;
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- assert (r->r_state == RT_ADD);
|
||||||
|
-
|
||||||
|
/* Enter the new object in the list of loaded objects. */
|
||||||
|
l = _dl_new_object (realname, name, l_type, loader, mode, nsid);
|
||||||
|
if (__glibc_unlikely (l == NULL))
|
||||||
|
@@ -1511,6 +1475,44 @@ cannot enable executable stack as shared object requires");
|
||||||
|
/* Now that the object is fully initialized add it to the object list. */
|
||||||
|
_dl_add_to_namespace_list (l, nsid);
|
||||||
|
|
||||||
|
+ /* Signal that we are going to add new objects. */
|
||||||
|
+ if (r->r_state == RT_CONSISTENT)
|
||||||
|
+ {
|
||||||
|
+#ifdef SHARED
|
||||||
|
+ /* Auditing checkpoint: we are going to add new objects. Since this
|
||||||
|
+ is called after _dl_add_to_namespace_list the namespace is guaranteed
|
||||||
|
+ to not be empty. */
|
||||||
|
+ if ((mode & __RTLD_AUDIT) == 0
|
||||||
|
+ && __glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
+ {
|
||||||
|
+ struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
|
||||||
|
+ /* Do not call the functions for any auditing object. */
|
||||||
|
+ if (head->l_auditing == 0)
|
||||||
|
+ {
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->activity != NULL)
|
||||||
|
+ afct->activity (&link_map_audit_state (head, cnt)->cookie,
|
||||||
|
+ LA_ACT_ADD);
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ /* Notify the debugger we have added some objects. We need to
|
||||||
|
+ call _dl_debug_initialize in a static program in case dynamic
|
||||||
|
+ linking has not been used before. */
|
||||||
|
+ r->r_state = RT_ADD;
|
||||||
|
+ _dl_debug_state ();
|
||||||
|
+ LIBC_PROBE (map_start, 2, nsid, r);
|
||||||
|
+ make_consistent = true;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ assert (r->r_state == RT_ADD);
|
||||||
|
+
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we have a new object. */
|
||||||
|
if (__glibc_unlikely (GLRO(dl_naudit) > 0)
|
||||||
|
diff --git a/elf/tst-audit18.c b/elf/tst-audit18.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..ef784908f60d50aa
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit18.c
|
||||||
|
@@ -0,0 +1,129 @@
|
||||||
|
+/* Check DT_AUDIT with dlmopen.
|
||||||
|
+ 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 <array_length.h>
|
||||||
|
+#include <getopt.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+#include <gnu/lib-names.h>
|
||||||
|
+#include <support/capture_subprocess.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+#include <support/xdlfcn.h>
|
||||||
|
+#include <support/xstdio.h>
|
||||||
|
+#include <support/support.h>
|
||||||
|
+
|
||||||
|
+static int restart;
|
||||||
|
+#define CMDLINE_OPTIONS \
|
||||||
|
+ { "restart", no_argument, &restart, 1 },
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+handle_restart (void)
|
||||||
|
+{
|
||||||
|
+ {
|
||||||
|
+ void *h = xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW);
|
||||||
|
+
|
||||||
|
+ pid_t (*s) (void) = xdlsym (h, "getpid");
|
||||||
|
+ TEST_COMPARE (s (), getpid ());
|
||||||
|
+
|
||||||
|
+ xdlclose (h);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ {
|
||||||
|
+ void *h = xdlmopen (LM_ID_NEWLM, "tst-audit18mod.so", RTLD_NOW);
|
||||||
|
+
|
||||||
|
+ int (*foo) (void) = xdlsym (h, "foo");
|
||||||
|
+ TEST_COMPARE (foo (), 10);
|
||||||
|
+
|
||||||
|
+ xdlclose (h);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (int argc, char *argv[])
|
||||||
|
+{
|
||||||
|
+ /* We must have either:
|
||||||
|
+ - One our fource parameters left if called initially:
|
||||||
|
+ + path to ld.so optional
|
||||||
|
+ + "--library-path" optional
|
||||||
|
+ + the library path optional
|
||||||
|
+ + the application name */
|
||||||
|
+
|
||||||
|
+ if (restart)
|
||||||
|
+ return handle_restart ();
|
||||||
|
+
|
||||||
|
+ char *spargv[9];
|
||||||
|
+ int i = 0;
|
||||||
|
+ for (; i < argc - 1; i++)
|
||||||
|
+ spargv[i] = argv[i + 1];
|
||||||
|
+ spargv[i++] = (char *) "--direct";
|
||||||
|
+ spargv[i++] = (char *) "--restart";
|
||||||
|
+ spargv[i] = NULL;
|
||||||
|
+
|
||||||
|
+ setenv ("LD_AUDIT", "tst-auditmod18.so", 0);
|
||||||
|
+ struct support_capture_subprocess result
|
||||||
|
+ = support_capture_subprogram (spargv[0], spargv);
|
||||||
|
+ support_capture_subprocess_check (&result, "tst-audit18", 0, sc_allow_stderr);
|
||||||
|
+
|
||||||
|
+ struct
|
||||||
|
+ {
|
||||||
|
+ const char *name;
|
||||||
|
+ bool found;
|
||||||
|
+ } audit_iface[] =
|
||||||
|
+ {
|
||||||
|
+ { "la_version", false },
|
||||||
|
+ { "la_objsearch", false },
|
||||||
|
+ { "la_activity", false },
|
||||||
|
+ { "la_objopen", false },
|
||||||
|
+ { "la_objclose", false },
|
||||||
|
+ { "la_preinit", false },
|
||||||
|
+#if __WORDSIZE == 32
|
||||||
|
+ { "la_symbind32", false },
|
||||||
|
+#elif __WORDSIZE == 64
|
||||||
|
+ { "la_symbind64", false },
|
||||||
|
+#endif
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ /* Some hooks are called more than once but the test only check if any
|
||||||
|
+ is called at least once. */
|
||||||
|
+ FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||||
|
+ TEST_VERIFY (out != NULL);
|
||||||
|
+ char *buffer = NULL;
|
||||||
|
+ size_t buffer_length = 0;
|
||||||
|
+ while (xgetline (&buffer, &buffer_length, out))
|
||||||
|
+ {
|
||||||
|
+ for (int i = 0; i < array_length (audit_iface); i++)
|
||||||
|
+ if (strncmp (buffer, audit_iface[i].name,
|
||||||
|
+ strlen (audit_iface[i].name)) == 0)
|
||||||
|
+ audit_iface[i].found = true;
|
||||||
|
+ }
|
||||||
|
+ free (buffer);
|
||||||
|
+ xfclose (out);
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < array_length (audit_iface); i++)
|
||||||
|
+ TEST_COMPARE (audit_iface[i].found, true);
|
||||||
|
+
|
||||||
|
+ support_capture_subprocess_free (&result);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define TEST_FUNCTION_ARGV do_test
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-audit18mod.c b/elf/tst-audit18mod.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..096a9167c9f8353f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit18mod.c
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+/* Check DT_AUDIT with dlmopen.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+foo (void)
|
||||||
|
+{
|
||||||
|
+ return 10;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod18.c b/elf/tst-auditmod18.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..182992e9fdb1620c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod18.c
|
||||||
|
@@ -0,0 +1,73 @@
|
||||||
|
+/* Check DT_AUDIT with dlmopen.
|
||||||
|
+ 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 <stdio.h>
|
||||||
|
+#include <link.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+char *
|
||||||
|
+la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+ return (char *) name;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_activity (uintptr_t *cookie, unsigned int flag)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+ return LA_FLG_BINDTO | LA_FLG_BINDFROM;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objclose (uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_preinit (uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+uintptr_t
|
||||||
|
+#if __ELF_NATIVE_CLASS == 32
|
||||||
|
+la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
||||||
|
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
||||||
|
+#else
|
||||||
|
+la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
||||||
|
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
||||||
|
+#endif
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s\n", __func__);
|
||||||
|
+ return sym->st_value;
|
||||||
|
+}
|
159
glibc-upstream-2.34-142.patch
Normal file
159
glibc-upstream-2.34-142.patch
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
commit ce0cb6d1d2daac2d58006a41c3d19c551b86f255
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Mon Jul 19 15:47:51 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_objopen
|
||||||
|
|
||||||
|
It consolidates the code required to call la_objopen audit callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit aee6e90f93e285016b6cd9c8bd00402c19ba271b)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/Makefile
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index bf6da98bdd15a18d..85165c0591412a45 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -118,6 +118,7 @@ elide-routines.os = \
|
||||||
|
# interpreter and operating independent of libc.
|
||||||
|
rtld-routines = \
|
||||||
|
$(all-dl-routines) \
|
||||||
|
+ dl-audit \
|
||||||
|
dl-compat \
|
||||||
|
dl-conflict \
|
||||||
|
dl-diagnostics \
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..4066dfe85146b9d4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -0,0 +1,39 @@
|
||||||
|
+/* Audit common functions.
|
||||||
|
+ 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 <ldsodefs.h>
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
+{
|
||||||
|
+ if (__glibc_likely (GLRO(dl_naudit) == 0))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->objopen != NULL)
|
||||||
|
+ {
|
||||||
|
+ struct auditstate *state = link_map_audit_state (l, cnt);
|
||||||
|
+ state->bindflags = afct->objopen (l, nsid, &state->cookie);
|
||||||
|
+ l->l_audit_any_plt |= state->bindflags != 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index a8c6df3959f2b331..a2d73d025c65cd79 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -1515,22 +1515,8 @@ cannot enable executable stack as shared object requires");
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we have a new object. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0)
|
||||||
|
- && !GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->objopen != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (l, cnt);
|
||||||
|
- state->bindflags = afct->objopen (l, nsid, &state->cookie);
|
||||||
|
- l->l_audit_any_plt |= state->bindflags != 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ if (!GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing)
|
||||||
|
+ _dl_audit_objopen (l, nsid);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return l;
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index ad5ddb2a0ab94e7f..45fec0df3043b90a 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -1064,25 +1064,6 @@ ERROR: audit interface '%s' requires version %d (maximum supported version %d);
|
||||||
|
dlmargs.map->l_auditing = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* Notify the the audit modules that the object MAP has already been
|
||||||
|
- loaded. */
|
||||||
|
-static void
|
||||||
|
-notify_audit_modules_of_loaded_object (struct link_map *map)
|
||||||
|
-{
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->objopen != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (map, cnt);
|
||||||
|
- state->bindflags = afct->objopen (map, LM_ID_BASE, &state->cookie);
|
||||||
|
- map->l_audit_any_plt |= state->bindflags != 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
/* Load all audit modules. */
|
||||||
|
static void
|
||||||
|
load_audit_modules (struct link_map *main_map, struct audit_list *audit_list)
|
||||||
|
@@ -1101,8 +1082,8 @@ load_audit_modules (struct link_map *main_map, struct audit_list *audit_list)
|
||||||
|
program and the dynamic linker itself). */
|
||||||
|
if (GLRO(dl_naudit) > 0)
|
||||||
|
{
|
||||||
|
- notify_audit_modules_of_loaded_object (main_map);
|
||||||
|
- notify_audit_modules_of_loaded_object (&GL(dl_rtld_map));
|
||||||
|
+ _dl_audit_objopen (main_map, LM_ID_BASE);
|
||||||
|
+ _dl_audit_objopen (&GL(dl_rtld_map), LM_ID_BASE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index bcf1f199c5985c65..5709e4e48dff4355 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1372,6 +1372,11 @@ link_map_audit_state (struct link_map *l, size_t index)
|
||||||
|
return &base[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+/* Call the la_objopen from the audit modules for the link_map L on the
|
||||||
|
+ namespace identification NSID. */
|
||||||
|
+void _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
+ attribute_hidden;
|
||||||
|
#endif /* SHARED */
|
||||||
|
|
||||||
|
#if PTHREAD_IN_LIBC && defined SHARED
|
254
glibc-upstream-2.34-143.patch
Normal file
254
glibc-upstream-2.34-143.patch
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
commit 66e9d27a090874ab93030a908eb86fc29f856151
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Tue Jul 20 11:03:34 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid
|
||||||
|
|
||||||
|
It consolidates the code required to call la_activity audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Also for a new Lmid_t the namespace link_map list are empty, so it
|
||||||
|
requires to check if before using it. This can happen for when audit
|
||||||
|
module is used along with dlmopen.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 3dac3959a5cb585b065cef2cb8a8d909c907e202)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 4066dfe85146b9d4..74b87f4b39be75e1 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -18,6 +18,32 @@
|
||||||
|
|
||||||
|
#include <ldsodefs.h>
|
||||||
|
|
||||||
|
+void
|
||||||
|
+_dl_audit_activity_map (struct link_map *l, int action)
|
||||||
|
+{
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->activity != NULL)
|
||||||
|
+ afct->activity (&link_map_audit_state (l, cnt)->cookie, action);
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_activity_nsid (Lmid_t nsid, int action)
|
||||||
|
+{
|
||||||
|
+ /* If head is NULL, the namespace has become empty, and the audit interface
|
||||||
|
+ does not give us a way to signal LA_ACT_CONSISTENT for it because the
|
||||||
|
+ first loaded module is used to identify the namespace. */
|
||||||
|
+ struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
|
||||||
|
+ if (__glibc_likely (GLRO(dl_naudit) == 0)
|
||||||
|
+ || head == NULL || head->l_auditing)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ _dl_audit_activity_map (head, action);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
_dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
{
|
||||||
|
diff --git a/elf/dl-close.c b/elf/dl-close.c
|
||||||
|
index f6fbf9de7d78555b..5a8cc9e7cb5186cc 100644
|
||||||
|
--- a/elf/dl-close.c
|
||||||
|
+++ b/elf/dl-close.c
|
||||||
|
@@ -472,25 +472,7 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we will start deleting objects. */
|
||||||
|
- if (__glibc_unlikely (do_audit))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = ns->_ns_loaded;
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- /* Do not call the functions for any auditing object. */
|
||||||
|
- if (head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (head, cnt);
|
||||||
|
- afct->activity (&state->cookie, LA_ACT_DELETE);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_activity_nsid (nsid, LA_ACT_DELETE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Notify the debugger we are about to remove some loaded objects. */
|
||||||
|
@@ -785,32 +767,9 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||||
|
__rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
- /* Auditing checkpoint: we have deleted all objects. */
|
||||||
|
- if (__glibc_unlikely (do_audit))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = ns->_ns_loaded;
|
||||||
|
- /* If head is NULL, the namespace has become empty, and the
|
||||||
|
- audit interface does not give us a way to signal
|
||||||
|
- LA_ACT_CONSISTENT for it because the first loaded module is
|
||||||
|
- used to identify the namespace.
|
||||||
|
-
|
||||||
|
- Furthermore, do not notify auditors of the cleanup of a
|
||||||
|
- failed audit module loading attempt. */
|
||||||
|
- if (head != NULL && head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (head, cnt);
|
||||||
|
- afct->activity (&state->cookie, LA_ACT_CONSISTENT);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ /* Auditing checkpoint: we have deleted all objects. Also, do not notify
|
||||||
|
+ auditors of the cleanup of a failed audit module loading attempt. */
|
||||||
|
+ _dl_audit_activity_nsid (nsid, LA_ACT_CONSISTENT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (__builtin_expect (ns->_ns_loaded == NULL, 0)
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index a2d73d025c65cd79..baf0a926053deaed 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -1482,24 +1482,8 @@ cannot enable executable stack as shared object requires");
|
||||||
|
/* Auditing checkpoint: we are going to add new objects. Since this
|
||||||
|
is called after _dl_add_to_namespace_list the namespace is guaranteed
|
||||||
|
to not be empty. */
|
||||||
|
- if ((mode & __RTLD_AUDIT) == 0
|
||||||
|
- && __glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
|
||||||
|
- /* Do not call the functions for any auditing object. */
|
||||||
|
- if (head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- afct->activity (&link_map_audit_state (head, cnt)->cookie,
|
||||||
|
- LA_ACT_ADD);
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ if ((mode & __RTLD_AUDIT) == 0)
|
||||||
|
+ _dl_audit_activity_nsid (nsid, LA_ACT_ADD);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Notify the debugger we have added some objects. We need to
|
||||||
|
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
||||||
|
index bc68e2c376debd71..3f01aa480730da13 100644
|
||||||
|
--- a/elf/dl-open.c
|
||||||
|
+++ b/elf/dl-open.c
|
||||||
|
@@ -611,25 +611,7 @@ dl_open_worker_begin (void *a)
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we have added all objects. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = GL(dl_ns)[new->l_ns]._ns_loaded;
|
||||||
|
- /* Do not call the functions for any auditing object. */
|
||||||
|
- if (head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (head, cnt);
|
||||||
|
- afct->activity (&state->cookie, LA_ACT_CONSISTENT);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_activity_nsid (new->l_ns, LA_ACT_CONSISTENT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Notify the debugger all new objects are now ready to go. */
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index 45fec0df3043b90a..b6bb46ca97b7972f 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -1804,18 +1804,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
|
||||||
|
/* Auditing checkpoint: we are ready to signal that the initial map
|
||||||
|
is being constructed. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- afct->activity (&link_map_audit_state (main_map, cnt)->cookie,
|
||||||
|
- LA_ACT_ADD);
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_activity_map (main_map, LA_ACT_ADD);
|
||||||
|
|
||||||
|
/* We have two ways to specify objects to preload: via environment
|
||||||
|
variable and via the file /etc/ld.so.preload. The latter can also
|
||||||
|
@@ -2496,23 +2485,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we have added all objects. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct link_map *head = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
|
||||||
|
- /* Do not call the functions for any auditing object. */
|
||||||
|
- if (head->l_auditing == 0)
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->activity != NULL)
|
||||||
|
- afct->activity (&link_map_audit_state (head, cnt)->cookie,
|
||||||
|
- LA_ACT_CONSISTENT);
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_activity_nsid (LM_ID_BASE, LA_ACT_CONSISTENT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Notify the debugger all new objects are now ready to go. We must re-get
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 5709e4e48dff4355..7384abcf5e0e8e24 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1373,6 +1373,16 @@ link_map_audit_state (struct link_map *l, size_t index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Call the la_activity from the audit modules from the link map L and issues
|
||||||
|
+ the ACTION argument. */
|
||||||
|
+void _dl_audit_activity_map (struct link_map *l, int action)
|
||||||
|
+ attribute_hidden;
|
||||||
|
+
|
||||||
|
+/* Call the la_activity from the audit modules from the link map from the
|
||||||
|
+ namespace NSID and issues the ACTION argument. */
|
||||||
|
+void _dl_audit_activity_nsid (Lmid_t nsid, int action)
|
||||||
|
+ attribute_hidden;
|
||||||
|
+
|
||||||
|
/* Call the la_objopen from the audit modules for the link_map L on the
|
||||||
|
namespace identification NSID. */
|
||||||
|
void _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
157
glibc-upstream-2.34-144.patch
Normal file
157
glibc-upstream-2.34-144.patch
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
commit ec0fc2a15358dc5f7191f9994f04b1385d14377d
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Tue Jul 20 13:47:36 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_objsearch
|
||||||
|
|
||||||
|
It consolidates the code required to call la_objsearch audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit c91008d3490e4e3ce29520068405f081f0d368ca)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 74b87f4b39be75e1..5682427220569d90 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -44,6 +44,28 @@ _dl_audit_activity_nsid (Lmid_t nsid, int action)
|
||||||
|
_dl_audit_activity_map (head, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
+const char *
|
||||||
|
+_dl_audit_objsearch (const char *name, struct link_map *l, unsigned int code)
|
||||||
|
+{
|
||||||
|
+ if (l == NULL || l->l_auditing || code == 0)
|
||||||
|
+ return name;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->objsearch != NULL)
|
||||||
|
+ {
|
||||||
|
+ struct auditstate *state = link_map_audit_state (l, cnt);
|
||||||
|
+ name = afct->objsearch (name, &state->cookie, code);
|
||||||
|
+ if (name == NULL)
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return name;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
_dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
{
|
||||||
|
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||||
|
index baf0a926053deaed..eb6b658b698f5694 100644
|
||||||
|
--- a/elf/dl-load.c
|
||||||
|
+++ b/elf/dl-load.c
|
||||||
|
@@ -1596,32 +1596,20 @@ open_verify (const char *name, int fd,
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Give the auditing libraries a chance. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
|
||||||
|
- && loader->l_auditing == 0)
|
||||||
|
+ if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
{
|
||||||
|
const char *original_name = name;
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->objsearch != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state = link_map_audit_state (loader, cnt);
|
||||||
|
- name = afct->objsearch (name, &state->cookie, whatcode);
|
||||||
|
- if (name == NULL)
|
||||||
|
- /* Ignore the path. */
|
||||||
|
- return -1;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
+ name = _dl_audit_objsearch (name, loader, whatcode);
|
||||||
|
+ if (name == NULL)
|
||||||
|
+ return -1;
|
||||||
|
|
||||||
|
if (fd != -1 && name != original_name && strcmp (name, original_name))
|
||||||
|
- {
|
||||||
|
- /* An audit library changed what we're supposed to open,
|
||||||
|
- so FD no longer matches it. */
|
||||||
|
- __close_nocancel (fd);
|
||||||
|
- fd = -1;
|
||||||
|
- }
|
||||||
|
+ {
|
||||||
|
+ /* An audit library changed what we're supposed to open,
|
||||||
|
+ so FD no longer matches it. */
|
||||||
|
+ __close_nocancel (fd);
|
||||||
|
+ fd = -1;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -2060,36 +2048,17 @@ _dl_map_object (struct link_map *loader, const char *name,
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Give the auditing libraries a chance to change the name before we
|
||||||
|
try anything. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0)
|
||||||
|
- && (loader == NULL || loader->l_auditing == 0))
|
||||||
|
+ if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
{
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ const char *before = name;
|
||||||
|
+ name = _dl_audit_objsearch (name, loader, LA_SER_ORIG);
|
||||||
|
+ if (name == NULL)
|
||||||
|
{
|
||||||
|
- if (afct->objsearch != NULL)
|
||||||
|
- {
|
||||||
|
- const char *before = name;
|
||||||
|
- struct auditstate *state = link_map_audit_state (loader, cnt);
|
||||||
|
- name = afct->objsearch (name, &state->cookie, LA_SER_ORIG);
|
||||||
|
- if (name == NULL)
|
||||||
|
- {
|
||||||
|
- /* Do not try anything further. */
|
||||||
|
- fd = -1;
|
||||||
|
- goto no_file;
|
||||||
|
- }
|
||||||
|
- if (before != name && strcmp (before, name) != 0)
|
||||||
|
- {
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES))
|
||||||
|
- _dl_debug_printf ("audit changed filename %s -> %s\n",
|
||||||
|
- before, name);
|
||||||
|
-
|
||||||
|
- if (origname == NULL)
|
||||||
|
- origname = before;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
+ fd = -1;
|
||||||
|
+ goto no_file;
|
||||||
|
}
|
||||||
|
+ if (before != name && strcmp (before, name) != 0)
|
||||||
|
+ origname = before;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 7384abcf5e0e8e24..1f212a18d7bfc440 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1373,6 +1373,13 @@ link_map_audit_state (struct link_map *l, size_t index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Call the la_objsearch from the audit modules from the link map L. If
|
||||||
|
+ ORIGNAME is non NULL, it is updated with the revious name prior calling
|
||||||
|
+ la_objsearch. */
|
||||||
|
+const char *_dl_audit_objsearch (const char *name, struct link_map *l,
|
||||||
|
+ unsigned int code)
|
||||||
|
+ attribute_hidden;
|
||||||
|
+
|
||||||
|
/* Call the la_activity from the audit modules from the link map L and issues
|
||||||
|
the ACTION argument. */
|
||||||
|
void _dl_audit_activity_map (struct link_map *l, int action)
|
123
glibc-upstream-2.34-145.patch
Normal file
123
glibc-upstream-2.34-145.patch
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
commit 198660741b23ec9defb19e22951d4a721de603c8
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Tue Jul 20 14:04:51 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_objclose
|
||||||
|
|
||||||
|
It consolidates the code required to call la_objclose audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 311c9ee54ea963ff69bd3a2e6981c37e893b4c3e)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 5682427220569d90..cb1c3de93cba447b 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -85,3 +85,24 @@ _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
afct = afct->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_objclose (struct link_map *l)
|
||||||
|
+{
|
||||||
|
+ if (__glibc_likely (GLRO(dl_naudit) == 0)
|
||||||
|
+ || GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->objclose != NULL)
|
||||||
|
+ {
|
||||||
|
+ struct auditstate *state= link_map_audit_state (l, cnt);
|
||||||
|
+ /* Return value is ignored. */
|
||||||
|
+ afct->objclose (&state->cookie);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/elf/dl-close.c b/elf/dl-close.c
|
||||||
|
index 5a8cc9e7cb5186cc..985cd4e2821436af 100644
|
||||||
|
--- a/elf/dl-close.c
|
||||||
|
+++ b/elf/dl-close.c
|
||||||
|
@@ -260,9 +260,6 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||||
|
_dl_sort_maps (maps, nloaded, (nsid == LM_ID_BASE), true);
|
||||||
|
|
||||||
|
/* Call all termination functions at once. */
|
||||||
|
-#ifdef SHARED
|
||||||
|
- bool do_audit = GLRO(dl_naudit) > 0 && !ns->_ns_loaded->l_auditing;
|
||||||
|
-#endif
|
||||||
|
bool unload_any = false;
|
||||||
|
bool scope_mem_left = false;
|
||||||
|
unsigned int unload_global = 0;
|
||||||
|
@@ -296,22 +293,7 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we remove an object. */
|
||||||
|
- if (__glibc_unlikely (do_audit))
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->objclose != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state
|
||||||
|
- = link_map_audit_state (imap, cnt);
|
||||||
|
- /* Return value is ignored. */
|
||||||
|
- (void) afct->objclose (&state->cookie);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_objclose (imap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This object must not be used anymore. */
|
||||||
|
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
|
||||||
|
index c683884c355dfd52..b789cfb9f2ac6c85 100644
|
||||||
|
--- a/elf/dl-fini.c
|
||||||
|
+++ b/elf/dl-fini.c
|
||||||
|
@@ -146,21 +146,7 @@ _dl_fini (void)
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: another object closed. */
|
||||||
|
- if (!do_audit && __builtin_expect (GLRO(dl_naudit) > 0, 0))
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->objclose != NULL)
|
||||||
|
- {
|
||||||
|
- struct auditstate *state
|
||||||
|
- = link_map_audit_state (l, cnt);
|
||||||
|
- /* Return value is ignored. */
|
||||||
|
- (void) afct->objclose (&state->cookie);
|
||||||
|
- }
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ _dl_audit_objclose (l);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 1f212a18d7bfc440..982f23c0287955fe 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1394,6 +1394,10 @@ void _dl_audit_activity_nsid (Lmid_t nsid, int action)
|
||||||
|
namespace identification NSID. */
|
||||||
|
void _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
attribute_hidden;
|
||||||
|
+
|
||||||
|
+/* Call the la_objclose from the audit modules for the link_map L. */
|
||||||
|
+void _dl_audit_objclose (struct link_map *l)
|
||||||
|
+ attribute_hidden;
|
||||||
|
#endif /* SHARED */
|
||||||
|
|
||||||
|
#if PTHREAD_IN_LIBC && defined SHARED
|
334
glibc-upstream-2.34-146.patch
Normal file
334
glibc-upstream-2.34-146.patch
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
commit b2d99731b6d27c719a30b8ffa931e91c73a6bb4b
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Tue Jul 20 15:58:35 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_symbind_alt and _dl_audit_symbind
|
||||||
|
|
||||||
|
It consolidates the code required to call la_symbind{32,64} audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit cda4f265c65fb6c4ce38ca1cf0a7e527c5e77cd5)
|
||||||
|
|
||||||
|
diff --git a/elf/Versions b/elf/Versions
|
||||||
|
index 2af210b8f771c950..164682eaeaa9a1da 100644
|
||||||
|
--- a/elf/Versions
|
||||||
|
+++ b/elf/Versions
|
||||||
|
@@ -58,6 +58,7 @@ ld {
|
||||||
|
_dl_argv; _dl_find_dso_for_object; _dl_get_tls_static_info;
|
||||||
|
_dl_deallocate_tls; _dl_make_stack_executable;
|
||||||
|
_dl_rtld_di_serinfo; _dl_starting_up; _dl_fatal_printf;
|
||||||
|
+ _dl_audit_symbind_alt;
|
||||||
|
_rtld_global; _rtld_global_ro;
|
||||||
|
|
||||||
|
# Only here for gdb while a better method is developed.
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index cb1c3de93cba447b..a21530f30bc5524b 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -16,6 +16,7 @@
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
+#include <assert.h>
|
||||||
|
#include <ldsodefs.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -106,3 +107,124 @@ _dl_audit_objclose (struct link_map *l)
|
||||||
|
afct = afct->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_symbind_alt (struct link_map *l, const ElfW(Sym) *ref, void **value,
|
||||||
|
+ lookup_t result)
|
||||||
|
+{
|
||||||
|
+ if ((l->l_audit_any_plt | result->l_audit_any_plt) == 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ const char *strtab = (const char *) D_PTR (result, l_info[DT_STRTAB]);
|
||||||
|
+ /* Compute index of the symbol entry in the symbol table of the DSO with
|
||||||
|
+ the definition. */
|
||||||
|
+ unsigned int ndx = (ref - (ElfW(Sym) *) D_PTR (result, l_info[DT_SYMTAB]));
|
||||||
|
+
|
||||||
|
+ unsigned int altvalue = 0;
|
||||||
|
+ /* Synthesize a symbol record where the st_value field is the result. */
|
||||||
|
+ ElfW(Sym) sym = *ref;
|
||||||
|
+ sym.st_value = (ElfW(Addr)) *value;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ struct auditstate *match_audit = link_map_audit_state (l, cnt);
|
||||||
|
+ struct auditstate *result_audit = link_map_audit_state (result, cnt);
|
||||||
|
+ if (afct->symbind != NULL
|
||||||
|
+ && ((match_audit->bindflags & LA_FLG_BINDFROM) != 0
|
||||||
|
+ || ((result_audit->bindflags & LA_FLG_BINDTO)
|
||||||
|
+ != 0)))
|
||||||
|
+ {
|
||||||
|
+ unsigned int flags = altvalue | LA_SYMB_DLSYM;
|
||||||
|
+ uintptr_t new_value = afct->symbind (&sym, ndx,
|
||||||
|
+ &match_audit->cookie,
|
||||||
|
+ &result_audit->cookie,
|
||||||
|
+ &flags, strtab + ref->st_name);
|
||||||
|
+ if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
+ {
|
||||||
|
+ altvalue = LA_SYMB_ALTVALUE;
|
||||||
|
+ sym.st_value = new_value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ *value = (void *) sym.st_value;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+rtld_hidden_def (_dl_audit_symbind_alt)
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
+ const ElfW(Sym) *defsym, DL_FIXUP_VALUE_TYPE *value,
|
||||||
|
+ lookup_t result)
|
||||||
|
+{
|
||||||
|
+ reloc_result->bound = result;
|
||||||
|
+ /* Compute index of the symbol entry in the symbol table of the DSO with the
|
||||||
|
+ definition. */
|
||||||
|
+ reloc_result->boundndx = (defsym - (ElfW(Sym) *) D_PTR (result,
|
||||||
|
+ l_info[DT_SYMTAB]));
|
||||||
|
+
|
||||||
|
+ if ((l->l_audit_any_plt | result->l_audit_any_plt) == 0)
|
||||||
|
+ {
|
||||||
|
+ /* Set all bits since this symbol binding is not interesting. */
|
||||||
|
+ reloc_result->enterexit = (1u << DL_NNS) - 1;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Synthesize a symbol record where the st_value field is the result. */
|
||||||
|
+ ElfW(Sym) sym = *defsym;
|
||||||
|
+ sym.st_value = DL_FIXUP_VALUE_ADDR (*value);
|
||||||
|
+
|
||||||
|
+ /* Keep track whether there is any interest in tracing the call in the lower
|
||||||
|
+ two bits. */
|
||||||
|
+ assert (DL_NNS * 2 <= sizeof (reloc_result->flags) * 8);
|
||||||
|
+ assert ((LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) == 3);
|
||||||
|
+ reloc_result->enterexit = LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT;
|
||||||
|
+
|
||||||
|
+ const char *strtab2 = (const void *) D_PTR (result, l_info[DT_STRTAB]);
|
||||||
|
+
|
||||||
|
+ unsigned int flags = 0;
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ /* XXX Check whether both DSOs must request action or only one */
|
||||||
|
+ struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
+ struct auditstate *result_state = link_map_audit_state (result, cnt);
|
||||||
|
+ if ((l_state->bindflags & LA_FLG_BINDFROM) != 0
|
||||||
|
+ && (result_state->bindflags & LA_FLG_BINDTO) != 0)
|
||||||
|
+ {
|
||||||
|
+ if (afct->symbind != NULL)
|
||||||
|
+ {
|
||||||
|
+ uintptr_t new_value = afct->symbind (&sym,
|
||||||
|
+ reloc_result->boundndx,
|
||||||
|
+ &l_state->cookie,
|
||||||
|
+ &result_state->cookie,
|
||||||
|
+ &flags,
|
||||||
|
+ strtab2 + defsym->st_name);
|
||||||
|
+ if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
+ {
|
||||||
|
+ flags |= LA_SYMB_ALTVALUE;
|
||||||
|
+ sym.st_value = new_value;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Remember the results for every audit library and store a summary
|
||||||
|
+ in the first two bits. */
|
||||||
|
+ reloc_result->enterexit &= flags & (LA_SYMB_NOPLTENTER
|
||||||
|
+ | LA_SYMB_NOPLTEXIT);
|
||||||
|
+ reloc_result->enterexit |= ((flags & (LA_SYMB_NOPLTENTER
|
||||||
|
+ | LA_SYMB_NOPLTEXIT))
|
||||||
|
+ << ((cnt + 1) * 2));
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ /* If the bind flags say this auditor is not interested, set the bits
|
||||||
|
+ manually. */
|
||||||
|
+ reloc_result->enterexit |= ((LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT)
|
||||||
|
+ << ((cnt + 1) * 2));
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ reloc_result->flags = flags;
|
||||||
|
+ *value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
+}
|
||||||
|
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
|
||||||
|
index 61c260ddb81b586c..c4413c9165cec8cb 100644
|
||||||
|
--- a/elf/dl-runtime.c
|
||||||
|
+++ b/elf/dl-runtime.c
|
||||||
|
@@ -297,84 +297,7 @@ _dl_profile_fixup (
|
||||||
|
auditing libraries the possibility to change the value and
|
||||||
|
tell us whether further auditing is wanted. */
|
||||||
|
if (defsym != NULL && GLRO(dl_naudit) > 0)
|
||||||
|
- {
|
||||||
|
- reloc_result->bound = result;
|
||||||
|
- /* Compute index of the symbol entry in the symbol table of
|
||||||
|
- the DSO with the definition. */
|
||||||
|
- reloc_result->boundndx = (defsym
|
||||||
|
- - (ElfW(Sym) *) D_PTR (result,
|
||||||
|
- l_info[DT_SYMTAB]));
|
||||||
|
-
|
||||||
|
- /* Determine whether any of the two participating DSOs is
|
||||||
|
- interested in auditing. */
|
||||||
|
- if ((l->l_audit_any_plt | result->l_audit_any_plt) != 0)
|
||||||
|
- {
|
||||||
|
- unsigned int flags = 0;
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- /* Synthesize a symbol record where the st_value field is
|
||||||
|
- the result. */
|
||||||
|
- ElfW(Sym) sym = *defsym;
|
||||||
|
- sym.st_value = DL_FIXUP_VALUE_ADDR (value);
|
||||||
|
-
|
||||||
|
- /* Keep track whether there is any interest in tracing
|
||||||
|
- the call in the lower two bits. */
|
||||||
|
- assert (DL_NNS * 2 <= sizeof (reloc_result->flags) * 8);
|
||||||
|
- assert ((LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) == 3);
|
||||||
|
- reloc_result->enterexit = LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT;
|
||||||
|
-
|
||||||
|
- const char *strtab2 = (const void *) D_PTR (result,
|
||||||
|
- l_info[DT_STRTAB]);
|
||||||
|
-
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- /* XXX Check whether both DSOs must request action or
|
||||||
|
- only one */
|
||||||
|
- struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
- struct auditstate *result_state
|
||||||
|
- = link_map_audit_state (result, cnt);
|
||||||
|
- if ((l_state->bindflags & LA_FLG_BINDFROM) != 0
|
||||||
|
- && (result_state->bindflags & LA_FLG_BINDTO) != 0)
|
||||||
|
- {
|
||||||
|
- if (afct->symbind != NULL)
|
||||||
|
- {
|
||||||
|
- uintptr_t new_value
|
||||||
|
- = afct->symbind (&sym, reloc_result->boundndx,
|
||||||
|
- &l_state->cookie,
|
||||||
|
- &result_state->cookie,
|
||||||
|
- &flags,
|
||||||
|
- strtab2 + defsym->st_name);
|
||||||
|
- if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
- {
|
||||||
|
- flags |= LA_SYMB_ALTVALUE;
|
||||||
|
- sym.st_value = new_value;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Remember the results for every audit library and
|
||||||
|
- store a summary in the first two bits. */
|
||||||
|
- reloc_result->enterexit
|
||||||
|
- &= flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT);
|
||||||
|
- reloc_result->enterexit
|
||||||
|
- |= ((flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT))
|
||||||
|
- << ((cnt + 1) * 2));
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- /* If the bind flags say this auditor is not interested,
|
||||||
|
- set the bits manually. */
|
||||||
|
- reloc_result->enterexit
|
||||||
|
- |= ((LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT)
|
||||||
|
- << ((cnt + 1) * 2));
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- reloc_result->flags = flags;
|
||||||
|
- value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- /* Set all bits since this symbol binding is not interesting. */
|
||||||
|
- reloc_result->enterexit = (1u << DL_NNS) - 1;
|
||||||
|
- }
|
||||||
|
+ _dl_audit_symbind (l, reloc_result, defsym, &value, result);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Store the result for later runs. */
|
||||||
|
diff --git a/elf/dl-sym-post.h b/elf/dl-sym-post.h
|
||||||
|
index d68c2d2b1cd43c9b..a11095d3e8c3c937 100644
|
||||||
|
--- a/elf/dl-sym-post.h
|
||||||
|
+++ b/elf/dl-sym-post.h
|
||||||
|
@@ -52,54 +52,9 @@ _dl_sym_post (lookup_t result, const ElfW(Sym) *ref, void *value,
|
||||||
|
tell us whether further auditing is wanted. */
|
||||||
|
if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
{
|
||||||
|
- const char *strtab = (const char *) D_PTR (result,
|
||||||
|
- l_info[DT_STRTAB]);
|
||||||
|
- /* Compute index of the symbol entry in the symbol table of
|
||||||
|
- the DSO with the definition. */
|
||||||
|
- unsigned int ndx = (ref - (ElfW(Sym) *) D_PTR (result,
|
||||||
|
- l_info[DT_SYMTAB]));
|
||||||
|
-
|
||||||
|
if (match == NULL)
|
||||||
|
match = _dl_sym_find_caller_link_map (caller);
|
||||||
|
-
|
||||||
|
- if ((match->l_audit_any_plt | result->l_audit_any_plt) != 0)
|
||||||
|
- {
|
||||||
|
- unsigned int altvalue = 0;
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- /* Synthesize a symbol record where the st_value field is
|
||||||
|
- the result. */
|
||||||
|
- ElfW(Sym) sym = *ref;
|
||||||
|
- sym.st_value = (ElfW(Addr)) value;
|
||||||
|
-
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- struct auditstate *match_audit
|
||||||
|
- = link_map_audit_state (match, cnt);
|
||||||
|
- struct auditstate *result_audit
|
||||||
|
- = link_map_audit_state (result, cnt);
|
||||||
|
- if (afct->symbind != NULL
|
||||||
|
- && ((match_audit->bindflags & LA_FLG_BINDFROM) != 0
|
||||||
|
- || ((result_audit->bindflags & LA_FLG_BINDTO)
|
||||||
|
- != 0)))
|
||||||
|
- {
|
||||||
|
- unsigned int flags = altvalue | LA_SYMB_DLSYM;
|
||||||
|
- uintptr_t new_value
|
||||||
|
- = afct->symbind (&sym, ndx,
|
||||||
|
- &match_audit->cookie,
|
||||||
|
- &result_audit->cookie,
|
||||||
|
- &flags, strtab + ref->st_name);
|
||||||
|
- if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
- {
|
||||||
|
- altvalue = LA_SYMB_ALTVALUE;
|
||||||
|
- sym.st_value = new_value;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- value = (void *) sym.st_value;
|
||||||
|
- }
|
||||||
|
+ _dl_audit_symbind_alt (match, ref, &value, result);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return value;
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 982f23c0287955fe..61f1dfb3f79a613a 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1398,6 +1398,16 @@ void _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
/* Call the la_objclose from the audit modules for the link_map L. */
|
||||||
|
void _dl_audit_objclose (struct link_map *l)
|
||||||
|
attribute_hidden;
|
||||||
|
+
|
||||||
|
+/* Call the la_symbind{32,64} from the audit modules for the link_map L. */
|
||||||
|
+void _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
+ const ElfW(Sym) *defsym, DL_FIXUP_VALUE_TYPE *value,
|
||||||
|
+ lookup_t result)
|
||||||
|
+ attribute_hidden;
|
||||||
|
+/* Same as _dl_audit_symbind, but also sets LA_SYMB_DLSYM flag. */
|
||||||
|
+void _dl_audit_symbind_alt (struct link_map *l, const ElfW(Sym) *ref,
|
||||||
|
+ void **value, lookup_t result);
|
||||||
|
+rtld_hidden_proto (_dl_audit_symbind_alt)
|
||||||
|
#endif /* SHARED */
|
||||||
|
|
||||||
|
#if PTHREAD_IN_LIBC && defined SHARED
|
107
glibc-upstream-2.34-147.patch
Normal file
107
glibc-upstream-2.34-147.patch
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
commit 31473c273be14270f8eef68e35c03fd2305eb2c3
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Thu Jul 22 17:10:57 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_preinit
|
||||||
|
|
||||||
|
It consolidates the code required to call la_preinit audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 0b98a8748759e88b58927882a8714109abe0a2d6)
|
||||||
|
|
||||||
|
diff --git a/csu/libc-start.c b/csu/libc-start.c
|
||||||
|
index 0350b006fdcc22d2..d01e57ea59ceb880 100644
|
||||||
|
--- a/csu/libc-start.c
|
||||||
|
+++ b/csu/libc-start.c
|
||||||
|
@@ -377,32 +377,15 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
|
||||||
|
/* This is a current program. Use the dynamic segment to find
|
||||||
|
constructors. */
|
||||||
|
call_init (argc, argv, __environ);
|
||||||
|
-#else /* !SHARED */
|
||||||
|
- call_init (argc, argv, __environ);
|
||||||
|
-#endif /* SHARED */
|
||||||
|
|
||||||
|
-#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: we have a new object. */
|
||||||
|
- if (__glibc_unlikely (GLRO(dl_naudit) > 0))
|
||||||
|
- {
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- struct link_map *head = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->preinit != NULL)
|
||||||
|
- afct->preinit (&link_map_audit_state (head, cnt)->cookie);
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
+ _dl_audit_preinit (GL(dl_ns)[LM_ID_BASE]._ns_loaded);
|
||||||
|
|
||||||
|
-#ifdef SHARED
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS))
|
||||||
|
GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv[0]);
|
||||||
|
-#endif
|
||||||
|
+#else /* !SHARED */
|
||||||
|
+ call_init (argc, argv, __environ);
|
||||||
|
|
||||||
|
-#ifndef SHARED
|
||||||
|
_dl_debug_initialize (0, LM_ID_BASE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
diff --git a/elf/Versions b/elf/Versions
|
||||||
|
index 164682eaeaa9a1da..bb6697647b397772 100644
|
||||||
|
--- a/elf/Versions
|
||||||
|
+++ b/elf/Versions
|
||||||
|
@@ -58,7 +58,7 @@ ld {
|
||||||
|
_dl_argv; _dl_find_dso_for_object; _dl_get_tls_static_info;
|
||||||
|
_dl_deallocate_tls; _dl_make_stack_executable;
|
||||||
|
_dl_rtld_di_serinfo; _dl_starting_up; _dl_fatal_printf;
|
||||||
|
- _dl_audit_symbind_alt;
|
||||||
|
+ _dl_audit_symbind_alt; _dl_audit_preinit;
|
||||||
|
_rtld_global; _rtld_global_ro;
|
||||||
|
|
||||||
|
# Only here for gdb while a better method is developed.
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index a21530f30bc5524b..0b6fac8e48877c93 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -108,6 +108,21 @@ _dl_audit_objclose (struct link_map *l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+_dl_audit_preinit (struct link_map *l)
|
||||||
|
+{
|
||||||
|
+ if (__glibc_likely (GLRO(dl_naudit) == 0))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->preinit != NULL)
|
||||||
|
+ afct->preinit (&link_map_audit_state (l, cnt)->cookie);
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
_dl_audit_symbind_alt (struct link_map *l, const ElfW(Sym) *ref, void **value,
|
||||||
|
lookup_t result)
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 61f1dfb3f79a613a..91193a036fc5c6ef 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1399,6 +1399,9 @@ void _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
|
||||||
|
void _dl_audit_objclose (struct link_map *l)
|
||||||
|
attribute_hidden;
|
||||||
|
|
||||||
|
+/* Call the la_preinit from the audit modules for the link_map L. */
|
||||||
|
+void _dl_audit_preinit (struct link_map *l);
|
||||||
|
+
|
||||||
|
/* Call the la_symbind{32,64} from the audit modules for the link_map L. */
|
||||||
|
void _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
const ElfW(Sym) *defsym, DL_FIXUP_VALUE_TYPE *value,
|
206
glibc-upstream-2.34-148.patch
Normal file
206
glibc-upstream-2.34-148.patch
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
commit fd9c4e8a1b72fa1372855051217f9480680d882a
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Thu Jul 22 17:45:33 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_pltenter
|
||||||
|
|
||||||
|
It consolidates the code required to call la_pltenter audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit eff687e8462b0eaf65992a6031b54a4b1cd16796)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 0b6fac8e48877c93..15250c67e8ac1658 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -17,7 +17,9 @@
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
+#include <link.h>
|
||||||
|
#include <ldsodefs.h>
|
||||||
|
+#include <dl-machine.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_dl_audit_activity_map (struct link_map *l, int action)
|
||||||
|
@@ -243,3 +245,78 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
reloc_result->flags = flags;
|
||||||
|
*value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+_dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
+ DL_FIXUP_VALUE_TYPE *value, void *regs, long int *framesize)
|
||||||
|
+{
|
||||||
|
+ /* Don't do anything if no auditor wants to intercept this call. */
|
||||||
|
+ if (GLRO(dl_naudit) == 0
|
||||||
|
+ || (reloc_result->enterexit & LA_SYMB_NOPLTENTER))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ /* Sanity check: DL_FIXUP_VALUE_CODE_ADDR (value) should have been
|
||||||
|
+ initialized earlier in this function or in another thread. */
|
||||||
|
+ assert (DL_FIXUP_VALUE_CODE_ADDR (*value) != 0);
|
||||||
|
+ ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
|
||||||
|
+ l_info[DT_SYMTAB])
|
||||||
|
+ + reloc_result->boundndx);
|
||||||
|
+
|
||||||
|
+ /* Set up the sym parameter. */
|
||||||
|
+ ElfW(Sym) sym = *defsym;
|
||||||
|
+ sym.st_value = DL_FIXUP_VALUE_ADDR (*value);
|
||||||
|
+
|
||||||
|
+ /* Get the symbol name. */
|
||||||
|
+ const char *strtab = (const void *) D_PTR (reloc_result->bound,
|
||||||
|
+ l_info[DT_STRTAB]);
|
||||||
|
+ const char *symname = strtab + sym.st_name;
|
||||||
|
+
|
||||||
|
+ /* Keep track of overwritten addresses. */
|
||||||
|
+ unsigned int flags = reloc_result->flags;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->ARCH_LA_PLTENTER != NULL
|
||||||
|
+ && (reloc_result->enterexit
|
||||||
|
+ & (LA_SYMB_NOPLTENTER << (2 * (cnt + 1)))) == 0)
|
||||||
|
+ {
|
||||||
|
+ long int new_framesize = -1;
|
||||||
|
+ struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
+ struct auditstate *bound_state
|
||||||
|
+ = link_map_audit_state (reloc_result->bound, cnt);
|
||||||
|
+ uintptr_t new_value
|
||||||
|
+ = afct->ARCH_LA_PLTENTER (&sym, reloc_result->boundndx,
|
||||||
|
+ &l_state->cookie, &bound_state->cookie,
|
||||||
|
+ regs, &flags, symname, &new_framesize);
|
||||||
|
+ if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
+ {
|
||||||
|
+ flags |= LA_SYMB_ALTVALUE;
|
||||||
|
+ sym.st_value = new_value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Remember the results for every audit library and store a summary
|
||||||
|
+ in the first two bits. */
|
||||||
|
+ reloc_result->enterexit |= ((flags & (LA_SYMB_NOPLTENTER
|
||||||
|
+ | LA_SYMB_NOPLTEXIT))
|
||||||
|
+ << (2 * (cnt + 1)));
|
||||||
|
+
|
||||||
|
+ if ((reloc_result->enterexit & (LA_SYMB_NOPLTEXIT
|
||||||
|
+ << (2 * (cnt + 1))))
|
||||||
|
+ == 0 && new_framesize != -1 && *framesize != -2)
|
||||||
|
+ {
|
||||||
|
+ /* If this is the first call providing information, use it. */
|
||||||
|
+ if (*framesize == -1)
|
||||||
|
+ *framesize = new_framesize;
|
||||||
|
+ /* If two pltenter calls provide conflicting information, use
|
||||||
|
+ the larger value. */
|
||||||
|
+ else if (new_framesize != *framesize)
|
||||||
|
+ *framesize = MAX (new_framesize, *framesize);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ *value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
+}
|
||||||
|
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
|
||||||
|
index c4413c9165cec8cb..dfedeaf2dd1c7253 100644
|
||||||
|
--- a/elf/dl-runtime.c
|
||||||
|
+++ b/elf/dl-runtime.c
|
||||||
|
@@ -320,78 +320,7 @@ _dl_profile_fixup (
|
||||||
|
#ifdef SHARED
|
||||||
|
/* Auditing checkpoint: report the PLT entering and allow the
|
||||||
|
auditors to change the value. */
|
||||||
|
- if (GLRO(dl_naudit) > 0
|
||||||
|
- /* Don't do anything if no auditor wants to intercept this call. */
|
||||||
|
- && (reloc_result->enterexit & LA_SYMB_NOPLTENTER) == 0)
|
||||||
|
- {
|
||||||
|
- /* Sanity check: DL_FIXUP_VALUE_CODE_ADDR (value) should have been
|
||||||
|
- initialized earlier in this function or in another thread. */
|
||||||
|
- assert (DL_FIXUP_VALUE_CODE_ADDR (value) != 0);
|
||||||
|
- ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
|
||||||
|
- l_info[DT_SYMTAB])
|
||||||
|
- + reloc_result->boundndx);
|
||||||
|
-
|
||||||
|
- /* Set up the sym parameter. */
|
||||||
|
- ElfW(Sym) sym = *defsym;
|
||||||
|
- sym.st_value = DL_FIXUP_VALUE_ADDR (value);
|
||||||
|
-
|
||||||
|
- /* Get the symbol name. */
|
||||||
|
- const char *strtab = (const void *) D_PTR (reloc_result->bound,
|
||||||
|
- l_info[DT_STRTAB]);
|
||||||
|
- const char *symname = strtab + sym.st_name;
|
||||||
|
-
|
||||||
|
- /* Keep track of overwritten addresses. */
|
||||||
|
- unsigned int flags = reloc_result->flags;
|
||||||
|
-
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->ARCH_LA_PLTENTER != NULL
|
||||||
|
- && (reloc_result->enterexit
|
||||||
|
- & (LA_SYMB_NOPLTENTER << (2 * (cnt + 1)))) == 0)
|
||||||
|
- {
|
||||||
|
- long int new_framesize = -1;
|
||||||
|
- struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
- struct auditstate *bound_state
|
||||||
|
- = link_map_audit_state (reloc_result->bound, cnt);
|
||||||
|
- uintptr_t new_value
|
||||||
|
- = afct->ARCH_LA_PLTENTER (&sym, reloc_result->boundndx,
|
||||||
|
- &l_state->cookie,
|
||||||
|
- &bound_state->cookie,
|
||||||
|
- regs, &flags, symname,
|
||||||
|
- &new_framesize);
|
||||||
|
- if (new_value != (uintptr_t) sym.st_value)
|
||||||
|
- {
|
||||||
|
- flags |= LA_SYMB_ALTVALUE;
|
||||||
|
- sym.st_value = new_value;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Remember the results for every audit library and
|
||||||
|
- store a summary in the first two bits. */
|
||||||
|
- reloc_result->enterexit
|
||||||
|
- |= ((flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT))
|
||||||
|
- << (2 * (cnt + 1)));
|
||||||
|
-
|
||||||
|
- if ((reloc_result->enterexit & (LA_SYMB_NOPLTEXIT
|
||||||
|
- << (2 * (cnt + 1))))
|
||||||
|
- == 0 && new_framesize != -1 && framesize != -2)
|
||||||
|
- {
|
||||||
|
- /* If this is the first call providing information,
|
||||||
|
- use it. */
|
||||||
|
- if (framesize == -1)
|
||||||
|
- framesize = new_framesize;
|
||||||
|
- /* If two pltenter calls provide conflicting information,
|
||||||
|
- use the larger value. */
|
||||||
|
- else if (new_framesize != framesize)
|
||||||
|
- framesize = MAX (new_framesize, framesize);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
- }
|
||||||
|
+ _dl_audit_pltenter (l, reloc_result, &value, regs, &framesize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Store the frame size information. */
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 91193a036fc5c6ef..ea187dd266f14e06 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1411,6 +1411,10 @@ void _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
void _dl_audit_symbind_alt (struct link_map *l, const ElfW(Sym) *ref,
|
||||||
|
void **value, lookup_t result);
|
||||||
|
rtld_hidden_proto (_dl_audit_symbind_alt)
|
||||||
|
+void _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
+ DL_FIXUP_VALUE_TYPE *value, void *regs,
|
||||||
|
+ long int *framesize)
|
||||||
|
+ attribute_hidden;
|
||||||
|
#endif /* SHARED */
|
||||||
|
|
||||||
|
#if PTHREAD_IN_LIBC && defined SHARED
|
715
glibc-upstream-2.34-149.patch
Normal file
715
glibc-upstream-2.34-149.patch
Normal file
@ -0,0 +1,715 @@
|
|||||||
|
commit a8e211daea6bdb505b10319ed3492e7d871c1e75
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Thu Jul 22 18:02:42 2021 -0300
|
||||||
|
|
||||||
|
elf: Add _dl_audit_pltexit
|
||||||
|
|
||||||
|
It consolidates the code required to call la_pltexit audit
|
||||||
|
callback.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 8c0664e2b861fd3789602cc0b0b1922b0e20cb3a)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
sysdeps/hppa/dl-runtime.c
|
||||||
|
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 15250c67e8ac1658..152712b12fed6de2 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -20,6 +20,8 @@
|
||||||
|
#include <link.h>
|
||||||
|
#include <ldsodefs.h>
|
||||||
|
#include <dl-machine.h>
|
||||||
|
+#include <dl-runtime.h>
|
||||||
|
+#include <dl-fixup-attribute.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_dl_audit_activity_map (struct link_map *l, int action)
|
||||||
|
@@ -320,3 +322,48 @@ _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
|
||||||
|
*value = DL_FIXUP_ADDR_VALUE (sym.st_value);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
|
||||||
|
+ const void *inregs, void *outregs)
|
||||||
|
+{
|
||||||
|
+ const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
|
||||||
|
+
|
||||||
|
+ /* This is the address in the array where we store the result of previous
|
||||||
|
+ relocations. */
|
||||||
|
+ // XXX Maybe the bound information must be stored on the stack since
|
||||||
|
+ // XXX with bind_not a new value could have been stored in the meantime.
|
||||||
|
+ struct reloc_result *reloc_result =
|
||||||
|
+ &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
|
||||||
|
+ ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
|
||||||
|
+ l_info[DT_SYMTAB])
|
||||||
|
+ + reloc_result->boundndx);
|
||||||
|
+
|
||||||
|
+ /* Set up the sym parameter. */
|
||||||
|
+ ElfW(Sym) sym = *defsym;
|
||||||
|
+ sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr);
|
||||||
|
+
|
||||||
|
+ /* Get the symbol name. */
|
||||||
|
+ const char *strtab = (const void *) D_PTR (reloc_result->bound,
|
||||||
|
+ l_info[DT_STRTAB]);
|
||||||
|
+ const char *symname = strtab + sym.st_name;
|
||||||
|
+
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ if (afct->ARCH_LA_PLTEXIT != NULL
|
||||||
|
+ && (reloc_result->enterexit
|
||||||
|
+ & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0)
|
||||||
|
+ {
|
||||||
|
+ struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
+ struct auditstate *bound_state
|
||||||
|
+ = link_map_audit_state (reloc_result->bound, cnt);
|
||||||
|
+ afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx,
|
||||||
|
+ &l_state->cookie, &bound_state->cookie,
|
||||||
|
+ inregs, outregs, symname);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
|
||||||
|
index dfedeaf2dd1c7253..e42f6e8b8dfca08e 100644
|
||||||
|
--- a/elf/dl-runtime.c
|
||||||
|
+++ b/elf/dl-runtime.c
|
||||||
|
@@ -16,8 +16,6 @@
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
-#define IN_DL_RUNTIME 1 /* This can be tested in dl-machine.h. */
|
||||||
|
-
|
||||||
|
#include <alloca.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
@@ -31,19 +29,6 @@
|
||||||
|
#include <dl-runtime.h>
|
||||||
|
|
||||||
|
|
||||||
|
-#if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
|
||||||
|
- || ELF_MACHINE_NO_REL
|
||||||
|
-# define PLTREL ElfW(Rela)
|
||||||
|
-#else
|
||||||
|
-# define PLTREL ElfW(Rel)
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
-/* The fixup functions might have need special attributes. If none
|
||||||
|
- are provided define the macro as empty. */
|
||||||
|
-#ifndef ARCH_FIXUP_ATTRIBUTE
|
||||||
|
-# define ARCH_FIXUP_ATTRIBUTE
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
/* This function is called through a special trampoline from the PLT the
|
||||||
|
first time each PLT entry is called. We must perform the relocation
|
||||||
|
specified in the PLT of the given shared object, and return the resolved
|
||||||
|
@@ -52,7 +37,7 @@
|
||||||
|
function. */
|
||||||
|
|
||||||
|
DL_FIXUP_VALUE_TYPE
|
||||||
|
-attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+attribute_hidden __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
_dl_fixup (
|
||||||
|
# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
|
||||||
|
ELF_MACHINE_RUNTIME_FIXUP_ARGS,
|
||||||
|
@@ -148,7 +133,8 @@ _dl_fixup (
|
||||||
|
|
||||||
|
#ifndef PROF
|
||||||
|
DL_FIXUP_VALUE_TYPE
|
||||||
|
-__attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+__attribute ((noinline))
|
||||||
|
+DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
_dl_profile_fixup (
|
||||||
|
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
|
||||||
|
ELF_MACHINE_RUNTIME_FIXUP_ARGS,
|
||||||
|
@@ -332,52 +318,3 @@ _dl_profile_fixup (
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PROF */
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-#include <stdio.h>
|
||||||
|
-void
|
||||||
|
-ARCH_FIXUP_ATTRIBUTE
|
||||||
|
-_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
|
||||||
|
- const void *inregs, void *outregs)
|
||||||
|
-{
|
||||||
|
-#ifdef SHARED
|
||||||
|
- const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
|
||||||
|
-
|
||||||
|
- /* This is the address in the array where we store the result of previous
|
||||||
|
- relocations. */
|
||||||
|
- // XXX Maybe the bound information must be stored on the stack since
|
||||||
|
- // XXX with bind_not a new value could have been stored in the meantime.
|
||||||
|
- struct reloc_result *reloc_result =
|
||||||
|
- &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
|
||||||
|
- ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
|
||||||
|
- l_info[DT_SYMTAB])
|
||||||
|
- + reloc_result->boundndx);
|
||||||
|
-
|
||||||
|
- /* Set up the sym parameter. */
|
||||||
|
- ElfW(Sym) sym = *defsym;
|
||||||
|
- sym.st_value = DL_FIXUP_VALUE_ADDR (reloc_result->addr);
|
||||||
|
-
|
||||||
|
- /* Get the symbol name. */
|
||||||
|
- const char *strtab = (const void *) D_PTR (reloc_result->bound,
|
||||||
|
- l_info[DT_STRTAB]);
|
||||||
|
- const char *symname = strtab + sym.st_name;
|
||||||
|
-
|
||||||
|
- struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
- for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
- {
|
||||||
|
- if (afct->ARCH_LA_PLTEXIT != NULL
|
||||||
|
- && (reloc_result->enterexit
|
||||||
|
- & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0)
|
||||||
|
- {
|
||||||
|
- struct auditstate *l_state = link_map_audit_state (l, cnt);
|
||||||
|
- struct auditstate *bound_state
|
||||||
|
- = link_map_audit_state (reloc_result->bound, cnt);
|
||||||
|
- afct->ARCH_LA_PLTEXIT (&sym, reloc_result->boundndx,
|
||||||
|
- &l_state->cookie, &bound_state->cookie,
|
||||||
|
- inregs, outregs, symname);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- afct = afct->next;
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
-}
|
||||||
|
diff --git a/elf/dl-support.c b/elf/dl-support.c
|
||||||
|
index c5ee5d33aa7e1d65..f29dc965f4d10648 100644
|
||||||
|
--- a/elf/dl-support.c
|
||||||
|
+++ b/elf/dl-support.c
|
||||||
|
@@ -437,3 +437,11 @@ _dl_get_dl_main_map (void)
|
||||||
|
return &_dl_main_map;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+
|
||||||
|
+/* This is used by _dl_runtime_profile, not used on static code. */
|
||||||
|
+void
|
||||||
|
+DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+_dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg,
|
||||||
|
+ const void *inregs, void *outregs)
|
||||||
|
+{
|
||||||
|
+}
|
||||||
|
diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S
|
||||||
|
index a7e9267c1c6a4863..9b352b1d0f7d62e7 100644
|
||||||
|
--- a/sysdeps/aarch64/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/aarch64/dl-trampoline.S
|
||||||
|
@@ -293,7 +293,7 @@ _dl_runtime_profile:
|
||||||
|
ldp x0, x1, [x29, #OFFSET_SAVED_CALL_X0]
|
||||||
|
add x2, x29, #OFFSET_RG
|
||||||
|
add x3, x29, #OFFSET_RV
|
||||||
|
- bl _dl_call_pltexit
|
||||||
|
+ bl _dl_audit_pltexit
|
||||||
|
|
||||||
|
ldp x0, x1, [x29, #OFFSET_RV + DL_OFFSET_RV_X0]
|
||||||
|
ldp d0, d1, [x29, #OFFSET_RV + DL_OFFSET_RV_D0 + 16*0]
|
||||||
|
diff --git a/sysdeps/alpha/dl-trampoline.S b/sysdeps/alpha/dl-trampoline.S
|
||||||
|
index 9dfce5b0839dc122..55380d48ad8536ee 100644
|
||||||
|
--- a/sysdeps/alpha/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/alpha/dl-trampoline.S
|
||||||
|
@@ -187,7 +187,7 @@ _dl_runtime_profile_new:
|
||||||
|
jsr $26, ($27), 0
|
||||||
|
ldgp $29, 0($26)
|
||||||
|
|
||||||
|
- /* Set up for call to _dl_call_pltexit. */
|
||||||
|
+ /* Set up for call to _dl_audit_pltexit. */
|
||||||
|
ldq $16, 16*8($15)
|
||||||
|
ldq $17, 17*8($15)
|
||||||
|
stq $0, 16*8($15)
|
||||||
|
@@ -196,7 +196,7 @@ _dl_runtime_profile_new:
|
||||||
|
lda $19, 16*8($15)
|
||||||
|
stt $f0, 18*8($15)
|
||||||
|
stt $f1, 19*8($15)
|
||||||
|
- bsr $26, _dl_call_pltexit !samegp
|
||||||
|
+ bsr $26, _dl_audit_pltexit !samegp
|
||||||
|
|
||||||
|
mov $15, $30
|
||||||
|
cfi_def_cfa_register (30)
|
||||||
|
@@ -518,7 +518,7 @@ _dl_runtime_profile_old:
|
||||||
|
jsr $26, ($27), 0
|
||||||
|
ldgp $29, 0($26)
|
||||||
|
|
||||||
|
- /* Set up for call to _dl_call_pltexit. */
|
||||||
|
+ /* Set up for call to _dl_audit_pltexit. */
|
||||||
|
ldq $16, 48*8($15)
|
||||||
|
ldq $17, 49*8($15)
|
||||||
|
stq $0, 46*8($15)
|
||||||
|
@@ -527,7 +527,7 @@ _dl_runtime_profile_old:
|
||||||
|
lda $19, 46*8($15)
|
||||||
|
stt $f0, 48*8($15)
|
||||||
|
stt $f1, 49*8($15)
|
||||||
|
- bsr $26, _dl_call_pltexit !samegp
|
||||||
|
+ bsr $26, _dl_audit_pltexit !samegp
|
||||||
|
|
||||||
|
mov $15, $30
|
||||||
|
cfi_def_cfa_register (30)
|
||||||
|
diff --git a/sysdeps/arm/dl-machine-rel.h b/sysdeps/arm/dl-machine-rel.h
|
||||||
|
index bec114706cd027a4..a9ee25a6b1d381ac 100644
|
||||||
|
--- a/sysdeps/arm/dl-machine-rel.h
|
||||||
|
+++ b/sysdeps/arm/dl-machine-rel.h
|
||||||
|
@@ -28,4 +28,6 @@
|
||||||
|
Prelinked libraries may use Elf32_Rela though. */
|
||||||
|
#define ELF_MACHINE_PLT_REL 1
|
||||||
|
|
||||||
|
+#define PLTREL ElfW(Rel)
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/sysdeps/arm/dl-trampoline.S b/sysdeps/arm/dl-trampoline.S
|
||||||
|
index 70105308ca7df934..a2d322706db77981 100644
|
||||||
|
--- a/sysdeps/arm/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/arm/dl-trampoline.S
|
||||||
|
@@ -194,7 +194,7 @@ _dl_runtime_profile:
|
||||||
|
ldmia ip, {r0,r1}
|
||||||
|
add r2, r7, #72
|
||||||
|
add r3, r7, #0
|
||||||
|
- bl _dl_call_pltexit
|
||||||
|
+ bl _dl_audit_pltexit
|
||||||
|
|
||||||
|
@ Return to caller.
|
||||||
|
ldmia r7, {r0-r3}
|
||||||
|
diff --git a/sysdeps/generic/dl-fixup-attribute.h b/sysdeps/generic/dl-fixup-attribute.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..aa92169b709b3fea
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/sysdeps/generic/dl-fixup-attribute.h
|
||||||
|
@@ -0,0 +1,24 @@
|
||||||
|
+/* ABI specifics for lazy resolution functions.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+#ifndef _DL_FIXUP_ATTRIBUTE_H
|
||||||
|
+#define _DL_FIXUP_ATTRIBUTE_H
|
||||||
|
+
|
||||||
|
+#define DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
diff --git a/sysdeps/generic/dl-machine-rel.h b/sysdeps/generic/dl-machine-rel.h
|
||||||
|
index 9167a1dffc715704..9d5b7bb749e69e63 100644
|
||||||
|
--- a/sysdeps/generic/dl-machine-rel.h
|
||||||
|
+++ b/sysdeps/generic/dl-machine-rel.h
|
||||||
|
@@ -23,5 +23,7 @@
|
||||||
|
#define ELF_MACHINE_NO_REL 1
|
||||||
|
/* Defined if the architecture supports Elf{32,64}_Rela relocations. */
|
||||||
|
#define ELF_MACHINE_NO_RELA 0
|
||||||
|
+/* Used to calculate the index of link_map l_reloc_result. */
|
||||||
|
+#define PLTREL ElfW(Rela)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index ea187dd266f14e06..686f0a7b9709eb10 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -35,6 +35,7 @@
|
||||||
|
#include <link.h>
|
||||||
|
#include <dl-lookupcfg.h>
|
||||||
|
#include <dl-sysdep.h>
|
||||||
|
+#include <dl-fixup-attribute.h>
|
||||||
|
#include <libc-lock.h>
|
||||||
|
#include <hp-timing.h>
|
||||||
|
#include <tls.h>
|
||||||
|
@@ -1415,6 +1416,11 @@ void _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
DL_FIXUP_VALUE_TYPE *value, void *regs,
|
||||||
|
long int *framesize)
|
||||||
|
attribute_hidden;
|
||||||
|
+void DL_ARCH_FIXUP_ATTRIBUTE _dl_audit_pltexit (struct link_map *l,
|
||||||
|
+ ElfW(Word) reloc_arg,
|
||||||
|
+ const void *inregs,
|
||||||
|
+ void *outregs)
|
||||||
|
+ attribute_hidden;
|
||||||
|
#endif /* SHARED */
|
||||||
|
|
||||||
|
#if PTHREAD_IN_LIBC && defined SHARED
|
||||||
|
diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c
|
||||||
|
index a71b5b2013abf723..8699171930f51489 100644
|
||||||
|
--- a/sysdeps/hppa/dl-runtime.c
|
||||||
|
+++ b/sysdeps/hppa/dl-runtime.c
|
||||||
|
@@ -25,7 +25,7 @@
|
||||||
|
return that to the caller. The caller will continue on to call
|
||||||
|
_dl_fixup with the relocation offset. */
|
||||||
|
|
||||||
|
-ElfW(Word) __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+ElfW(Word) __attribute ((noinline)) DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
_dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
|
||||||
|
{
|
||||||
|
Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type;
|
||||||
|
diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S
|
||||||
|
index cb18ea7eabba41ed..c54879bae0148012 100644
|
||||||
|
--- a/sysdeps/hppa/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/hppa/dl-trampoline.S
|
||||||
|
@@ -300,7 +300,7 @@ L(cont):
|
||||||
|
ldw -4(%sp),%r1
|
||||||
|
copy %r1, %sp
|
||||||
|
|
||||||
|
- /* Arguments to _dl_call_pltexit */
|
||||||
|
+ /* Arguments to _dl_audit_pltexit */
|
||||||
|
ldw -116(%sp), %r26 /* (1) got[1] == struct link_map */
|
||||||
|
ldw -120(%sp), %r25 /* (2) reloc offsets */
|
||||||
|
ldo -56(%sp), %r24 /* (3) *La_hppa_regs */
|
||||||
|
@@ -312,8 +312,8 @@ L(cont):
|
||||||
|
ldo -128(%sp), %r1
|
||||||
|
fstd %fr4,0(%r1)
|
||||||
|
|
||||||
|
- /* Call _dl_call_pltexit */
|
||||||
|
- bl _dl_call_pltexit,%rp
|
||||||
|
+ /* Call _dl_audit_pltexit */
|
||||||
|
+ bl _dl_audit_pltexit,%rp
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* Restore *La_hppa_retval */
|
||||||
|
diff --git a/sysdeps/i386/dl-fixup-attribute.h b/sysdeps/i386/dl-fixup-attribute.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..c10e9936f4db7254
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/sysdeps/i386/dl-fixup-attribute.h
|
||||||
|
@@ -0,0 +1,30 @@
|
||||||
|
+/* ABI specifics for lazy resolution functions. i386 version.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+#ifndef _DL_FIXUP_ATTRIBUTE_H
|
||||||
|
+#define _DL_FIXUP_ATTRIBUTE_H
|
||||||
|
+
|
||||||
|
+/* We cannot use this scheme for profiling because the _mcount call destroys
|
||||||
|
+ the passed register information. */
|
||||||
|
+#ifndef PROF
|
||||||
|
+# define DL_ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused))
|
||||||
|
+#else
|
||||||
|
+# define DL_ARCH_FIXUP_ATTRIBUTE
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
diff --git a/sysdeps/i386/dl-machine-rel.h b/sysdeps/i386/dl-machine-rel.h
|
||||||
|
index 7ac46f78a69fbf98..bb3480d45415d761 100644
|
||||||
|
--- a/sysdeps/i386/dl-machine-rel.h
|
||||||
|
+++ b/sysdeps/i386/dl-machine-rel.h
|
||||||
|
@@ -28,4 +28,6 @@
|
||||||
|
Prelinked libraries may use Elf32_Rela though. */
|
||||||
|
#define ELF_MACHINE_PLT_REL 1
|
||||||
|
|
||||||
|
+#define PLTREL ElfW(Rel)
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
|
||||||
|
index c55c9a3d64bed1f2..5483e903d81e85c6 100644
|
||||||
|
--- a/sysdeps/i386/dl-machine.h
|
||||||
|
+++ b/sysdeps/i386/dl-machine.h
|
||||||
|
@@ -122,29 +122,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
|
||||||
|
return lazy;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#ifdef IN_DL_RUNTIME
|
||||||
|
-
|
||||||
|
-# ifndef PROF
|
||||||
|
-/* We add a declaration of this function here so that in dl-runtime.c
|
||||||
|
- the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters
|
||||||
|
- in registers.
|
||||||
|
-
|
||||||
|
- We cannot use this scheme for profiling because the _mcount call
|
||||||
|
- destroys the passed register information. */
|
||||||
|
-#define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused))
|
||||||
|
-
|
||||||
|
-extern ElfW(Addr) _dl_fixup (struct link_map *l,
|
||||||
|
- ElfW(Word) reloc_offset)
|
||||||
|
- ARCH_FIXUP_ATTRIBUTE;
|
||||||
|
-extern ElfW(Addr) _dl_profile_fixup (struct link_map *l,
|
||||||
|
- ElfW(Word) reloc_offset,
|
||||||
|
- ElfW(Addr) retaddr, void *regs,
|
||||||
|
- long int *framesizep)
|
||||||
|
- ARCH_FIXUP_ATTRIBUTE;
|
||||||
|
-# endif
|
||||||
|
-
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
/* Mask identifying addresses reserved for the user program,
|
||||||
|
where the dynamic linker should not map anything. */
|
||||||
|
#define ELF_MACHINE_USER_ADDRESS_MASK 0xf0000000UL
|
||||||
|
diff --git a/sysdeps/i386/dl-trampoline.S b/sysdeps/i386/dl-trampoline.S
|
||||||
|
index b5ec0326df94f0fd..3a33051c52da9cde 100644
|
||||||
|
--- a/sysdeps/i386/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/i386/dl-trampoline.S
|
||||||
|
@@ -265,7 +265,7 @@ _dl_runtime_profile:
|
||||||
|
movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax
|
||||||
|
# PLT1
|
||||||
|
movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx
|
||||||
|
- call _dl_call_pltexit
|
||||||
|
+ call _dl_audit_pltexit
|
||||||
|
movl LRV_EAX_OFFSET(%esp), %eax
|
||||||
|
movl LRV_EDX_OFFSET(%esp), %edx
|
||||||
|
fldt LRV_ST1_OFFSET(%esp)
|
||||||
|
diff --git a/sysdeps/ia64/dl-trampoline.S b/sysdeps/ia64/dl-trampoline.S
|
||||||
|
index 3053405a3a21d62e..11e86932c75d5b6b 100644
|
||||||
|
--- a/sysdeps/ia64/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/ia64/dl-trampoline.S
|
||||||
|
@@ -133,7 +133,7 @@ END(_dl_runtime_resolve)
|
||||||
|
|
||||||
|
|
||||||
|
/* The fourth argument to _dl_profile_fixup and the third one to
|
||||||
|
- _dl_call_pltexit are a pointer to La_ia64_regs:
|
||||||
|
+ _dl_audit_pltexit are a pointer to La_ia64_regs:
|
||||||
|
|
||||||
|
8byte r8
|
||||||
|
8byte r9
|
||||||
|
@@ -159,7 +159,7 @@ END(_dl_runtime_resolve)
|
||||||
|
8byte sp
|
||||||
|
|
||||||
|
The fifth argument to _dl_profile_fixup is a pointer to long int.
|
||||||
|
- The fourth argument to _dl_call_pltexit is a pointer to
|
||||||
|
+ The fourth argument to _dl_audit_pltexit is a pointer to
|
||||||
|
La_ia64_retval:
|
||||||
|
|
||||||
|
8byte r8
|
||||||
|
@@ -261,7 +261,7 @@ ENTRY(_dl_runtime_profile)
|
||||||
|
}
|
||||||
|
{ .mii
|
||||||
|
mov r18 = ar.unat /* save it in La_ia64_regs */
|
||||||
|
- mov loc7 = out3 /* save it for _dl_call_pltexit */
|
||||||
|
+ mov loc7 = out3 /* save it for _dl_audit_pltexit */
|
||||||
|
mov loc5 = r11 /* preserve language specific register */
|
||||||
|
}
|
||||||
|
{ .mmi
|
||||||
|
@@ -272,7 +272,7 @@ ENTRY(_dl_runtime_profile)
|
||||||
|
}
|
||||||
|
{ .mii
|
||||||
|
mov ar.unat = r17 /* restore it for function call */
|
||||||
|
- mov loc8 = r16 /* save it for _dl_call_pltexit */
|
||||||
|
+ mov loc8 = r16 /* save it for _dl_audit_pltexit */
|
||||||
|
nop.i 0x0
|
||||||
|
}
|
||||||
|
{ .mmi
|
||||||
|
@@ -291,7 +291,7 @@ ENTRY(_dl_runtime_profile)
|
||||||
|
{ .mmi
|
||||||
|
stf.spill [r2] = f14, 32
|
||||||
|
stf.spill [r3] = f15, 24
|
||||||
|
- mov loc9 = out1 /* save it for _dl_call_pltexit */
|
||||||
|
+ mov loc9 = out1 /* save it for _dl_audit_pltexit */
|
||||||
|
;;
|
||||||
|
}
|
||||||
|
{ .mmb
|
||||||
|
@@ -426,7 +426,7 @@ ENTRY(_dl_runtime_profile)
|
||||||
|
br.call.sptk.many b0 = b6
|
||||||
|
}
|
||||||
|
{ .mii
|
||||||
|
- /* Prepare stack for _dl_call_pltexit. Loc10 has the original
|
||||||
|
+ /* Prepare stack for _dl_audit_pltexit. Loc10 has the original
|
||||||
|
stack pointer. */
|
||||||
|
adds r12 = -PLTEXIT_FRAME_SIZE, loc10
|
||||||
|
adds r2 = -(PLTEXIT_FRAME_SIZE - 16), loc10
|
||||||
|
@@ -461,14 +461,14 @@ ENTRY(_dl_runtime_profile)
|
||||||
|
{ .mmi
|
||||||
|
stf.spill [r2] = f12, 32
|
||||||
|
stf.spill [r3] = f13, 32
|
||||||
|
- /* We need to restore gp for _dl_call_pltexit. */
|
||||||
|
+ /* We need to restore gp for _dl_audit_pltexit. */
|
||||||
|
mov gp = loc11
|
||||||
|
;;
|
||||||
|
}
|
||||||
|
{ .mmb
|
||||||
|
stf.spill [r2] = f14
|
||||||
|
stf.spill [r3] = f15
|
||||||
|
- br.call.sptk.many b0 = _dl_call_pltexit
|
||||||
|
+ br.call.sptk.many b0 = _dl_audit_pltexit
|
||||||
|
}
|
||||||
|
{ .mmi
|
||||||
|
/* Load all the non-floating and floating return values. Skip
|
||||||
|
diff --git a/sysdeps/m68k/dl-trampoline.S b/sysdeps/m68k/dl-trampoline.S
|
||||||
|
index a51a5f7f573c6330..72bde664c31c4256 100644
|
||||||
|
--- a/sysdeps/m68k/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/m68k/dl-trampoline.S
|
||||||
|
@@ -202,7 +202,7 @@ _dl_runtime_profile:
|
||||||
|
cfi_adjust_cfa_offset (4)
|
||||||
|
move.l (32+FPSPACE)(%sp), -(%sp)
|
||||||
|
cfi_adjust_cfa_offset (4)
|
||||||
|
- jbsr _dl_call_pltexit
|
||||||
|
+ jbsr _dl_audit_pltexit
|
||||||
|
lea 16(%sp), %sp
|
||||||
|
cfi_adjust_cfa_offset (-16)
|
||||||
|
move.l (%sp)+, %d0
|
||||||
|
diff --git a/sysdeps/mips/dl-machine-rel.h b/sysdeps/mips/dl-machine-rel.h
|
||||||
|
index ed396180412bc723..3d0dfec01f6b193e 100644
|
||||||
|
--- a/sysdeps/mips/dl-machine-rel.h
|
||||||
|
+++ b/sysdeps/mips/dl-machine-rel.h
|
||||||
|
@@ -22,5 +22,6 @@
|
||||||
|
#define ELF_MACHINE_PLT_REL 1
|
||||||
|
#define ELF_MACHINE_NO_REL 0
|
||||||
|
#define ELF_MACHINE_NO_RELA 0
|
||||||
|
+#define PLTREL ElfW(Rel)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/sysdeps/powerpc/powerpc64/dl-trampoline.S b/sysdeps/powerpc/powerpc64/dl-trampoline.S
|
||||||
|
index 61bd8571fcc93caa..97f0105ce780514e 100644
|
||||||
|
--- a/sysdeps/powerpc/powerpc64/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/powerpc/powerpc64/dl-trampoline.S
|
||||||
|
@@ -197,7 +197,7 @@ END(_dl_runtime_resolve)
|
||||||
|
#ifndef PROF
|
||||||
|
ENTRY (_dl_profile_resolve, 4)
|
||||||
|
/* Spill r30, r31 to preserve the link_map* and reloc_addr, in case we
|
||||||
|
- need to call _dl_call_pltexit. */
|
||||||
|
+ need to call _dl_audit_pltexit. */
|
||||||
|
std r31,-8(r1)
|
||||||
|
std r30,-16(r1)
|
||||||
|
/* We need to save the registers used to pass parameters, ie. r3 thru
|
||||||
|
@@ -452,7 +452,7 @@ L(restoreFXR2):
|
||||||
|
L(callpltexit):
|
||||||
|
addi r5,r1,INT_PARMS
|
||||||
|
addi r6,r1,INT_RTN
|
||||||
|
- bl JUMPTARGET(_dl_call_pltexit)
|
||||||
|
+ bl JUMPTARGET(_dl_audit_pltexit)
|
||||||
|
#ifndef SHARED
|
||||||
|
nop
|
||||||
|
#endif
|
||||||
|
diff --git a/sysdeps/s390/s390-32/dl-trampoline.h b/sysdeps/s390/s390-32/dl-trampoline.h
|
||||||
|
index c224a2b92832af9b..9e4cd1055fe6ab20 100644
|
||||||
|
--- a/sysdeps/s390/s390-32/dl-trampoline.h
|
||||||
|
+++ b/sysdeps/s390/s390-32/dl-trampoline.h
|
||||||
|
@@ -282,7 +282,7 @@ _dl_runtime_profile:
|
||||||
|
basr %r1,0
|
||||||
|
5: l %r14,7f-5b(%r1)
|
||||||
|
la %r5,CFA_OFF+RETVAL_OFF(%r12) # struct La_s390_32_retval *
|
||||||
|
- bas %r14,0(%r14,%r1) # call _dl_call_pltexit
|
||||||
|
+ bas %r14,0(%r14,%r1) # call _dl_audit_pltexit
|
||||||
|
|
||||||
|
lr %r15,%r12 # remove stack frame
|
||||||
|
# undef FRAME_SIZE
|
||||||
|
@@ -301,7 +301,7 @@ _dl_runtime_profile:
|
||||||
|
br %r14
|
||||||
|
|
||||||
|
6: .long _dl_profile_fixup - 0b
|
||||||
|
-7: .long _dl_call_pltexit - 5b
|
||||||
|
+7: .long _dl_audit_pltexit - 5b
|
||||||
|
cfi_endproc
|
||||||
|
.size _dl_runtime_profile, .-_dl_runtime_profile
|
||||||
|
# undef SIZEOF_STRUCT_LA_S390_32_REGS
|
||||||
|
diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h
|
||||||
|
index ae741a3bad5ec77e..6e5bad40459ec765 100644
|
||||||
|
--- a/sysdeps/s390/s390-64/dl-trampoline.h
|
||||||
|
+++ b/sysdeps/s390/s390-64/dl-trampoline.h
|
||||||
|
@@ -284,7 +284,7 @@ _dl_runtime_profile:
|
||||||
|
lmg %r2,%r4,CFA_OFF+PLT1_OFF(%r12) # r2, r3: args saved by PLT
|
||||||
|
# r4: struct La_s390_64_regs *
|
||||||
|
la %r5,CFA_OFF+RETVAL_OFF(%r12) # struct La_s390_64_retval *
|
||||||
|
- brasl %r14,_dl_call_pltexit
|
||||||
|
+ brasl %r14,_dl_audit_pltexit
|
||||||
|
|
||||||
|
lgr %r15,%r12 # remove stack frame
|
||||||
|
# undef FRAME_SIZE
|
||||||
|
diff --git a/sysdeps/sh/dl-trampoline.S b/sysdeps/sh/dl-trampoline.S
|
||||||
|
index 824ac84ba1830ce5..f9038cd10ed5286f 100644
|
||||||
|
--- a/sysdeps/sh/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/sh/dl-trampoline.S
|
||||||
|
@@ -423,8 +423,8 @@ _dl_runtime_profile:
|
||||||
|
.align 2
|
||||||
|
#ifdef SHARED
|
||||||
|
7: .long _GLOBAL_OFFSET_TABLE_
|
||||||
|
-8: .long _dl_call_pltexit@GOTOFF
|
||||||
|
+8: .long _dl_audit_pltexit@GOTOFF
|
||||||
|
#else
|
||||||
|
-8: .long _dl_call_pltexit
|
||||||
|
+8: .long _dl_audit_pltexit
|
||||||
|
#endif
|
||||||
|
.size _dl_runtime_profile, .-_dl_runtime_profile
|
||||||
|
diff --git a/sysdeps/sparc/sparc32/dl-trampoline.S b/sysdeps/sparc/sparc32/dl-trampoline.S
|
||||||
|
index 426f90c99a7ed369..2f64809731c865a2 100644
|
||||||
|
--- a/sysdeps/sparc/sparc32/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/sparc/sparc32/dl-trampoline.S
|
||||||
|
@@ -127,7 +127,7 @@ _dl_profile_invoke:
|
||||||
|
mov %l5, %o0
|
||||||
|
mov %l6, %o1
|
||||||
|
add %sp, (11 * 8), %o2
|
||||||
|
- call _dl_call_pltexit
|
||||||
|
+ call _dl_audit_pltexit
|
||||||
|
add %sp, ( 9 * 8), %o3
|
||||||
|
|
||||||
|
ldd [%sp + ( 9 * 8)], %i0
|
||||||
|
diff --git a/sysdeps/sparc/sparc64/dl-trampoline.S b/sysdeps/sparc/sparc64/dl-trampoline.S
|
||||||
|
index 8d59fa67209cd8ab..86605e37acd929fd 100644
|
||||||
|
--- a/sysdeps/sparc/sparc64/dl-trampoline.S
|
||||||
|
+++ b/sysdeps/sparc/sparc64/dl-trampoline.S
|
||||||
|
@@ -196,7 +196,7 @@ _dl_profile_invoke:
|
||||||
|
mov %l5, %o0
|
||||||
|
mov %l6, %o1
|
||||||
|
add %sp, STACK_BIAS + (24 * 8), %o2
|
||||||
|
- call _dl_call_pltexit
|
||||||
|
+ call _dl_audit_pltexit
|
||||||
|
add %sp, STACK_BIAS + (16 * 8), %o3
|
||||||
|
|
||||||
|
ldx [%sp + STACK_BIAS + (16 * 8)], %i0
|
||||||
|
diff --git a/sysdeps/x86_64/dl-runtime.h b/sysdeps/x86_64/dl-runtime.h
|
||||||
|
index 9c8d3977eee27069..19ba33ef30970c20 100644
|
||||||
|
--- a/sysdeps/x86_64/dl-runtime.h
|
||||||
|
+++ b/sysdeps/x86_64/dl-runtime.h
|
||||||
|
@@ -18,7 +18,7 @@
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
/* The ABI calls for the PLT stubs to pass the index of the relocation
|
||||||
|
- and not its offset. In _dl_profile_fixup and _dl_call_pltexit we
|
||||||
|
+ and not its offset. In _dl_profile_fixup and _dl_audit_pltexit we
|
||||||
|
also use the index. Therefore it is wasteful to compute the offset
|
||||||
|
in the trampoline just to reverse the operation immediately
|
||||||
|
afterwards. */
|
||||||
|
diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
|
||||||
|
index b9a12970cd6206ee..b5de7efff778559e 100644
|
||||||
|
--- a/sysdeps/x86_64/dl-trampoline.h
|
||||||
|
+++ b/sysdeps/x86_64/dl-trampoline.h
|
||||||
|
@@ -388,7 +388,7 @@ _dl_runtime_profile:
|
||||||
|
jns 3f
|
||||||
|
|
||||||
|
/* There's nothing in the frame size, so there
|
||||||
|
- will be no call to the _dl_call_pltexit. */
|
||||||
|
+ will be no call to the _dl_audit_pltexit. */
|
||||||
|
|
||||||
|
/* Get back registers content. */
|
||||||
|
movq LR_RCX_OFFSET(%rsp), %rcx
|
||||||
|
@@ -436,7 +436,7 @@ _dl_runtime_profile:
|
||||||
|
mov 24(%rbx), %RSP_LP # Drop the copied stack content
|
||||||
|
|
||||||
|
/* Now we have to prepare the La_x86_64_retval structure for the
|
||||||
|
- _dl_call_pltexit. The La_x86_64_regs is being pointed by rsp now,
|
||||||
|
+ _dl_audit_pltexit. The La_x86_64_regs is being pointed by rsp now,
|
||||||
|
so we just need to allocate the sizeof(La_x86_64_retval) space on
|
||||||
|
the stack, since the alignment has already been taken care of. */
|
||||||
|
# ifdef RESTORE_AVX
|
||||||
|
@@ -491,7 +491,7 @@ _dl_runtime_profile:
|
||||||
|
movq 24(%rbx), %rdx # La_x86_64_regs argument to %rdx.
|
||||||
|
movq 40(%rbx), %rsi # Copy args pushed by PLT in register.
|
||||||
|
movq 32(%rbx), %rdi # %rdi: link_map, %rsi: reloc_index
|
||||||
|
- call _dl_call_pltexit
|
||||||
|
+ call _dl_audit_pltexit
|
||||||
|
|
||||||
|
/* Restore return registers. */
|
||||||
|
movq LRV_RAX_OFFSET(%rsp), %rax
|
454
glibc-upstream-2.34-150.patch
Normal file
454
glibc-upstream-2.34-150.patch
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
commit 29496b3103ff13aa3c1d8b62552a98f39da0fe59
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Wed Jun 30 10:24:09 2021 -0300
|
||||||
|
|
||||||
|
elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)
|
||||||
|
|
||||||
|
The rtld-audit interfaces introduces a slowdown due to enabling
|
||||||
|
profiling instrumentation (as if LD_AUDIT implied LD_PROFILE).
|
||||||
|
However, instrumenting is only necessary if one of audit libraries
|
||||||
|
provides PLT callbacks (la_pltenter or la_pltexit symbols). Otherwise,
|
||||||
|
the slowdown can be avoided.
|
||||||
|
|
||||||
|
The following patch adjusts the logic that enables profiling to iterate
|
||||||
|
over all audit modules and check if any of those provides a PLT hook.
|
||||||
|
To keep la_symbind to work even without PLT callbacks, _dl_fixup now
|
||||||
|
calls the audit callback if the modules implements it.
|
||||||
|
|
||||||
|
Co-authored-by: Alexander Monakov <amonakov@ispras.ru>
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 063f9ba220f434c7f30dd65c4cff17c0c458a7cf)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
NEWS
|
||||||
|
elf/Makefile
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 85165c0591412a45..eab9d46b6165e6be 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -365,6 +365,7 @@ tests += \
|
||||||
|
tst-audit16 \
|
||||||
|
tst-audit17 \
|
||||||
|
tst-audit18 \
|
||||||
|
+ tst-audit19b \
|
||||||
|
tst-auditmany \
|
||||||
|
tst-auxobj \
|
||||||
|
tst-auxobj-dlopen \
|
||||||
|
@@ -454,6 +455,7 @@ tests-internal += \
|
||||||
|
neededtest2 \
|
||||||
|
neededtest3 \
|
||||||
|
neededtest4 \
|
||||||
|
+ tst-audit19a \
|
||||||
|
tst-create_format1 \
|
||||||
|
tst-dl-hwcaps_split \
|
||||||
|
tst-dlmopen2 \
|
||||||
|
@@ -626,6 +628,7 @@ modules-names = \
|
||||||
|
tst-audit12mod3 \
|
||||||
|
tst-audit13mod1 \
|
||||||
|
tst-audit18mod \
|
||||||
|
+ tst-audit19bmod \
|
||||||
|
tst-auditlogmod-1 \
|
||||||
|
tst-auditlogmod-2 \
|
||||||
|
tst-auditlogmod-3 \
|
||||||
|
@@ -644,6 +647,8 @@ modules-names = \
|
||||||
|
tst-auditmod11 \
|
||||||
|
tst-auditmod12 \
|
||||||
|
tst-auditmod18 \
|
||||||
|
+ tst-auditmod19a \
|
||||||
|
+ tst-auditmod19b \
|
||||||
|
tst-auxvalmod \
|
||||||
|
tst-big-note-lib \
|
||||||
|
tst-deep1mod1 \
|
||||||
|
@@ -2007,6 +2012,13 @@ $(objpfx)tst-audit18.out: $(objpfx)tst-auditmod18.so \
|
||||||
|
$(objpfx)tst-audit18mod.so
|
||||||
|
tst-audit18-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit19a.out: $(objpfx)tst-auditmod19a.so
|
||||||
|
+tst-audit19a-ENV = LD_AUDIT=$(objpfx)tst-auditmod19a.so
|
||||||
|
+
|
||||||
|
+$(objpfx)tst-audit19b.out: $(objpfx)tst-auditmod19b.so
|
||||||
|
+$(objpfx)tst-audit19b: $(objpfx)tst-audit19bmod.so
|
||||||
|
+tst-audit19b-ARGS = -- $(host-test-program-cmd)
|
||||||
|
+
|
||||||
|
# tst-sonamemove links against an older implementation of the library.
|
||||||
|
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
||||||
|
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
||||||
|
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
|
||||||
|
index 3447de7f3536cd70..5b69321bda1f2b27 100644
|
||||||
|
--- a/elf/dl-reloc.c
|
||||||
|
+++ b/elf/dl-reloc.c
|
||||||
|
@@ -205,12 +205,28 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||||
|
int skip_ifunc = reloc_mode & __RTLD_NOIFUNC;
|
||||||
|
|
||||||
|
#ifdef SHARED
|
||||||
|
+ bool consider_symbind = false;
|
||||||
|
/* If we are auditing, install the same handlers we need for profiling. */
|
||||||
|
if ((reloc_mode & __RTLD_AUDIT) == 0)
|
||||||
|
- consider_profiling |= GLRO(dl_audit) != NULL;
|
||||||
|
+ {
|
||||||
|
+ struct audit_ifaces *afct = GLRO(dl_audit);
|
||||||
|
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
|
||||||
|
+ {
|
||||||
|
+ /* Profiling is needed only if PLT hooks are provided. */
|
||||||
|
+ if (afct->ARCH_LA_PLTENTER != NULL
|
||||||
|
+ || afct->ARCH_LA_PLTEXIT != NULL)
|
||||||
|
+ consider_profiling = 1;
|
||||||
|
+ if (afct->symbind != NULL)
|
||||||
|
+ consider_symbind = true;
|
||||||
|
+
|
||||||
|
+ afct = afct->next;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
#elif defined PROF
|
||||||
|
/* Never use dynamic linker profiling for gprof profiling code. */
|
||||||
|
# define consider_profiling 0
|
||||||
|
+#else
|
||||||
|
+# define consider_symbind 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (l->l_relocated)
|
||||||
|
@@ -272,7 +288,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||||
|
ELF_DYNAMIC_RELOCATE (l, scope, lazy, consider_profiling, skip_ifunc);
|
||||||
|
|
||||||
|
#ifndef PROF
|
||||||
|
- if (__glibc_unlikely (consider_profiling)
|
||||||
|
+ if ((consider_profiling || consider_symbind)
|
||||||
|
&& l->l_info[DT_PLTRELSZ] != NULL)
|
||||||
|
{
|
||||||
|
/* Allocate the array which will contain the already found
|
||||||
|
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
|
||||||
|
index e42f6e8b8dfca08e..77a5cccdcbcb9293 100644
|
||||||
|
--- a/elf/dl-runtime.c
|
||||||
|
+++ b/elf/dl-runtime.c
|
||||||
|
@@ -124,6 +124,37 @@ _dl_fixup (
|
||||||
|
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0))
|
||||||
|
value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value));
|
||||||
|
|
||||||
|
+#ifdef SHARED
|
||||||
|
+ /* Auditing checkpoint: we have a new binding. Provide the auditing
|
||||||
|
+ libraries the possibility to change the value and tell us whether further
|
||||||
|
+ auditing is wanted.
|
||||||
|
+ The l_reloc_result is only allocated if there is an audit module which
|
||||||
|
+ provides a la_symbind. */
|
||||||
|
+ if (l->l_reloc_result != NULL)
|
||||||
|
+ {
|
||||||
|
+ /* This is the address in the array where we store the result of previous
|
||||||
|
+ relocations. */
|
||||||
|
+ struct reloc_result *reloc_result
|
||||||
|
+ = &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
|
||||||
|
+ unsigned int init = atomic_load_acquire (&reloc_result->init);
|
||||||
|
+ if (init == 0)
|
||||||
|
+ {
|
||||||
|
+ _dl_audit_symbind (l, reloc_result, sym, &value, result);
|
||||||
|
+
|
||||||
|
+ /* Store the result for later runs. */
|
||||||
|
+ if (__glibc_likely (! GLRO(dl_bind_not)))
|
||||||
|
+ {
|
||||||
|
+ reloc_result->addr = value;
|
||||||
|
+ /* Guarantee all previous writes complete before init is
|
||||||
|
+ updated. See CONCURRENCY NOTES below. */
|
||||||
|
+ atomic_store_release (&reloc_result->init, 1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ value = reloc_result->addr;
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/* Finally, fix up the plt itself. */
|
||||||
|
if (__glibc_unlikely (GLRO(dl_bind_not)))
|
||||||
|
return value;
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index b6bb46ca97b7972f..f632a767d7a269ef 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -1016,13 +1016,7 @@ ERROR: audit interface '%s' requires version %d (maximum supported version %d);
|
||||||
|
"la_objsearch\0"
|
||||||
|
"la_objopen\0"
|
||||||
|
"la_preinit\0"
|
||||||
|
-#if __ELF_NATIVE_CLASS == 32
|
||||||
|
- "la_symbind32\0"
|
||||||
|
-#elif __ELF_NATIVE_CLASS == 64
|
||||||
|
- "la_symbind64\0"
|
||||||
|
-#else
|
||||||
|
-# error "__ELF_NATIVE_CLASS must be defined"
|
||||||
|
-#endif
|
||||||
|
+ LA_SYMBIND "\0"
|
||||||
|
#define STRING(s) __STRING (s)
|
||||||
|
"la_" STRING (ARCH_LA_PLTENTER) "\0"
|
||||||
|
"la_" STRING (ARCH_LA_PLTEXIT) "\0"
|
||||||
|
diff --git a/elf/tst-audit19a.c b/elf/tst-audit19a.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..035cde9351c2711b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit19a.c
|
||||||
|
@@ -0,0 +1,38 @@
|
||||||
|
+/* Check if DT_AUDIT a module without la_plt{enter,exit} symbols does not incur
|
||||||
|
+ in profiling (BZ#15533).
|
||||||
|
+ 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 <link.h>
|
||||||
|
+#include <support/xdlfcn.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (void)
|
||||||
|
+{
|
||||||
|
+ void *h = xdlopen ("tst-auditmod19a.so", RTLD_NOW);
|
||||||
|
+
|
||||||
|
+ struct link_map *lmap;
|
||||||
|
+ TEST_VERIFY_EXIT (dlinfo (h, RTLD_DI_LINKMAP, &lmap) == 0);
|
||||||
|
+
|
||||||
|
+ /* The internal array is only allocated if profiling is enabled. */
|
||||||
|
+ TEST_VERIFY (lmap->l_reloc_result == NULL);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-audit19b.c b/elf/tst-audit19b.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..da015734f24e0d79
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit19b.c
|
||||||
|
@@ -0,0 +1,94 @@
|
||||||
|
+/* Check if DT_AUDIT a module with la_plt{enter,exit} call la_symbind
|
||||||
|
+ for lazy resolution.
|
||||||
|
+ 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 <getopt.h>
|
||||||
|
+#include <support/capture_subprocess.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+#include <support/xstdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdbool.h>
|
||||||
|
+
|
||||||
|
+static int restart;
|
||||||
|
+#define CMDLINE_OPTIONS \
|
||||||
|
+ { "restart", no_argument, &restart, 1 },
|
||||||
|
+
|
||||||
|
+int tst_audit18bmod1_func (void);
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+handle_restart (void)
|
||||||
|
+{
|
||||||
|
+ TEST_COMPARE (tst_audit18bmod1_func (), 10);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+startswith (const char *str, const char *pre)
|
||||||
|
+{
|
||||||
|
+ size_t lenpre = strlen (pre);
|
||||||
|
+ size_t lenstr = strlen (str);
|
||||||
|
+ return lenstr < lenpre ? false : memcmp (pre, str, lenpre) == 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (int argc, char *argv[])
|
||||||
|
+{
|
||||||
|
+ /* We must have either:
|
||||||
|
+ - One our fource parameters left if called initially:
|
||||||
|
+ + path to ld.so optional
|
||||||
|
+ + "--library-path" optional
|
||||||
|
+ + the library path optional
|
||||||
|
+ + the application name */
|
||||||
|
+
|
||||||
|
+ if (restart)
|
||||||
|
+ return handle_restart ();
|
||||||
|
+
|
||||||
|
+ char *spargv[9];
|
||||||
|
+ int i = 0;
|
||||||
|
+ for (; i < argc - 1; i++)
|
||||||
|
+ spargv[i] = argv[i + 1];
|
||||||
|
+ spargv[i++] = (char *) "--direct";
|
||||||
|
+ spargv[i++] = (char *) "--restart";
|
||||||
|
+ spargv[i] = NULL;
|
||||||
|
+
|
||||||
|
+ setenv ("LD_AUDIT", "tst-auditmod18b.so", 0);
|
||||||
|
+ struct support_capture_subprocess result
|
||||||
|
+ = support_capture_subprogram (spargv[0], spargv);
|
||||||
|
+ support_capture_subprocess_check (&result, "tst-audit18b", 0, sc_allow_stderr);
|
||||||
|
+
|
||||||
|
+ bool find_symbind = false;
|
||||||
|
+
|
||||||
|
+ FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||||
|
+ TEST_VERIFY (out != NULL);
|
||||||
|
+ char *buffer = NULL;
|
||||||
|
+ size_t buffer_length = 0;
|
||||||
|
+ while (xgetline (&buffer, &buffer_length, out))
|
||||||
|
+ if (startswith (buffer, "la_symbind: tst_audit18bmod1_func") == 0)
|
||||||
|
+ find_symbind = true;
|
||||||
|
+
|
||||||
|
+ TEST_COMPARE (find_symbind, true);
|
||||||
|
+
|
||||||
|
+ free (buffer);
|
||||||
|
+ xfclose (out);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define TEST_FUNCTION_ARGV do_test
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-audit19bmod.c b/elf/tst-audit19bmod.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..9ffdcd8f3ffbc38e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit19bmod.c
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+/* Extra module for tst-audit18b.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+tst_audit18bmod1_func (void)
|
||||||
|
+{
|
||||||
|
+ return 10;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod19a.c b/elf/tst-auditmod19a.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..f58204099457743d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod19a.c
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+/* Audit module for tst-audit18a.
|
||||||
|
+ 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 <link.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod19b.c b/elf/tst-auditmod19b.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..e2248b2a75946746
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod19b.c
|
||||||
|
@@ -0,0 +1,46 @@
|
||||||
|
+/* Audit module for tst-audit18b.
|
||||||
|
+ 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 <link.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ return LA_FLG_BINDTO | LA_FLG_BINDFROM;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+uintptr_t
|
||||||
|
+#if __ELF_NATIVE_CLASS == 32
|
||||||
|
+la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
||||||
|
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
||||||
|
+#else
|
||||||
|
+la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
||||||
|
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
||||||
|
+#endif
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "la_symbind: %s\n", symname);
|
||||||
|
+ return sym->st_value;
|
||||||
|
+}
|
||||||
|
diff --git a/include/link.h b/include/link.h
|
||||||
|
index 4dcf01d8aea90bc2..b3f160c278222b3c 100644
|
||||||
|
--- a/include/link.h
|
||||||
|
+++ b/include/link.h
|
||||||
|
@@ -363,8 +363,10 @@ struct auditstate
|
||||||
|
|
||||||
|
#if __ELF_NATIVE_CLASS == 32
|
||||||
|
# define symbind symbind32
|
||||||
|
+# define LA_SYMBIND "la_symbind32"
|
||||||
|
#elif __ELF_NATIVE_CLASS == 64
|
||||||
|
# define symbind symbind64
|
||||||
|
+# define LA_SYMBIND "la_symbind64"
|
||||||
|
#else
|
||||||
|
# error "__ELF_NATIVE_CLASS must be defined"
|
||||||
|
#endif
|
294
glibc-upstream-2.34-151.patch
Normal file
294
glibc-upstream-2.34-151.patch
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
commit 02c6a3d35316d360ae08623f617b1873d2f6159a
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Wed Jun 30 15:51:31 2021 -0300
|
||||||
|
|
||||||
|
elf: Add audit tests for modules with TLSDESC
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit d1b38173c9255b1a4ae00018ad9b35404a7c74d0)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index eab9d46b6165e6be..29f545d2272bf6e2 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -807,6 +807,22 @@ modules-names += tst-gnu2-tls1mod
|
||||||
|
$(objpfx)tst-gnu2-tls1: $(objpfx)tst-gnu2-tls1mod.so
|
||||||
|
tst-gnu2-tls1mod.so-no-z-defs = yes
|
||||||
|
CFLAGS-tst-gnu2-tls1mod.c += -mtls-dialect=gnu2
|
||||||
|
+
|
||||||
|
+tests += tst-audit-tlsdesc tst-audit-tlsdesc-dlopen
|
||||||
|
+modules-names += tst-audit-tlsdesc-mod1 tst-audit-tlsdesc-mod2 tst-auditmod-tlsdesc
|
||||||
|
+$(objpfx)tst-audit-tlsdesc: $(objpfx)tst-audit-tlsdesc-mod1.so \
|
||||||
|
+ $(objpfx)tst-audit-tlsdesc-mod2.so \
|
||||||
|
+ $(shared-thread-library)
|
||||||
|
+CFLAGS-tst-audit-tlsdesc-mod1.c += -mtls-dialect=gnu2
|
||||||
|
+CFLAGS-tst-audit-tlsdesc-mod2.c += -mtls-dialect=gnu2
|
||||||
|
+$(objpfx)tst-audit-tlsdesc-dlopen: $(shared-thread-library)
|
||||||
|
+$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-audit-tlsdesc-mod1.so \
|
||||||
|
+ $(objpfx)tst-audit-tlsdesc-mod2.so
|
||||||
|
+$(objpfx)tst-audit-tlsdesc-mod1.so: $(objpfx)tst-audit-tlsdesc-mod2.so
|
||||||
|
+$(objpfx)tst-audit-tlsdesc.out: $(objpfx)tst-auditmod-tlsdesc.so
|
||||||
|
+tst-audit-tlsdesc-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
|
||||||
|
+$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-auditmod-tlsdesc.so
|
||||||
|
+tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
|
||||||
|
endif
|
||||||
|
ifeq (yes,$(have-protected-data))
|
||||||
|
modules-names += tst-protected1moda tst-protected1modb
|
||||||
|
diff --git a/elf/tst-audit-tlsdesc-dlopen.c b/elf/tst-audit-tlsdesc-dlopen.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..9c16bb087aca1b77
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit-tlsdesc-dlopen.c
|
||||||
|
@@ -0,0 +1,67 @@
|
||||||
|
+/* DT_AUDIT with modules with TLSDESC.
|
||||||
|
+ 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 <support/check.h>
|
||||||
|
+#include <support/xthread.h>
|
||||||
|
+#include <support/xdlfcn.h>
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+thr_func (void *mod)
|
||||||
|
+{
|
||||||
|
+ int* (*get_global1)(void) = xdlsym (mod, "get_global1");
|
||||||
|
+ int* (*get_global2)(void) = xdlsym (mod, "get_global2");
|
||||||
|
+ void (*set_global2)(int) = xdlsym (mod, "set_global2");
|
||||||
|
+ int* (*get_local1)(void) = xdlsym (mod, "get_local1");
|
||||||
|
+ int* (*get_local2)(void) = xdlsym (mod, "get_local2");
|
||||||
|
+
|
||||||
|
+ int *global1 = get_global1 ();
|
||||||
|
+ TEST_COMPARE (*global1, 0);
|
||||||
|
+ ++*global1;
|
||||||
|
+
|
||||||
|
+ int *global2 = get_global2 ();
|
||||||
|
+ TEST_COMPARE (*global2, 0);
|
||||||
|
+ ++*global2;
|
||||||
|
+ TEST_COMPARE (*global2, 1);
|
||||||
|
+
|
||||||
|
+ set_global2 (10);
|
||||||
|
+ TEST_COMPARE (*global2, 10);
|
||||||
|
+
|
||||||
|
+ int *local1 = get_local1 ();
|
||||||
|
+ TEST_COMPARE (*local1, 0);
|
||||||
|
+ ++*local1;
|
||||||
|
+
|
||||||
|
+ int *local2 = get_local2 ();
|
||||||
|
+ TEST_COMPARE (*local2, 0);
|
||||||
|
+ ++*local2;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (void)
|
||||||
|
+{
|
||||||
|
+ void *mod = xdlopen ("tst-audit-tlsdesc-mod1.so", RTLD_LAZY);
|
||||||
|
+
|
||||||
|
+ pthread_t thr = xpthread_create (NULL, thr_func, mod);
|
||||||
|
+ void *r = xpthread_join (thr);
|
||||||
|
+ TEST_VERIFY (r == NULL);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-audit-tlsdesc-mod1.c b/elf/tst-audit-tlsdesc-mod1.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..61c7dd99a2fb5e28
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit-tlsdesc-mod1.c
|
||||||
|
@@ -0,0 +1,41 @@
|
||||||
|
+/* DT_AUDIT with modules with TLSDESC.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+__thread int global1;
|
||||||
|
+
|
||||||
|
+int *
|
||||||
|
+get_global1 (void)
|
||||||
|
+{
|
||||||
|
+ return &global1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static __thread int local1;
|
||||||
|
+
|
||||||
|
+void *
|
||||||
|
+get_local1 (void)
|
||||||
|
+{
|
||||||
|
+ return &local1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+extern __thread int global2;
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+set_global2 (int v)
|
||||||
|
+{
|
||||||
|
+ global2 = v;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-audit-tlsdesc-mod2.c b/elf/tst-audit-tlsdesc-mod2.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..28aef635f688ee03
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit-tlsdesc-mod2.c
|
||||||
|
@@ -0,0 +1,33 @@
|
||||||
|
+/* DT_AUDIT with modules with TLSDESC.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+__thread int global2;
|
||||||
|
+
|
||||||
|
+int *
|
||||||
|
+get_global2 (void)
|
||||||
|
+{
|
||||||
|
+ return &global2;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static __thread int local2;
|
||||||
|
+
|
||||||
|
+void *
|
||||||
|
+get_local2 (void)
|
||||||
|
+{
|
||||||
|
+ return &local2;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-audit-tlsdesc.c b/elf/tst-audit-tlsdesc.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..3c8be81c95528f47
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit-tlsdesc.c
|
||||||
|
@@ -0,0 +1,60 @@
|
||||||
|
+/* DT_AUDIT with modules with TLSDESC.
|
||||||
|
+ 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 <support/check.h>
|
||||||
|
+#include <support/xthread.h>
|
||||||
|
+
|
||||||
|
+extern __thread int global1;
|
||||||
|
+extern __thread int global2;
|
||||||
|
+void *get_local1 (void);
|
||||||
|
+void set_global2 (int v);
|
||||||
|
+void *get_local2 (void);
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+thr_func (void *clousure)
|
||||||
|
+{
|
||||||
|
+ TEST_COMPARE (global1, 0);
|
||||||
|
+ ++global1;
|
||||||
|
+ TEST_COMPARE (global2, 0);
|
||||||
|
+ ++global2;
|
||||||
|
+ TEST_COMPARE (global2, 1);
|
||||||
|
+
|
||||||
|
+ set_global2 (10);
|
||||||
|
+ TEST_COMPARE (global2, 10);
|
||||||
|
+
|
||||||
|
+ int *local1 = get_local1 ();
|
||||||
|
+ TEST_COMPARE (*local1, 0);
|
||||||
|
+ ++*local1;
|
||||||
|
+
|
||||||
|
+ int *local2 = get_local2 ();
|
||||||
|
+ TEST_COMPARE (*local2, 0);
|
||||||
|
+ ++*local2;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (void)
|
||||||
|
+{
|
||||||
|
+ pthread_t thr = xpthread_create (NULL, thr_func, NULL);
|
||||||
|
+ void *r = xpthread_join (thr);
|
||||||
|
+ TEST_VERIFY (r == NULL);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-auditmod-tlsdesc.c b/elf/tst-auditmod-tlsdesc.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..e4b835d1f1fb6f73
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod-tlsdesc.c
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+/* DT_AUDIT with modules with TLSDESC.
|
||||||
|
+ 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 <link.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
314
glibc-upstream-2.34-152.patch
Normal file
314
glibc-upstream-2.34-152.patch
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
commit d1b9bee29a1c4e0b80db53f228e22550c3604894
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Mon Jul 19 18:42:26 2021 -0300
|
||||||
|
|
||||||
|
elf: Issue audit la_objopen for vDSO
|
||||||
|
|
||||||
|
The vDSO is is listed in the link_map chain, but is never the subject of
|
||||||
|
an la_objopen call. A new internal flag __RTLD_VDSO is added that
|
||||||
|
acts as __RTLD_OPENEXEC to allocate the required 'struct auditstate'
|
||||||
|
extra space for the 'struct link_map'.
|
||||||
|
|
||||||
|
The return value from the callback is currently ignored, since there
|
||||||
|
is no PLT call involved by glibc when using the vDSO, neither the vDSO
|
||||||
|
are exported directly.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit f0e23d34a7bdf6b90fba954ee741419171ac41b2)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/Makefile
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 29f545d2272bf6e2..465442bf59fa9794 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -366,6 +366,7 @@ tests += \
|
||||||
|
tst-audit17 \
|
||||||
|
tst-audit18 \
|
||||||
|
tst-audit19b \
|
||||||
|
+ tst-audit22 \
|
||||||
|
tst-auditmany \
|
||||||
|
tst-auxobj \
|
||||||
|
tst-auxobj-dlopen \
|
||||||
|
@@ -649,6 +650,7 @@ modules-names = \
|
||||||
|
tst-auditmod18 \
|
||||||
|
tst-auditmod19a \
|
||||||
|
tst-auditmod19b \
|
||||||
|
+ tst-auditmod22 \
|
||||||
|
tst-auxvalmod \
|
||||||
|
tst-big-note-lib \
|
||||||
|
tst-deep1mod1 \
|
||||||
|
@@ -2035,6 +2037,9 @@ $(objpfx)tst-audit19b.out: $(objpfx)tst-auditmod19b.so
|
||||||
|
$(objpfx)tst-audit19b: $(objpfx)tst-audit19bmod.so
|
||||||
|
tst-audit19b-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
||||||
|
+tst-audit22-ARGS = -- $(host-test-program-cmd)
|
||||||
|
+
|
||||||
|
# tst-sonamemove links against an older implementation of the library.
|
||||||
|
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
||||||
|
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
||||||
|
diff --git a/elf/dl-object.c b/elf/dl-object.c
|
||||||
|
index 1875599eb274dc35..dee49a32d4fdf07d 100644
|
||||||
|
--- a/elf/dl-object.c
|
||||||
|
+++ b/elf/dl-object.c
|
||||||
|
@@ -59,16 +59,19 @@ _dl_new_object (char *realname, const char *libname, int type,
|
||||||
|
{
|
||||||
|
#ifdef SHARED
|
||||||
|
unsigned int naudit;
|
||||||
|
- if (__glibc_unlikely ((mode & __RTLD_OPENEXEC) != 0))
|
||||||
|
+ if (__glibc_unlikely ((mode & (__RTLD_OPENEXEC | __RTLD_VDSO)) != 0))
|
||||||
|
{
|
||||||
|
- assert (type == lt_executable);
|
||||||
|
- assert (nsid == LM_ID_BASE);
|
||||||
|
+ if (mode & __RTLD_OPENEXEC)
|
||||||
|
+ {
|
||||||
|
+ assert (type == lt_executable);
|
||||||
|
+ assert (nsid == LM_ID_BASE);
|
||||||
|
|
||||||
|
- /* Ignore the specified libname for the main executable. It is
|
||||||
|
- only known with an explicit loader invocation. */
|
||||||
|
- libname = "";
|
||||||
|
+ /* Ignore the specified libname for the main executable. It is
|
||||||
|
+ only known with an explicit loader invocation. */
|
||||||
|
+ libname = "";
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- /* We create the map for the executable before we know whether
|
||||||
|
+ /* We create the map for the executable and vDSO before we know whether
|
||||||
|
we have auditing libraries and if yes, how many. Assume the
|
||||||
|
worst. */
|
||||||
|
naudit = DL_NNS;
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index f632a767d7a269ef..b089e5cf4740443e 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -1922,6 +1922,12 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
assert (i == npreloads);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef NEED_DL_SYSINFO_DSO
|
||||||
|
+ /* Now that the audit modules are opened, call la_objopen for the vDSO. */
|
||||||
|
+ if (GLRO(dl_sysinfo_map) != NULL)
|
||||||
|
+ _dl_audit_objopen (GLRO(dl_sysinfo_map), LM_ID_BASE);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/* Load all the libraries specified by DT_NEEDED entries. If LD_PRELOAD
|
||||||
|
specified some libraries to load, these are inserted before the actual
|
||||||
|
dependencies in the executable's searchlist for symbol resolution. */
|
||||||
|
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
|
||||||
|
index 3f20578046de76ed..2b013d974a377a83 100644
|
||||||
|
--- a/elf/setup-vdso.h
|
||||||
|
+++ b/elf/setup-vdso.h
|
||||||
|
@@ -30,7 +30,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
|
||||||
|
We just want our data structures to describe it as if we had just
|
||||||
|
mapped and relocated it normally. */
|
||||||
|
struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL,
|
||||||
|
- 0, LM_ID_BASE);
|
||||||
|
+ __RTLD_VDSO, LM_ID_BASE);
|
||||||
|
if (__glibc_likely (l != NULL))
|
||||||
|
{
|
||||||
|
l->l_phdr = ((const void *) GLRO(dl_sysinfo_dso)
|
||||||
|
diff --git a/elf/tst-audit22.c b/elf/tst-audit22.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..18fd22a760ddc3d8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit22.c
|
||||||
|
@@ -0,0 +1,124 @@
|
||||||
|
+/* Check DTAUDIT and vDSO interaction.
|
||||||
|
+ 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 <errno.h>
|
||||||
|
+#include <getopt.h>
|
||||||
|
+#include <limits.h>
|
||||||
|
+#include <inttypes.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <support/capture_subprocess.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+#include <support/xstdio.h>
|
||||||
|
+#include <support/support.h>
|
||||||
|
+#include <sys/auxv.h>
|
||||||
|
+
|
||||||
|
+static int restart;
|
||||||
|
+#define CMDLINE_OPTIONS \
|
||||||
|
+ { "restart", no_argument, &restart, 1 },
|
||||||
|
+
|
||||||
|
+static uintptr_t vdso_addr;
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+handle_restart (void)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "vdso: %p\n", (void*) vdso_addr);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static uintptr_t
|
||||||
|
+parse_address (const char *str)
|
||||||
|
+{
|
||||||
|
+ void *r;
|
||||||
|
+ TEST_COMPARE (sscanf (str, "%p\n", &r), 1);
|
||||||
|
+ return (uintptr_t) r;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+startswith (const char *str, const char *pre)
|
||||||
|
+{
|
||||||
|
+ size_t lenpre = strlen (pre);
|
||||||
|
+ size_t lenstr = strlen (str);
|
||||||
|
+ return lenstr >= lenpre && memcmp (pre, str, lenpre) == 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (int argc, char *argv[])
|
||||||
|
+{
|
||||||
|
+ vdso_addr = getauxval (AT_SYSINFO_EHDR);
|
||||||
|
+ if (vdso_addr == 0)
|
||||||
|
+ FAIL_UNSUPPORTED ("getauxval (AT_SYSINFO_EHDR) returned 0");
|
||||||
|
+
|
||||||
|
+ /* We must have either:
|
||||||
|
+ - One our fource parameters left if called initially:
|
||||||
|
+ + path to ld.so optional
|
||||||
|
+ + "--library-path" optional
|
||||||
|
+ + the library path optional
|
||||||
|
+ + the application name */
|
||||||
|
+ if (restart)
|
||||||
|
+ return handle_restart ();
|
||||||
|
+
|
||||||
|
+ char *spargv[9];
|
||||||
|
+ int i = 0;
|
||||||
|
+ for (; i < argc - 1; i++)
|
||||||
|
+ spargv[i] = argv[i + 1];
|
||||||
|
+ spargv[i++] = (char *) "--direct";
|
||||||
|
+ spargv[i++] = (char *) "--restart";
|
||||||
|
+ spargv[i] = NULL;
|
||||||
|
+
|
||||||
|
+ setenv ("LD_AUDIT", "tst-auditmod22.so", 0);
|
||||||
|
+ struct support_capture_subprocess result
|
||||||
|
+ = support_capture_subprogram (spargv[0], spargv);
|
||||||
|
+ support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
||||||
|
+
|
||||||
|
+ /* The respawned process should always print the vDSO address (otherwise it
|
||||||
|
+ will fails as unsupported). However, on some architectures the audit
|
||||||
|
+ module might see the vDSO with l_addr being 0, meaning a fixed mapping
|
||||||
|
+ (linux-gate.so). In this case we don't check its value against
|
||||||
|
+ AT_SYSINFO_EHDR one. */
|
||||||
|
+ uintptr_t vdso_process = 0;
|
||||||
|
+ bool vdso_audit_found = false;
|
||||||
|
+ uintptr_t vdso_audit = 0;
|
||||||
|
+
|
||||||
|
+ FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||||
|
+ TEST_VERIFY (out != NULL);
|
||||||
|
+ char *buffer = NULL;
|
||||||
|
+ size_t buffer_length = 0;
|
||||||
|
+ while (xgetline (&buffer, &buffer_length, out))
|
||||||
|
+ {
|
||||||
|
+ if (startswith (buffer, "vdso: "))
|
||||||
|
+ vdso_process = parse_address (buffer + strlen ("vdso: "));
|
||||||
|
+ else if (startswith (buffer, "vdso found: "))
|
||||||
|
+ {
|
||||||
|
+ vdso_audit = parse_address (buffer + strlen ("vdso found: "));
|
||||||
|
+ vdso_audit_found = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ TEST_COMPARE (vdso_audit_found, true);
|
||||||
|
+ if (vdso_audit != 0)
|
||||||
|
+ TEST_COMPARE (vdso_process, vdso_audit);
|
||||||
|
+
|
||||||
|
+ free (buffer);
|
||||||
|
+ xfclose (out);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define TEST_FUNCTION_ARGV do_test
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-auditmod22.c b/elf/tst-auditmod22.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..8e05ce8cbb215dd5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod22.c
|
||||||
|
@@ -0,0 +1,51 @@
|
||||||
|
+/* Check DTAUDIT and vDSO interaction.
|
||||||
|
+ 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 <link.h>
|
||||||
|
+#include <inttypes.h>
|
||||||
|
+#include <stdbool.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <sys/auxv.h>
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+startswith (const char *str, const char *pre)
|
||||||
|
+{
|
||||||
|
+ size_t lenpre = strlen (pre);
|
||||||
|
+ size_t lenstr = strlen (str);
|
||||||
|
+ return lenstr < lenpre ? false : memcmp (pre, str, lenpre) == 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ /* The linux-gate.so is placed at a fixed address, thus l_addr being 0,
|
||||||
|
+ and it might be the value reported as the AT_SYSINFO_EHDR. */
|
||||||
|
+ if (map->l_addr == 0 && startswith (map->l_name, "linux-gate.so"))
|
||||||
|
+ fprintf (stderr, "vdso found: %p\n", NULL);
|
||||||
|
+ else if (map->l_addr == getauxval (AT_SYSINFO_EHDR))
|
||||||
|
+ fprintf (stderr, "vdso found: %p\n", (void*) map->l_addr);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/include/dlfcn.h b/include/dlfcn.h
|
||||||
|
index a4c283728f94deb4..e73294b0af587913 100644
|
||||||
|
--- a/include/dlfcn.h
|
||||||
|
+++ b/include/dlfcn.h
|
||||||
|
@@ -12,6 +12,8 @@
|
||||||
|
#define __RTLD_AUDIT 0x08000000
|
||||||
|
#define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
|
||||||
|
#define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */
|
||||||
|
+#define __RTLD_VDSO 0x01000000 /* Tell _dl_new_object the object is
|
||||||
|
+ system-loaded. */
|
||||||
|
|
||||||
|
#define __LM_ID_CALLER -2
|
||||||
|
|
167
glibc-upstream-2.34-153.patch
Normal file
167
glibc-upstream-2.34-153.patch
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
commit 2255621f0e2cd07f7a6147928ce644e13526ffb6
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Wed Jun 30 17:33:57 2021 -0300
|
||||||
|
|
||||||
|
elf: Do not fail for failed dlmopen on audit modules (BZ #28061)
|
||||||
|
|
||||||
|
The dl_main sets the LM_ID_BASE to RT_ADD just before starting to
|
||||||
|
add load new shared objects. The state is set to RT_CONSISTENT just
|
||||||
|
after all objects are loaded.
|
||||||
|
|
||||||
|
However if a audit modules tries to dlmopen an inexistent module,
|
||||||
|
the _dl_open will assert that the namespace is in an inconsistent
|
||||||
|
state.
|
||||||
|
|
||||||
|
This is different than dlopen, since first it will not use
|
||||||
|
LM_ID_BASE and second _dl_map_object_from_fd is the sole responsible
|
||||||
|
to set and reset the r_state value.
|
||||||
|
|
||||||
|
So the assert on _dl_open can not really be seen if the state is
|
||||||
|
consistent, since _dt_main resets it. This patch removes the assert.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 484e672ddabe0a919a692520e6ac8f2580866235)
|
||||||
|
|
||||||
|
Resolved conflicts:
|
||||||
|
elf/Makefile
|
||||||
|
elf/dl-open.c
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 465442bf59fa9794..91b2269257523a64 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -366,6 +366,7 @@ tests += \
|
||||||
|
tst-audit17 \
|
||||||
|
tst-audit18 \
|
||||||
|
tst-audit19b \
|
||||||
|
+ tst-audit20 \
|
||||||
|
tst-audit22 \
|
||||||
|
tst-auditmany \
|
||||||
|
tst-auxobj \
|
||||||
|
@@ -650,6 +651,7 @@ modules-names = \
|
||||||
|
tst-auditmod18 \
|
||||||
|
tst-auditmod19a \
|
||||||
|
tst-auditmod19b \
|
||||||
|
+ tst-auditmod20 \
|
||||||
|
tst-auditmod22 \
|
||||||
|
tst-auxvalmod \
|
||||||
|
tst-big-note-lib \
|
||||||
|
@@ -2037,6 +2039,9 @@ $(objpfx)tst-audit19b.out: $(objpfx)tst-auditmod19b.so
|
||||||
|
$(objpfx)tst-audit19b: $(objpfx)tst-audit19bmod.so
|
||||||
|
tst-audit19b-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit20.out: $(objpfx)tst-auditmod20.so
|
||||||
|
+tst-audit20-ENV = LD_AUDIT=$(objpfx)tst-auditmod20.so
|
||||||
|
+
|
||||||
|
$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
||||||
|
tst-audit22-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
||||||
|
index 3f01aa480730da13..bc6872632880634e 100644
|
||||||
|
--- a/elf/dl-open.c
|
||||||
|
+++ b/elf/dl-open.c
|
||||||
|
@@ -914,8 +914,6 @@ no more namespaces available for dlmopen()"));
|
||||||
|
the flag here. */
|
||||||
|
}
|
||||||
|
|
||||||
|
- assert (_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT);
|
||||||
|
-
|
||||||
|
/* Release the lock. */
|
||||||
|
__rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||||
|
|
||||||
|
diff --git a/elf/tst-audit20.c b/elf/tst-audit20.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..6f39ccee865b012b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit20.c
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+/* Check dlopen failure on audit modules.
|
||||||
|
+ 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/>. */
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (void)
|
||||||
|
+{
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-auditmod20.c b/elf/tst-auditmod20.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..c57e50ee4e88dd6b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod20.c
|
||||||
|
@@ -0,0 +1,57 @@
|
||||||
|
+/* Check dlopen failure on audit modules.
|
||||||
|
+ 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 <dlfcn.h>
|
||||||
|
+#include <link.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int v)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+check (void)
|
||||||
|
+{
|
||||||
|
+ {
|
||||||
|
+ void *mod = dlopen ("nonexistent.so", RTLD_NOW);
|
||||||
|
+ if (mod != NULL)
|
||||||
|
+ abort ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ {
|
||||||
|
+ void *mod = dlmopen (LM_ID_BASE, "nonexistent.so", RTLD_NOW);
|
||||||
|
+ if (mod != NULL)
|
||||||
|
+ abort ();
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_activity (uintptr_t *cookie, unsigned int flag)
|
||||||
|
+{
|
||||||
|
+ if (flag != LA_ACT_CONSISTENT)
|
||||||
|
+ return;
|
||||||
|
+ check ();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_preinit (uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ check ();
|
||||||
|
+}
|
434
glibc-upstream-2.34-154.patch
Normal file
434
glibc-upstream-2.34-154.patch
Normal file
@ -0,0 +1,434 @@
|
|||||||
|
commit 98047ba95caf9ed596908ca73a22070c5e27597b
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Mon Jan 24 10:46:15 2022 -0300
|
||||||
|
|
||||||
|
elf: Add la_activity during application exit
|
||||||
|
|
||||||
|
la_activity is not called during application exit, even though
|
||||||
|
la_objclose is.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||||
|
Tested-by: Carlos O'Donell <carlos@redhat.com>
|
||||||
|
(cherry picked from commit 5fa11a2bc94c912c3b25860065086902674537ba)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 91b2269257523a64..407aaeaeb8c84020 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -368,6 +368,7 @@ tests += \
|
||||||
|
tst-audit19b \
|
||||||
|
tst-audit20 \
|
||||||
|
tst-audit22 \
|
||||||
|
+ tst-audit23 \
|
||||||
|
tst-auditmany \
|
||||||
|
tst-auxobj \
|
||||||
|
tst-auxobj-dlopen \
|
||||||
|
@@ -631,6 +632,7 @@ modules-names = \
|
||||||
|
tst-audit13mod1 \
|
||||||
|
tst-audit18mod \
|
||||||
|
tst-audit19bmod \
|
||||||
|
+ tst-audit23mod \
|
||||||
|
tst-auditlogmod-1 \
|
||||||
|
tst-auditlogmod-2 \
|
||||||
|
tst-auditlogmod-3 \
|
||||||
|
@@ -653,6 +655,7 @@ modules-names = \
|
||||||
|
tst-auditmod19b \
|
||||||
|
tst-auditmod20 \
|
||||||
|
tst-auditmod22 \
|
||||||
|
+ tst-auditmod23 \
|
||||||
|
tst-auxvalmod \
|
||||||
|
tst-big-note-lib \
|
||||||
|
tst-deep1mod1 \
|
||||||
|
@@ -2045,6 +2048,10 @@ tst-audit20-ENV = LD_AUDIT=$(objpfx)tst-auditmod20.so
|
||||||
|
$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
||||||
|
tst-audit22-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit23.out: $(objpfx)tst-auditmod23.so \
|
||||||
|
+ $(objpfx)tst-audit23mod.so
|
||||||
|
+tst-audit23-ARGS = -- $(host-test-program-cmd)
|
||||||
|
+
|
||||||
|
# tst-sonamemove links against an older implementation of the library.
|
||||||
|
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
||||||
|
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
||||||
|
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
|
||||||
|
index b789cfb9f2ac6c85..fa876da0ffa1cf97 100644
|
||||||
|
--- a/elf/dl-fini.c
|
||||||
|
+++ b/elf/dl-fini.c
|
||||||
|
@@ -64,6 +64,10 @@ _dl_fini (void)
|
||||||
|
__rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
+#ifdef SHARED
|
||||||
|
+ _dl_audit_activity_nsid (ns, LA_ACT_DELETE);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/* Now we can allocate an array to hold all the pointers and
|
||||||
|
copy the pointers in. */
|
||||||
|
struct link_map *maps[nloaded];
|
||||||
|
@@ -153,6 +157,10 @@ _dl_fini (void)
|
||||||
|
/* Correct the previous increment. */
|
||||||
|
--l->l_direct_opencount;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+#ifdef SHARED
|
||||||
|
+ _dl_audit_activity_nsid (ns, LA_ACT_CONSISTENT);
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..4904cf1340a97ee1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit23.c
|
||||||
|
@@ -0,0 +1,239 @@
|
||||||
|
+/* Check for expected la_objopen and la_objeclose for all objects.
|
||||||
|
+ Copyright (C) 2022 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 <array_length.h>
|
||||||
|
+#include <errno.h>
|
||||||
|
+#include <getopt.h>
|
||||||
|
+#include <link.h>
|
||||||
|
+#include <limits.h>
|
||||||
|
+#include <inttypes.h>
|
||||||
|
+#include <gnu/lib-names.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <support/capture_subprocess.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+#include <support/xstdio.h>
|
||||||
|
+#include <support/xdlfcn.h>
|
||||||
|
+#include <support/support.h>
|
||||||
|
+
|
||||||
|
+static int restart;
|
||||||
|
+#define CMDLINE_OPTIONS \
|
||||||
|
+ { "restart", no_argument, &restart, 1 },
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+handle_restart (void)
|
||||||
|
+{
|
||||||
|
+ xdlopen ("tst-audit23mod.so", RTLD_NOW);
|
||||||
|
+ xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+startswith (const char *str, const char *pre)
|
||||||
|
+{
|
||||||
|
+ size_t lenpre = strlen (pre);
|
||||||
|
+ size_t lenstr = strlen (str);
|
||||||
|
+ return lenstr >= lenpre && memcmp (pre, str, lenpre) == 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+is_vdso (const char *str)
|
||||||
|
+{
|
||||||
|
+ return startswith (str, "linux-gate")
|
||||||
|
+ || startswith (str, "linux-vdso");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (int argc, char *argv[])
|
||||||
|
+{
|
||||||
|
+ /* We must have either:
|
||||||
|
+ - One or four parameters left if called initially:
|
||||||
|
+ + path to ld.so optional
|
||||||
|
+ + "--library-path" optional
|
||||||
|
+ + the library path optional
|
||||||
|
+ + the application name */
|
||||||
|
+ if (restart)
|
||||||
|
+ return handle_restart ();
|
||||||
|
+
|
||||||
|
+ char *spargv[9];
|
||||||
|
+ TEST_VERIFY_EXIT (((argc - 1) + 3) < array_length (spargv));
|
||||||
|
+ int i = 0;
|
||||||
|
+ for (; i < argc - 1; i++)
|
||||||
|
+ spargv[i] = argv[i + 1];
|
||||||
|
+ spargv[i++] = (char *) "--direct";
|
||||||
|
+ spargv[i++] = (char *) "--restart";
|
||||||
|
+ spargv[i] = NULL;
|
||||||
|
+
|
||||||
|
+ setenv ("LD_AUDIT", "tst-auditmod23.so", 0);
|
||||||
|
+ struct support_capture_subprocess result
|
||||||
|
+ = support_capture_subprogram (spargv[0], spargv);
|
||||||
|
+ support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
||||||
|
+
|
||||||
|
+ /* The expected la_objopen/la_objclose:
|
||||||
|
+ 1. executable
|
||||||
|
+ 2. loader
|
||||||
|
+ 3. libc.so
|
||||||
|
+ 4. tst-audit23mod.so
|
||||||
|
+ 5. libc.so (LM_ID_NEWLM).
|
||||||
|
+ 6. vdso (optional and ignored). */
|
||||||
|
+ enum { max_objs = 6 };
|
||||||
|
+ struct la_obj_t
|
||||||
|
+ {
|
||||||
|
+ char *lname;
|
||||||
|
+ uintptr_t laddr;
|
||||||
|
+ Lmid_t lmid;
|
||||||
|
+ bool closed;
|
||||||
|
+ } objs[max_objs] = { [0 ... max_objs-1] = { .closed = false } };
|
||||||
|
+ size_t nobjs = 0;
|
||||||
|
+
|
||||||
|
+ /* The expected namespaces are one for the audit module, one for the
|
||||||
|
+ application, and another for the dlmopen on handle_restart. */
|
||||||
|
+ enum { max_ns = 3 };
|
||||||
|
+ uintptr_t acts[max_ns] = { 0 };
|
||||||
|
+ size_t nacts = 0;
|
||||||
|
+ int last_act = -1;
|
||||||
|
+ uintptr_t last_act_cookie = -1;
|
||||||
|
+ bool seen_first_objclose = false;
|
||||||
|
+
|
||||||
|
+ FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||||
|
+ TEST_VERIFY (out != NULL);
|
||||||
|
+ char *buffer = NULL;
|
||||||
|
+ size_t buffer_length = 0;
|
||||||
|
+ while (xgetline (&buffer, &buffer_length, out))
|
||||||
|
+ {
|
||||||
|
+ if (startswith (buffer, "la_activity: "))
|
||||||
|
+ {
|
||||||
|
+ uintptr_t cookie;
|
||||||
|
+ int this_act;
|
||||||
|
+ int r = sscanf (buffer, "la_activity: %d %"SCNxPTR"", &this_act,
|
||||||
|
+ &cookie);
|
||||||
|
+ TEST_COMPARE (r, 2);
|
||||||
|
+
|
||||||
|
+ /* The cookie identifies the object at the head of the link map,
|
||||||
|
+ so we only add a new namespace if it changes from the previous
|
||||||
|
+ one. This works since dlmopen is the last in the test body. */
|
||||||
|
+ if (cookie != last_act_cookie && last_act_cookie != -1)
|
||||||
|
+ TEST_COMPARE (last_act, LA_ACT_CONSISTENT);
|
||||||
|
+
|
||||||
|
+ if (this_act == LA_ACT_ADD && acts[nacts] != cookie)
|
||||||
|
+ {
|
||||||
|
+ acts[nacts++] = cookie;
|
||||||
|
+ last_act_cookie = cookie;
|
||||||
|
+ }
|
||||||
|
+ /* The LA_ACT_DELETE is called in the reverse order of LA_ACT_ADD
|
||||||
|
+ at program termination (if the tests adds a dlclose or a library
|
||||||
|
+ with extra dependencies this will need to be adapted). */
|
||||||
|
+ else if (this_act == LA_ACT_DELETE)
|
||||||
|
+ {
|
||||||
|
+ last_act_cookie = acts[--nacts];
|
||||||
|
+ TEST_COMPARE (acts[nacts], cookie);
|
||||||
|
+ acts[nacts] = 0;
|
||||||
|
+ }
|
||||||
|
+ else if (this_act == LA_ACT_CONSISTENT)
|
||||||
|
+ {
|
||||||
|
+ TEST_COMPARE (cookie, last_act_cookie);
|
||||||
|
+
|
||||||
|
+ /* LA_ACT_DELETE must always be followed by an la_objclose. */
|
||||||
|
+ if (last_act == LA_ACT_DELETE)
|
||||||
|
+ TEST_COMPARE (seen_first_objclose, true);
|
||||||
|
+ else
|
||||||
|
+ TEST_COMPARE (last_act, LA_ACT_ADD);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ last_act = this_act;
|
||||||
|
+ seen_first_objclose = false;
|
||||||
|
+ }
|
||||||
|
+ else if (startswith (buffer, "la_objopen: "))
|
||||||
|
+ {
|
||||||
|
+ char *lname;
|
||||||
|
+ uintptr_t laddr;
|
||||||
|
+ Lmid_t lmid;
|
||||||
|
+ uintptr_t cookie;
|
||||||
|
+ int r = sscanf (buffer, "la_objopen: %"SCNxPTR" %ms %"SCNxPTR" %ld",
|
||||||
|
+ &cookie, &lname, &laddr, &lmid);
|
||||||
|
+ TEST_COMPARE (r, 4);
|
||||||
|
+
|
||||||
|
+ /* la_objclose is not triggered by vDSO because glibc does not
|
||||||
|
+ unload it. */
|
||||||
|
+ if (is_vdso (lname))
|
||||||
|
+ continue;
|
||||||
|
+ if (nobjs == max_objs)
|
||||||
|
+ FAIL_EXIT1 ("non expected la_objopen: %s %"PRIxPTR" %ld",
|
||||||
|
+ lname, laddr, lmid);
|
||||||
|
+ objs[nobjs].lname = lname;
|
||||||
|
+ objs[nobjs].laddr = laddr;
|
||||||
|
+ objs[nobjs].lmid = lmid;
|
||||||
|
+ objs[nobjs].closed = false;
|
||||||
|
+ nobjs++;
|
||||||
|
+
|
||||||
|
+ /* This indirectly checks that la_objopen always comes before
|
||||||
|
+ la_objclose btween la_activity calls. */
|
||||||
|
+ seen_first_objclose = false;
|
||||||
|
+ }
|
||||||
|
+ else if (startswith (buffer, "la_objclose: "))
|
||||||
|
+ {
|
||||||
|
+ char *lname;
|
||||||
|
+ uintptr_t laddr;
|
||||||
|
+ Lmid_t lmid;
|
||||||
|
+ uintptr_t cookie;
|
||||||
|
+ int r = sscanf (buffer, "la_objclose: %"SCNxPTR" %ms %"SCNxPTR" %ld",
|
||||||
|
+ &cookie, &lname, &laddr, &lmid);
|
||||||
|
+ TEST_COMPARE (r, 4);
|
||||||
|
+
|
||||||
|
+ for (size_t i = 0; i < nobjs; i++)
|
||||||
|
+ {
|
||||||
|
+ if (strcmp (lname, objs[i].lname) == 0 && lmid == objs[i].lmid)
|
||||||
|
+ {
|
||||||
|
+ TEST_COMPARE (objs[i].closed, false);
|
||||||
|
+ objs[i].closed = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* la_objclose should be called after la_activity(LA_ACT_DELETE) for
|
||||||
|
+ the closed object's namespace. */
|
||||||
|
+ TEST_COMPARE (last_act, LA_ACT_DELETE);
|
||||||
|
+ if (!seen_first_objclose)
|
||||||
|
+ {
|
||||||
|
+ TEST_COMPARE (last_act_cookie, cookie);
|
||||||
|
+ seen_first_objclose = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (size_t i = 0; i < nobjs; i++)
|
||||||
|
+ {
|
||||||
|
+ TEST_COMPARE (objs[i].closed, true);
|
||||||
|
+ free (objs[i].lname);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* la_activity(LA_ACT_CONSISTENT) should be the last callback received.
|
||||||
|
+ Since only one link map may be not-CONSISTENT at a time, this also
|
||||||
|
+ ensures la_activity(LA_ACT_CONSISTENT) is the last callback received
|
||||||
|
+ for every namespace. */
|
||||||
|
+ TEST_COMPARE (last_act, LA_ACT_CONSISTENT);
|
||||||
|
+
|
||||||
|
+ free (buffer);
|
||||||
|
+ xfclose (out);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define TEST_FUNCTION_ARGV do_test
|
||||||
|
+#include <support/test-driver.c>
|
||||||
|
diff --git a/elf/tst-audit23mod.c b/elf/tst-audit23mod.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..30315687037d25e8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit23mod.c
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+/* Extra module for tst-audit23
|
||||||
|
+ Copyright (C) 2022 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/>. */
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+foo (void)
|
||||||
|
+{
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod23.c b/elf/tst-auditmod23.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..d7c60d7a5cbc4f8a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod23.c
|
||||||
|
@@ -0,0 +1,74 @@
|
||||||
|
+/* Audit module loaded by tst-audit23.
|
||||||
|
+ Copyright (C) 2022 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 <link.h>
|
||||||
|
+#include <inttypes.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <sys/auxv.h>
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int version)
|
||||||
|
+{
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+struct map_desc_t
|
||||||
|
+{
|
||||||
|
+ char *lname;
|
||||||
|
+ uintptr_t laddr;
|
||||||
|
+ Lmid_t lmid;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_activity (uintptr_t *cookie, unsigned int flag)
|
||||||
|
+{
|
||||||
|
+ fprintf (stderr, "%s: %d %"PRIxPTR"\n", __func__, flag, (uintptr_t) cookie);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ const char *l_name = map->l_name[0] == '\0' ? "mainapp" : map->l_name;
|
||||||
|
+ fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
|
||||||
|
+ (uintptr_t) cookie, l_name, map->l_addr, lmid);
|
||||||
|
+
|
||||||
|
+ struct map_desc_t *map_desc = malloc (sizeof (struct map_desc_t));
|
||||||
|
+ if (map_desc == NULL)
|
||||||
|
+ abort ();
|
||||||
|
+
|
||||||
|
+ map_desc->lname = strdup (l_name);
|
||||||
|
+ map_desc->laddr = map->l_addr;
|
||||||
|
+ map_desc->lmid = lmid;
|
||||||
|
+
|
||||||
|
+ *cookie = (uintptr_t) map_desc;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objclose (uintptr_t *cookie)
|
||||||
|
+{
|
||||||
|
+ struct map_desc_t *map_desc = (struct map_desc_t *) *cookie;
|
||||||
|
+ fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
|
||||||
|
+ (uintptr_t) cookie, map_desc->lname, map_desc->laddr,
|
||||||
|
+ map_desc->lmid);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
299
glibc-upstream-2.34-155.patch
Normal file
299
glibc-upstream-2.34-155.patch
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
commit efb21b5fb27fbad447d9f242436fb591870f0045
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Mon Jan 24 10:46:16 2022 -0300
|
||||||
|
|
||||||
|
elf: Fix initial-exec TLS access on audit modules (BZ #28096)
|
||||||
|
|
||||||
|
For audit modules and dependencies with initial-exec TLS, we can not
|
||||||
|
set the initial TLS image on default loader initialization because it
|
||||||
|
would already be set by the audit setup. However, subsequent thread
|
||||||
|
creation would need to follow the default behaviour.
|
||||||
|
|
||||||
|
This patch fixes it by setting l_auditing link_map field not only
|
||||||
|
for the audit modules, but also for all its dependencies. This is
|
||||||
|
used on _dl_allocate_tls_init to avoid the static TLS initialization
|
||||||
|
at load time.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||||
|
Tested-by: Carlos O'Donell <carlos@redhat.com>
|
||||||
|
(cherry picked from commit 254d3d5aef2fd8430c469e1938209ac100ebf132)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 407aaeaeb8c84020..3ccf78f62985e2d0 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -367,6 +367,7 @@ tests += \
|
||||||
|
tst-audit18 \
|
||||||
|
tst-audit19b \
|
||||||
|
tst-audit20 \
|
||||||
|
+ tst-audit21 \
|
||||||
|
tst-audit22 \
|
||||||
|
tst-audit23 \
|
||||||
|
tst-auditmany \
|
||||||
|
@@ -654,6 +655,8 @@ modules-names = \
|
||||||
|
tst-auditmod19a \
|
||||||
|
tst-auditmod19b \
|
||||||
|
tst-auditmod20 \
|
||||||
|
+ tst-auditmod21a \
|
||||||
|
+ tst-auditmod21b \
|
||||||
|
tst-auditmod22 \
|
||||||
|
tst-auditmod23 \
|
||||||
|
tst-auxvalmod \
|
||||||
|
@@ -2045,6 +2048,11 @@ tst-audit19b-ARGS = -- $(host-test-program-cmd)
|
||||||
|
$(objpfx)tst-audit20.out: $(objpfx)tst-auditmod20.so
|
||||||
|
tst-audit20-ENV = LD_AUDIT=$(objpfx)tst-auditmod20.so
|
||||||
|
|
||||||
|
+$(objpfx)tst-audit21: $(shared-thread-library)
|
||||||
|
+$(objpfx)tst-audit21.out: $(objpfx)tst-auditmod21a.so
|
||||||
|
+$(objpfx)tst-auditmod21a.so: $(objpfx)tst-auditmod21b.so
|
||||||
|
+tst-audit21-ENV = LD_AUDIT=$(objpfx)tst-auditmod21a.so
|
||||||
|
+
|
||||||
|
$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
||||||
|
tst-audit22-ARGS = -- $(host-test-program-cmd)
|
||||||
|
|
||||||
|
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||||
|
index e2012d0cd515103b..fab6546e2d31edd4 100644
|
||||||
|
--- a/elf/dl-tls.c
|
||||||
|
+++ b/elf/dl-tls.c
|
||||||
|
@@ -519,8 +519,12 @@ _dl_resize_dtv (dtv_t *dtv, size_t max_modid)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+/* Allocate initial TLS. RESULT should be a non-NULL pointer to storage
|
||||||
|
+ for the TLS space. The DTV may be resized, and so this function may
|
||||||
|
+ call malloc to allocate that space. The loader's GL(dl_load_tls_lock)
|
||||||
|
+ is taken when manipulating global TLS-related data in the loader. */
|
||||||
|
void *
|
||||||
|
-_dl_allocate_tls_init (void *result)
|
||||||
|
+_dl_allocate_tls_init (void *result, bool init_tls)
|
||||||
|
{
|
||||||
|
if (result == NULL)
|
||||||
|
/* The memory allocation failed. */
|
||||||
|
@@ -593,7 +597,14 @@ _dl_allocate_tls_init (void *result)
|
||||||
|
some platforms use in static programs requires it. */
|
||||||
|
dtv[map->l_tls_modid].pointer.val = dest;
|
||||||
|
|
||||||
|
- /* Copy the initialization image and clear the BSS part. */
|
||||||
|
+ /* Copy the initialization image and clear the BSS part. For
|
||||||
|
+ audit modules or dependencies with initial-exec TLS, we can not
|
||||||
|
+ set the initial TLS image on default loader initialization
|
||||||
|
+ because it would already be set by the audit setup. However,
|
||||||
|
+ subsequent thread creation would need to follow the default
|
||||||
|
+ behaviour. */
|
||||||
|
+ if (map->l_ns != LM_ID_BASE && !init_tls)
|
||||||
|
+ continue;
|
||||||
|
memset (__mempcpy (dest, map->l_tls_initimage,
|
||||||
|
map->l_tls_initimage_size), '\0',
|
||||||
|
map->l_tls_blocksize - map->l_tls_initimage_size);
|
||||||
|
@@ -620,7 +631,7 @@ _dl_allocate_tls (void *mem)
|
||||||
|
{
|
||||||
|
return _dl_allocate_tls_init (mem == NULL
|
||||||
|
? _dl_allocate_tls_storage ()
|
||||||
|
- : allocate_dtv (mem));
|
||||||
|
+ : allocate_dtv (mem), true);
|
||||||
|
}
|
||||||
|
rtld_hidden_def (_dl_allocate_tls)
|
||||||
|
|
||||||
|
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||||
|
index b089e5cf4740443e..26c6fb6479c9008c 100644
|
||||||
|
--- a/elf/rtld.c
|
||||||
|
+++ b/elf/rtld.c
|
||||||
|
@@ -2429,7 +2429,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
into the main thread's TLS area, which we allocated above.
|
||||||
|
Note: thread-local variables must only be accessed after completing
|
||||||
|
the next step. */
|
||||||
|
- _dl_allocate_tls_init (tcbp);
|
||||||
|
+ _dl_allocate_tls_init (tcbp, false);
|
||||||
|
|
||||||
|
/* And finally install it for the main thread. */
|
||||||
|
if (! tls_init_tp_called)
|
||||||
|
diff --git a/elf/tst-audit21.c b/elf/tst-audit21.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..3a47ab64d44421ee
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-audit21.c
|
||||||
|
@@ -0,0 +1,42 @@
|
||||||
|
+/* Check LD_AUDIT with static TLS.
|
||||||
|
+ Copyright (C) 2022 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 <ctype.h>
|
||||||
|
+#include <support/xthread.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+
|
||||||
|
+static volatile __thread int out __attribute__ ((tls_model ("initial-exec")));
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf (void *arg)
|
||||||
|
+{
|
||||||
|
+ TEST_COMPARE (out, 0);
|
||||||
|
+ out = isspace (' ');
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int main (int argc, char *argv[])
|
||||||
|
+{
|
||||||
|
+ TEST_COMPARE (out, 0);
|
||||||
|
+ out = isspace (' ');
|
||||||
|
+
|
||||||
|
+ pthread_t t = xpthread_create (NULL, tf, NULL);
|
||||||
|
+ xpthread_join (t);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod21a.c b/elf/tst-auditmod21a.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..f6d51b5c0531c49d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod21a.c
|
||||||
|
@@ -0,0 +1,80 @@
|
||||||
|
+/* Check LD_AUDIT with static TLS.
|
||||||
|
+ Copyright (C) 2022 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 <ctype.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <link.h>
|
||||||
|
+
|
||||||
|
+#define tls_ie __attribute__ ((tls_model ("initial-exec")))
|
||||||
|
+
|
||||||
|
+__thread int tls_var0 tls_ie;
|
||||||
|
+__thread int tls_var1 tls_ie = 0x10;
|
||||||
|
+
|
||||||
|
+/* Defined at tst-auditmod21b.so */
|
||||||
|
+extern __thread int tls_var2;
|
||||||
|
+extern __thread int tls_var3;
|
||||||
|
+
|
||||||
|
+static volatile int out;
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+call_libc (void)
|
||||||
|
+{
|
||||||
|
+ /* isspace accesses the initial-exec glibc TLS variables, which are
|
||||||
|
+ setup in glibc initialization. */
|
||||||
|
+ out = isspace (' ');
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_version (unsigned int v)
|
||||||
|
+{
|
||||||
|
+ tls_var0 = 0x1;
|
||||||
|
+ if (tls_var1 != 0x10)
|
||||||
|
+ abort ();
|
||||||
|
+ tls_var1 = 0x20;
|
||||||
|
+
|
||||||
|
+ tls_var2 = 0x2;
|
||||||
|
+ if (tls_var3 != 0x20)
|
||||||
|
+ abort ();
|
||||||
|
+ tls_var3 = 0x40;
|
||||||
|
+
|
||||||
|
+ call_libc ();
|
||||||
|
+
|
||||||
|
+ return LAV_CURRENT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+unsigned int
|
||||||
|
+la_objopen (struct link_map* map, Lmid_t lmid, uintptr_t* cookie)
|
||||||
|
+{
|
||||||
|
+ call_libc ();
|
||||||
|
+ *cookie = (uintptr_t) map;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_activity (uintptr_t* cookie, unsigned int flag)
|
||||||
|
+{
|
||||||
|
+ if (tls_var0 != 0x1 || tls_var1 != 0x20)
|
||||||
|
+ abort ();
|
||||||
|
+ call_libc ();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+la_preinit (uintptr_t* cookie)
|
||||||
|
+{
|
||||||
|
+ call_libc ();
|
||||||
|
+}
|
||||||
|
diff --git a/elf/tst-auditmod21b.c b/elf/tst-auditmod21b.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..6ba5335b7514c674
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/elf/tst-auditmod21b.c
|
||||||
|
@@ -0,0 +1,22 @@
|
||||||
|
+/* Check LD_AUDIT with static TLS.
|
||||||
|
+ Copyright (C) 2022 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/>. */
|
||||||
|
+
|
||||||
|
+#define tls_ie __attribute__ ((tls_model ("initial-exec")))
|
||||||
|
+
|
||||||
|
+__thread int tls_var2 tls_ie;
|
||||||
|
+__thread int tls_var3 tls_ie = 0x20;
|
||||||
|
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
|
||||||
|
index 50065bc9bd8a28e5..554a721f814b53c4 100644
|
||||||
|
--- a/nptl/allocatestack.c
|
||||||
|
+++ b/nptl/allocatestack.c
|
||||||
|
@@ -139,7 +139,7 @@ get_cached_stack (size_t *sizep, void **memp)
|
||||||
|
memset (dtv, '\0', (dtv[-1].counter + 1) * sizeof (dtv_t));
|
||||||
|
|
||||||
|
/* Re-initialize the TLS. */
|
||||||
|
- _dl_allocate_tls_init (TLS_TPADJ (result));
|
||||||
|
+ _dl_allocate_tls_init (TLS_TPADJ (result), true);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||||
|
index 686f0a7b9709eb10..a56060d0204cc453 100644
|
||||||
|
--- a/sysdeps/generic/ldsodefs.h
|
||||||
|
+++ b/sysdeps/generic/ldsodefs.h
|
||||||
|
@@ -1254,7 +1254,7 @@ extern void _dl_allocate_static_tls (struct link_map *map) attribute_hidden;
|
||||||
|
/* These are internal entry points to the two halves of _dl_allocate_tls,
|
||||||
|
only used within rtld.c itself at startup time. */
|
||||||
|
extern void *_dl_allocate_tls_storage (void) attribute_hidden;
|
||||||
|
-extern void *_dl_allocate_tls_init (void *);
|
||||||
|
+extern void *_dl_allocate_tls_init (void *, bool);
|
||||||
|
rtld_hidden_proto (_dl_allocate_tls_init)
|
||||||
|
|
||||||
|
/* Deallocate memory allocated with _dl_allocate_tls. */
|
1778
glibc-upstream-2.34-156.patch
Normal file
1778
glibc-upstream-2.34-156.patch
Normal file
File diff suppressed because it is too large
Load Diff
1042
glibc-upstream-2.34-157.patch
Normal file
1042
glibc-upstream-2.34-157.patch
Normal file
File diff suppressed because it is too large
Load Diff
23
glibc-upstream-2.34-158.patch
Normal file
23
glibc-upstream-2.34-158.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
commit 165e7ad459fbba2f89708fba04a55bb3981e884c
|
||||||
|
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||||
|
Date: Wed Feb 2 14:03:58 2022 +0000
|
||||||
|
|
||||||
|
Fix elf/tst-audit25a with default bind now toolchains
|
||||||
|
|
||||||
|
This test relies on lazy binding for the executable so request that
|
||||||
|
explicitly in case the toolchain defaults to bind now.
|
||||||
|
|
||||||
|
(cherry picked from commit 80a08d0faa9b224019f895800c4d97de4e23e1aa)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 0ab3e885f5e35671..9e4e056938a75ddb 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -2133,6 +2133,7 @@ $(objpfx)tst-audit25a: $(objpfx)tst-audit25mod1.so \
|
||||||
|
$(objpfx)tst-audit25mod2.so \
|
||||||
|
$(objpfx)tst-audit25mod3.so \
|
||||||
|
$(objpfx)tst-audit25mod4.so
|
||||||
|
+LDFLAGS-tst-audit25a = -Wl,-z,lazy
|
||||||
|
$(objpfx)tst-audit25mod1.so: $(objpfx)tst-audit25mod3.so
|
||||||
|
LDFLAGS-tst-audit25mod1.so = -Wl,-z,now
|
||||||
|
$(objpfx)tst-audit25mod2.so: $(objpfx)tst-audit25mod4.so
|
27
glibc-upstream-2.34-159.patch
Normal file
27
glibc-upstream-2.34-159.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
commit aabdad371f44defc6046aabdc96af7782a2e94be
|
||||||
|
Author: H.J. Lu <hjl.tools@gmail.com>
|
||||||
|
Date: Sun Feb 6 11:12:24 2022 -0800
|
||||||
|
|
||||||
|
elf: Replace tst-audit24bmod2.so with tst-audit24bmod2
|
||||||
|
|
||||||
|
Replace tst-audit24bmod2.so with tst-audit24bmod2 to silence:
|
||||||
|
|
||||||
|
make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/elf'
|
||||||
|
Makefile:2201: warning: overriding recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so'
|
||||||
|
../Makerules:765: warning: ignoring old recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so'
|
||||||
|
|
||||||
|
(cherry picked from commit fa7ad1df1915c8a62f50e3a5b7e10f9c7118cd7f)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 9e4e056938a75ddb..57059293d0bc86cb 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -888,7 +888,7 @@ extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
|
||||||
|
# filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
|
||||||
|
# rules.
|
||||||
|
modules-names-nobuild := filtmod1 tst-big-note-lib tst-ro-dynamic-mod \
|
||||||
|
- tst-audit24bmod1 tst-audit24bmod2.so
|
||||||
|
+ tst-audit24bmod1 tst-audit24bmod2
|
||||||
|
|
||||||
|
tests += $(tests-static)
|
||||||
|
|
114
glibc-upstream-2.34-160.patch
Normal file
114
glibc-upstream-2.34-160.patch
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
commit 4dca2d3a7b43bf99bd6a567870a3144af4e763ef
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Fri Feb 4 15:54:59 2022 -0300
|
||||||
|
|
||||||
|
hppa: Fix bind-now audit (BZ #28857)
|
||||||
|
|
||||||
|
On hppa, a function pointer returned by la_symbind is actually a function
|
||||||
|
descriptor has the plabel bit set (bit 30). This must be cleared to get
|
||||||
|
the actual address of the descriptor. If the descriptor has been bound,
|
||||||
|
the first word of the descriptor is the physical address of theA function,
|
||||||
|
otherwise, the first word of the descriptor points to a trampoline in the
|
||||||
|
PLT.
|
||||||
|
|
||||||
|
This patch also adds a workaround on tests because on hppa (and it seems
|
||||||
|
to be the only ABI I have see it), some shared library adds a dynamic PLT
|
||||||
|
relocation to am empty symbol name:
|
||||||
|
|
||||||
|
$ readelf -r elf/tst-audit25mod1.so
|
||||||
|
[...]
|
||||||
|
Relocation section '.rela.plt' at offset 0x464 contains 6 entries:
|
||||||
|
Offset Info Type Sym.Value Sym. Name + Addend
|
||||||
|
00002008 00000081 R_PARISC_IPLT 508
|
||||||
|
[...]
|
||||||
|
|
||||||
|
It breaks some assumptions on the test, where a symbol with an empty
|
||||||
|
name ("") is passed on la_symbind.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu and hppa-linux-gnu.
|
||||||
|
|
||||||
|
(cherry picked from commit 9e94f57484a2aba0fe67ea2059b5843f651887c2)
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 57059293d0bc86cb..3e17a0706f5ec2df 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -2116,7 +2116,7 @@ $(objpfx)tst-audit24c.out: $(objpfx)tst-auditmod24c.so
|
||||||
|
$(objpfx)tst-audit24c: $(objpfx)tst-audit24amod1.so \
|
||||||
|
$(objpfx)tst-audit24amod2.so
|
||||||
|
tst-audit24c-ENV = LD_BIND_NOW=1 LD_AUDIT=$(objpfx)tst-auditmod24c.so
|
||||||
|
-LDFLAGS-tst-audit24b = -Wl,-z,lazy
|
||||||
|
+LDFLAGS-tst-audit24c = -Wl,-z,lazy
|
||||||
|
|
||||||
|
$(objpfx)tst-audit24d.out: $(objpfx)tst-auditmod24d.so
|
||||||
|
$(objpfx)tst-audit24d: $(objpfx)tst-audit24dmod1.so \
|
||||||
|
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
|
||||||
|
index 72a50717ef60a357..ec9b032eae37c103 100644
|
||||||
|
--- a/elf/dl-audit.c
|
||||||
|
+++ b/elf/dl-audit.c
|
||||||
|
@@ -257,7 +257,8 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result,
|
||||||
|
reloc_result->flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
- DL_FIXUP_BINDNOW_RELOC (value, new_value, sym.st_value);
|
||||||
|
+ if (flags & LA_SYMB_ALTVALUE)
|
||||||
|
+ DL_FIXUP_BINDNOW_RELOC (value, new_value, sym.st_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
diff --git a/elf/tst-auditmod24a.c b/elf/tst-auditmod24a.c
|
||||||
|
index d8e88f3984af1707..3075dfae2fd3d288 100644
|
||||||
|
--- a/elf/tst-auditmod24a.c
|
||||||
|
+++ b/elf/tst-auditmod24a.c
|
||||||
|
@@ -110,5 +110,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
|
||||||
|
return sym->st_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
- abort ();
|
||||||
|
+ if (symname[0] != '\0')
|
||||||
|
+ abort ();
|
||||||
|
+ return sym->st_value;
|
||||||
|
}
|
||||||
|
diff --git a/elf/tst-auditmod24d.c b/elf/tst-auditmod24d.c
|
||||||
|
index 8c803ecc0a48f21b..badc6be451ee0357 100644
|
||||||
|
--- a/elf/tst-auditmod24d.c
|
||||||
|
+++ b/elf/tst-auditmod24d.c
|
||||||
|
@@ -116,5 +116,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- abort ();
|
||||||
|
+ if (symname[0] != '\0')
|
||||||
|
+ abort ();
|
||||||
|
+ return sym->st_value;
|
||||||
|
}
|
||||||
|
diff --git a/elf/tst-auditmod25.c b/elf/tst-auditmod25.c
|
||||||
|
index 526f5c54bc2c3b8c..20640a8daf346b5f 100644
|
||||||
|
--- a/elf/tst-auditmod25.c
|
||||||
|
+++ b/elf/tst-auditmod25.c
|
||||||
|
@@ -72,7 +72,7 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
|
||||||
|
unsigned int *flags, const char *symname)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
- if (*refcook != -1 && *defcook != -1)
|
||||||
|
+ if (*refcook != -1 && *defcook != -1 && symname[0] != '\0')
|
||||||
|
fprintf (stderr, "la_symbind: %s %u\n", symname,
|
||||||
|
*flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) ? 1 : 0);
|
||||||
|
return sym->st_value;
|
||||||
|
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
|
||||||
|
index f4f00714fa158e18..92fd0b7c844713ce 100644
|
||||||
|
--- a/sysdeps/hppa/dl-lookupcfg.h
|
||||||
|
+++ b/sysdeps/hppa/dl-lookupcfg.h
|
||||||
|
@@ -80,7 +80,9 @@ void attribute_hidden _dl_unmap (struct link_map *map);
|
||||||
|
/* Extract the code address from a fixup value */
|
||||||
|
#define DL_FIXUP_VALUE_CODE_ADDR(value) ((value).ip)
|
||||||
|
#define DL_FIXUP_VALUE_ADDR(value) ((uintptr_t) &(value))
|
||||||
|
-#define DL_FIXUP_ADDR_VALUE(addr) (*(struct fdesc *) (addr))
|
||||||
|
+/* Clear the plabel bit to get the actual address of the descriptor. */
|
||||||
|
+#define DL_FIXUP_ADDR_VALUE(addr) \
|
||||||
|
+ (*(DL_FIXUP_VALUE_TYPE *) ((uintptr_t) (addr) & ~2))
|
||||||
|
#define DL_FIXUP_BINDNOW_ADDR_VALUE(addr) (addr)
|
||||||
|
-#define DL_FIXUP_BINDNOW_RELOC(value, new_value, st_value) \
|
||||||
|
- (*value) = *(struct fdesc *) (st_value)
|
||||||
|
+#define DL_FIXUP_BINDNOW_RELOC(value, new_value, st_value) \
|
||||||
|
+ *(value) = *(DL_FIXUP_VALUE_TYPE *) ((uintptr_t) (new_value) & ~2)
|
242
glibc-upstream-2.34-162.patch
Normal file
242
glibc-upstream-2.34-162.patch
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
commit 0c03cb54c808173d8e7ba96f6152dfcf627ac496
|
||||||
|
Author: Stefan Liebler <stli@linux.ibm.com>
|
||||||
|
Date: Wed Apr 13 14:36:09 2022 +0200
|
||||||
|
|
||||||
|
S390: Add new s390 platform z16.
|
||||||
|
|
||||||
|
The new IBM z16 is added to platform string array.
|
||||||
|
The macro _DL_PLATFORMS_COUNT is incremented.
|
||||||
|
|
||||||
|
_dl_hwcaps_subdir is extended by "z16" if HWCAP_S390_VXRS_PDE2
|
||||||
|
is set. HWCAP_S390_NNPA is not tested in _dl_hwcaps_subdirs_active
|
||||||
|
as those instructions may be replaced or removed in future.
|
||||||
|
|
||||||
|
tst-glibc-hwcaps.c is extended in order to test z16 via new marker5.
|
||||||
|
|
||||||
|
A fatal glibc error is dumped if glibc was build with architecture
|
||||||
|
level set for z16, but run on an older machine. (See dl-hwcap-check.h)
|
||||||
|
|
||||||
|
(cherry picked from commit 2376944b9e5c0364b9fb473e4d8dabca31b57167)
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
sysdeps/s390/s390-64/dl-hwcap-check.h - Use GCCMACRO__ARCH__.
|
||||||
|
- Backported f01d482f0355a7029d0715ace0ccf3323e7e94bc requires it.
|
||||||
|
|
||||||
|
diff --git a/elf/Makefile b/elf/Makefile
|
||||||
|
index 3e17a0706f5ec2df..8e2dd91c583f9a62 100644
|
||||||
|
--- a/elf/Makefile
|
||||||
|
+++ b/elf/Makefile
|
||||||
|
@@ -571,6 +571,11 @@ modules-names = \
|
||||||
|
libmarkermod4-2 \
|
||||||
|
libmarkermod4-3 \
|
||||||
|
libmarkermod4-4 \
|
||||||
|
+ libmarkermod5-1 \
|
||||||
|
+ libmarkermod5-2 \
|
||||||
|
+ libmarkermod5-3 \
|
||||||
|
+ libmarkermod5-4 \
|
||||||
|
+ libmarkermod5-5 \
|
||||||
|
ltglobmod1 \
|
||||||
|
ltglobmod2 \
|
||||||
|
neededobj1 \
|
||||||
|
@@ -2412,6 +2417,7 @@ LDFLAGS-libmarkermod1-1.so += -Wl,-soname,libmarkermod1.so
|
||||||
|
LDFLAGS-libmarkermod2-1.so += -Wl,-soname,libmarkermod2.so
|
||||||
|
LDFLAGS-libmarkermod3-1.so += -Wl,-soname,libmarkermod3.so
|
||||||
|
LDFLAGS-libmarkermod4-1.so += -Wl,-soname,libmarkermod4.so
|
||||||
|
+LDFLAGS-libmarkermod5-1.so += -Wl,-soname,libmarkermod5.so
|
||||||
|
$(objpfx)libmarkermod%.os : markermodMARKER-VALUE.c
|
||||||
|
$(compile-command.c) \
|
||||||
|
-DMARKER=marker$(firstword $(subst -, ,$*)) \
|
||||||
|
@@ -2424,6 +2430,8 @@ $(objpfx)libmarkermod3.so: $(objpfx)libmarkermod3-1.so
|
||||||
|
cp $< $@
|
||||||
|
$(objpfx)libmarkermod4.so: $(objpfx)libmarkermod4-1.so
|
||||||
|
cp $< $@
|
||||||
|
+$(objpfx)libmarkermod5.so: $(objpfx)libmarkermod5-1.so
|
||||||
|
+ cp $< $@
|
||||||
|
|
||||||
|
# tst-glibc-hwcaps-prepend checks that --glibc-hwcaps-prepend is
|
||||||
|
# preferred over auto-detected subdirectories.
|
||||||
|
diff --git a/elf/tst-glibc-hwcaps-cache.script b/elf/tst-glibc-hwcaps-cache.script
|
||||||
|
index c3271f61f9e50f2e..d58fc8c5de3c5198 100644
|
||||||
|
--- a/elf/tst-glibc-hwcaps-cache.script
|
||||||
|
+++ b/elf/tst-glibc-hwcaps-cache.script
|
||||||
|
@@ -4,6 +4,7 @@
|
||||||
|
cp $B/elf/libmarkermod2-1.so $L/libmarkermod2.so
|
||||||
|
cp $B/elf/libmarkermod3-1.so $L/libmarkermod3.so
|
||||||
|
cp $B/elf/libmarkermod4-1.so $L/libmarkermod4.so
|
||||||
|
+cp $B/elf/libmarkermod5-1.so $L/libmarkermod5.so
|
||||||
|
|
||||||
|
mkdirp 0770 $L/glibc-hwcaps/power9
|
||||||
|
cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/power9/libmarkermod2.so
|
||||||
|
@@ -20,6 +21,11 @@ mkdirp 0770 $L/glibc-hwcaps/z15
|
||||||
|
cp $B/elf/libmarkermod4-2.so $L/glibc-hwcaps/z13/libmarkermod4.so
|
||||||
|
cp $B/elf/libmarkermod4-3.so $L/glibc-hwcaps/z14/libmarkermod4.so
|
||||||
|
cp $B/elf/libmarkermod4-4.so $L/glibc-hwcaps/z15/libmarkermod4.so
|
||||||
|
+mkdirp 0770 $L/glibc-hwcaps/z16
|
||||||
|
+cp $B/elf/libmarkermod5-2.so $L/glibc-hwcaps/z13/libmarkermod5.so
|
||||||
|
+cp $B/elf/libmarkermod5-3.so $L/glibc-hwcaps/z14/libmarkermod5.so
|
||||||
|
+cp $B/elf/libmarkermod5-4.so $L/glibc-hwcaps/z15/libmarkermod5.so
|
||||||
|
+cp $B/elf/libmarkermod5-5.so $L/glibc-hwcaps/z16/libmarkermod5.so
|
||||||
|
|
||||||
|
mkdirp 0770 $L/glibc-hwcaps/x86-64-v2
|
||||||
|
cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/x86-64-v2/libmarkermod2.so
|
||||||
|
diff --git a/sysdeps/s390/dl-procinfo.c b/sysdeps/s390/dl-procinfo.c
|
||||||
|
index 155f0bd99eccb3f9..755b54ff13a0fa2f 100644
|
||||||
|
--- a/sysdeps/s390/dl-procinfo.c
|
||||||
|
+++ b/sysdeps/s390/dl-procinfo.c
|
||||||
|
@@ -64,11 +64,12 @@ PROCINFO_CLASS const char _dl_s390_cap_flags[23][9]
|
||||||
|
#if !defined PROCINFO_DECL && defined SHARED
|
||||||
|
._dl_s390_platforms
|
||||||
|
#else
|
||||||
|
-PROCINFO_CLASS const char _dl_s390_platforms[10][7]
|
||||||
|
+PROCINFO_CLASS const char _dl_s390_platforms[11][7]
|
||||||
|
#endif
|
||||||
|
#ifndef PROCINFO_DECL
|
||||||
|
= {
|
||||||
|
- "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15"
|
||||||
|
+ "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15",
|
||||||
|
+ "z16"
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if !defined SHARED || defined PROCINFO_DECL
|
||||||
|
diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h
|
||||||
|
index e4e3e334a5b3d47c..d44e1dd97441bd90 100644
|
||||||
|
--- a/sysdeps/s390/dl-procinfo.h
|
||||||
|
+++ b/sysdeps/s390/dl-procinfo.h
|
||||||
|
@@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
#define _DL_HWCAP_COUNT 23
|
||||||
|
|
||||||
|
-#define _DL_PLATFORMS_COUNT 10
|
||||||
|
+#define _DL_PLATFORMS_COUNT 11
|
||||||
|
|
||||||
|
/* The kernel provides up to 32 capability bits with elf_hwcap. */
|
||||||
|
#define _DL_FIRST_PLATFORM 32
|
||||||
|
diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile
|
||||||
|
index e5da26871c862e63..66ed844e68df5159 100644
|
||||||
|
--- a/sysdeps/s390/s390-64/Makefile
|
||||||
|
+++ b/sysdeps/s390/s390-64/Makefile
|
||||||
|
@@ -7,8 +7,11 @@ CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
|
||||||
|
CFLAGS-dl-load.c += -Wno-unused
|
||||||
|
CFLAGS-dl-reloc.c += -Wno-unused
|
||||||
|
|
||||||
|
-$(objpfx)tst-glibc-hwcaps: $(objpfx)libmarkermod2-1.so \
|
||||||
|
- $(objpfx)libmarkermod3-1.so $(objpfx)libmarkermod4-1.so
|
||||||
|
+$(objpfx)tst-glibc-hwcaps: \
|
||||||
|
+ $(objpfx)libmarkermod2-1.so \
|
||||||
|
+ $(objpfx)libmarkermod3-1.so \
|
||||||
|
+ $(objpfx)libmarkermod4-1.so \
|
||||||
|
+ $(objpfx)libmarkermod5-1.so
|
||||||
|
$(objpfx)tst-glibc-hwcaps.out: \
|
||||||
|
$(objpfx)libmarkermod2.so \
|
||||||
|
$(objpfx)glibc-hwcaps/z13/libmarkermod2.so \
|
||||||
|
@@ -19,6 +22,11 @@ $(objpfx)tst-glibc-hwcaps.out: \
|
||||||
|
$(objpfx)glibc-hwcaps/z13/libmarkermod4.so \
|
||||||
|
$(objpfx)glibc-hwcaps/z14/libmarkermod4.so \
|
||||||
|
$(objpfx)glibc-hwcaps/z15/libmarkermod4.so \
|
||||||
|
+ $(objpfx)libmarkermod5.so \
|
||||||
|
+ $(objpfx)glibc-hwcaps/z13/libmarkermod5.so \
|
||||||
|
+ $(objpfx)glibc-hwcaps/z14/libmarkermod5.so \
|
||||||
|
+ $(objpfx)glibc-hwcaps/z15/libmarkermod5.so \
|
||||||
|
+ $(objpfx)glibc-hwcaps/z16/libmarkermod5.so
|
||||||
|
|
||||||
|
$(objpfx)glibc-hwcaps/z13/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
|
||||||
|
$(make-target-directory)
|
||||||
|
@@ -38,6 +46,19 @@ $(objpfx)glibc-hwcaps/z14/libmarkermod4.so: $(objpfx)libmarkermod4-3.so
|
||||||
|
$(objpfx)glibc-hwcaps/z15/libmarkermod4.so: $(objpfx)libmarkermod4-4.so
|
||||||
|
$(make-target-directory)
|
||||||
|
cp $< $@
|
||||||
|
+$(objpfx)glibc-hwcaps/z13/libmarkermod5.so: $(objpfx)libmarkermod5-2.so
|
||||||
|
+ $(make-target-directory)
|
||||||
|
+ cp $< $@
|
||||||
|
+$(objpfx)glibc-hwcaps/z14/libmarkermod5.so: $(objpfx)libmarkermod5-3.so
|
||||||
|
+ $(make-target-directory)
|
||||||
|
+ cp $< $@
|
||||||
|
+$(objpfx)glibc-hwcaps/z15/libmarkermod5.so: $(objpfx)libmarkermod5-4.so
|
||||||
|
+ $(make-target-directory)
|
||||||
|
+ cp $< $@
|
||||||
|
+$(objpfx)glibc-hwcaps/z16/libmarkermod5.so: $(objpfx)libmarkermod5-5.so
|
||||||
|
+ $(make-target-directory)
|
||||||
|
+ cp $< $@
|
||||||
|
+
|
||||||
|
|
||||||
|
ifeq (no,$(build-hardcoded-path-in-tests))
|
||||||
|
# This is an ld.so.cache test, and RPATH/RUNPATH in the executable
|
||||||
|
diff --git a/sysdeps/s390/s390-64/dl-hwcap-check.h b/sysdeps/s390/s390-64/dl-hwcap-check.h
|
||||||
|
index 27f7e245b1d1a9e9..52c609571b32f4ab 100644
|
||||||
|
--- a/sysdeps/s390/s390-64/dl-hwcap-check.h
|
||||||
|
+++ b/sysdeps/s390/s390-64/dl-hwcap-check.h
|
||||||
|
@@ -26,7 +26,11 @@ static inline void
|
||||||
|
dl_hwcap_check (void)
|
||||||
|
{
|
||||||
|
#if defined __ARCH__
|
||||||
|
-# if GCCMACRO__ARCH__ >= 13
|
||||||
|
+# if GCCMACRO__ARCH__ >= 14
|
||||||
|
+ if (!(GLRO(dl_hwcap) & HWCAP_S390_VXRS_PDE2))
|
||||||
|
+ _dl_fatal_printf ("\
|
||||||
|
+Fatal glibc error: CPU lacks VXRS_PDE2 support (z16 or later required)\n");
|
||||||
|
+# elif GCCMACRO__ARCH__ >= 13
|
||||||
|
if (!(GLRO(dl_hwcap) & HWCAP_S390_VXRS_EXT2))
|
||||||
|
_dl_fatal_printf ("\
|
||||||
|
Fatal glibc error: CPU lacks VXRS_EXT2 support (z15 or later required)\n");
|
||||||
|
diff --git a/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
|
||||||
|
index b9d094f3d73c2d7a..187d732d560c4a62 100644
|
||||||
|
--- a/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
|
||||||
|
+++ b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
|
||||||
|
@@ -19,8 +19,8 @@
|
||||||
|
#include <dl-hwcaps.h>
|
||||||
|
#include <ldsodefs.h>
|
||||||
|
|
||||||
|
-const char _dl_hwcaps_subdirs[] = "z15:z14:z13";
|
||||||
|
-enum { subdirs_count = 3 }; /* Number of components in _dl_hwcaps_subdirs. */
|
||||||
|
+const char _dl_hwcaps_subdirs[] = "z16:z15:z14:z13";
|
||||||
|
+enum { subdirs_count = 4 }; /* Number of components in _dl_hwcaps_subdirs. */
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
_dl_hwcaps_subdirs_active (void)
|
||||||
|
@@ -50,5 +50,12 @@ _dl_hwcaps_subdirs_active (void)
|
||||||
|
return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
||||||
|
++active;
|
||||||
|
|
||||||
|
+ /* z16.
|
||||||
|
+ Note: We do not list HWCAP_S390_NNPA here as, according to the Principles of
|
||||||
|
+ Operation, those instructions may be replaced or removed in future. */
|
||||||
|
+ if (!(GLRO (dl_hwcap) & HWCAP_S390_VXRS_PDE2))
|
||||||
|
+ return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
||||||
|
+ ++active;
|
||||||
|
+
|
||||||
|
return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
||||||
|
}
|
||||||
|
diff --git a/sysdeps/s390/s390-64/tst-glibc-hwcaps.c b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
|
||||||
|
index 02397a478c552516..f3b8ef3dec80d2d1 100644
|
||||||
|
--- a/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
|
||||||
|
+++ b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
extern int marker2 (void);
|
||||||
|
extern int marker3 (void);
|
||||||
|
extern int marker4 (void);
|
||||||
|
+extern int marker5 (void);
|
||||||
|
|
||||||
|
/* Return the arch level, 10 for the baseline libmarkermod*.so's. */
|
||||||
|
static int
|
||||||
|
@@ -63,9 +64,11 @@ compute_level (void)
|
||||||
|
return 12;
|
||||||
|
if (strcmp (platform, "z15") == 0)
|
||||||
|
return 13;
|
||||||
|
+ if (strcmp (platform, "z16") == 0)
|
||||||
|
+ return 14;
|
||||||
|
printf ("warning: unrecognized AT_PLATFORM value: %s\n", platform);
|
||||||
|
- /* Assume that the new platform supports z15. */
|
||||||
|
- return 13;
|
||||||
|
+ /* Assume that the new platform supports z16. */
|
||||||
|
+ return 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
@@ -76,6 +79,7 @@ do_test (void)
|
||||||
|
TEST_COMPARE (marker2 (), MIN (level - 9, 2));
|
||||||
|
TEST_COMPARE (marker3 (), MIN (level - 9, 3));
|
||||||
|
TEST_COMPARE (marker4 (), MIN (level - 9, 4));
|
||||||
|
+ TEST_COMPARE (marker5 (), MIN (level - 9, 5));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
834
glibc-upstream-2.34-163.patch
Normal file
834
glibc-upstream-2.34-163.patch
Normal file
@ -0,0 +1,834 @@
|
|||||||
|
commit 290db09546b260a30137d03ce97a857e6f15b648
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Wed Apr 6 12:24:42 2022 -0300
|
||||||
|
|
||||||
|
nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
|
||||||
|
|
||||||
|
Some Linux interfaces never restart after being interrupted by a signal
|
||||||
|
handler, regardless of the use of SA_RESTART [1]. It means that for
|
||||||
|
pthread cancellation, if the target thread disables cancellation with
|
||||||
|
pthread_setcancelstate and calls such interfaces (like poll or select),
|
||||||
|
it should not see spurious EINTR failures due the internal SIGCANCEL.
|
||||||
|
|
||||||
|
However recent changes made pthread_cancel to always sent the internal
|
||||||
|
signal, regardless of the target thread cancellation status or type.
|
||||||
|
To fix it, the previous semantic is restored, where the cancel signal
|
||||||
|
is only sent if the target thread has cancelation enabled in
|
||||||
|
asynchronous mode.
|
||||||
|
|
||||||
|
The cancel state and cancel type is moved back to cancelhandling
|
||||||
|
and atomic operation are used to synchronize between threads. The
|
||||||
|
patch essentially revert the following commits:
|
||||||
|
|
||||||
|
8c1c0aae20 nptl: Move cancel type out of cancelhandling
|
||||||
|
2b51742531 nptl: Move cancel state out of cancelhandling
|
||||||
|
26cfbb7162 nptl: Remove CANCELING_BITMASK
|
||||||
|
|
||||||
|
However I changed the atomic operation to follow the internal C11
|
||||||
|
semantic and removed the MACRO usage, it simplifies a bit the
|
||||||
|
resulting code (and removes another usage of the old atomic macros).
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
|
||||||
|
and powerpc64-linux-gnu.
|
||||||
|
|
||||||
|
[1] https://man7.org/linux/man-pages/man7/signal.7.html
|
||||||
|
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
|
||||||
|
|
||||||
|
(cherry-picked from commit 404656009b459658138ed1bd18f3c6cf3863e6a6)
|
||||||
|
|
||||||
|
diff --git a/manual/process.texi b/manual/process.texi
|
||||||
|
index 28c9531f4294f56e..9307379194c6f666 100644
|
||||||
|
--- a/manual/process.texi
|
||||||
|
+++ b/manual/process.texi
|
||||||
|
@@ -68,8 +68,7 @@ until the subprogram terminates before you can do anything else.
|
||||||
|
@c CLEANUP_HANDLER @ascuplugin @ascuheap @acsmem
|
||||||
|
@c libc_cleanup_region_start @ascuplugin @ascuheap @acsmem
|
||||||
|
@c pthread_cleanup_push_defer @ascuplugin @ascuheap @acsmem
|
||||||
|
-@c __pthread_testcancel @ascuplugin @ascuheap @acsmem
|
||||||
|
-@c CANCEL_ENABLED_AND_CANCELED ok
|
||||||
|
+@c cancel_enabled_and_canceled @ascuplugin @ascuheap @acsmem
|
||||||
|
@c do_cancel @ascuplugin @ascuheap @acsmem
|
||||||
|
@c cancel_handler ok
|
||||||
|
@c kill syscall ok
|
||||||
|
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
|
||||||
|
index 554a721f814b53c4..96101753ec2f4323 100644
|
||||||
|
--- a/nptl/allocatestack.c
|
||||||
|
+++ b/nptl/allocatestack.c
|
||||||
|
@@ -120,8 +120,6 @@ get_cached_stack (size_t *sizep, void **memp)
|
||||||
|
|
||||||
|
/* Cancellation handling is back to the default. */
|
||||||
|
result->cancelhandling = 0;
|
||||||
|
- result->cancelstate = PTHREAD_CANCEL_ENABLE;
|
||||||
|
- result->canceltype = PTHREAD_CANCEL_DEFERRED;
|
||||||
|
result->cleanup = NULL;
|
||||||
|
result->setup_failed = 0;
|
||||||
|
|
||||||
|
diff --git a/nptl/cancellation.c b/nptl/cancellation.c
|
||||||
|
index 05962784d51fb98b..e97d56f97d7a5698 100644
|
||||||
|
--- a/nptl/cancellation.c
|
||||||
|
+++ b/nptl/cancellation.c
|
||||||
|
@@ -31,19 +31,26 @@ int
|
||||||
|
__pthread_enable_asynccancel (void)
|
||||||
|
{
|
||||||
|
struct pthread *self = THREAD_SELF;
|
||||||
|
+ int oldval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
|
||||||
|
- int oldval = THREAD_GETMEM (self, canceltype);
|
||||||
|
- THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_ASYNCHRONOUS);
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ int newval = oldval | CANCELTYPE_BITMASK;
|
||||||
|
|
||||||
|
- int ch = THREAD_GETMEM (self, cancelhandling);
|
||||||
|
+ if (newval == oldval)
|
||||||
|
+ break;
|
||||||
|
|
||||||
|
- if (self->cancelstate == PTHREAD_CANCEL_ENABLE
|
||||||
|
- && (ch & CANCELED_BITMASK)
|
||||||
|
- && !(ch & EXITING_BITMASK)
|
||||||
|
- && !(ch & TERMINATED_BITMASK))
|
||||||
|
- {
|
||||||
|
- THREAD_SETMEM (self, result, PTHREAD_CANCELED);
|
||||||
|
- __do_cancel ();
|
||||||
|
+ if (atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &oldval, newval))
|
||||||
|
+ {
|
||||||
|
+ if (cancel_enabled_and_canceled_and_async (newval))
|
||||||
|
+ {
|
||||||
|
+ self->result = PTHREAD_CANCELED;
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldval;
|
||||||
|
@@ -57,10 +64,29 @@ __pthread_disable_asynccancel (int oldtype)
|
||||||
|
{
|
||||||
|
/* If asynchronous cancellation was enabled before we do not have
|
||||||
|
anything to do. */
|
||||||
|
- if (oldtype == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
+ if (oldtype & CANCELTYPE_BITMASK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct pthread *self = THREAD_SELF;
|
||||||
|
- self->canceltype = PTHREAD_CANCEL_DEFERRED;
|
||||||
|
+ int newval;
|
||||||
|
+ int oldval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ do
|
||||||
|
+ {
|
||||||
|
+ newval = oldval & ~CANCELTYPE_BITMASK;
|
||||||
|
+ }
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &oldval, newval));
|
||||||
|
+
|
||||||
|
+ /* We cannot return when we are being canceled. Upon return the
|
||||||
|
+ thread might be things which would have to be undone. The
|
||||||
|
+ following loop should loop until the cancellation signal is
|
||||||
|
+ delivered. */
|
||||||
|
+ while (__glibc_unlikely ((newval & (CANCELING_BITMASK | CANCELED_BITMASK))
|
||||||
|
+ == CANCELING_BITMASK))
|
||||||
|
+ {
|
||||||
|
+ futex_wait_simple ((unsigned int *) &self->cancelhandling, newval,
|
||||||
|
+ FUTEX_PRIVATE);
|
||||||
|
+ newval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
libc_hidden_def (__pthread_disable_asynccancel)
|
||||||
|
diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c
|
||||||
|
index 7e858d0df068276b..35ba40fb0247c7cc 100644
|
||||||
|
--- a/nptl/cleanup_defer.c
|
||||||
|
+++ b/nptl/cleanup_defer.c
|
||||||
|
@@ -31,9 +31,22 @@ ___pthread_register_cancel_defer (__pthread_unwind_buf_t *buf)
|
||||||
|
ibuf->priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
|
||||||
|
ibuf->priv.data.cleanup = THREAD_GETMEM (self, cleanup);
|
||||||
|
|
||||||
|
- /* Disable asynchronous cancellation for now. */
|
||||||
|
- ibuf->priv.data.canceltype = THREAD_GETMEM (self, canceltype);
|
||||||
|
- THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
|
||||||
|
+ int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK))
|
||||||
|
+ {
|
||||||
|
+ int newval;
|
||||||
|
+ do
|
||||||
|
+ {
|
||||||
|
+ newval = cancelhandling & ~CANCELTYPE_BITMASK;
|
||||||
|
+ }
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &cancelhandling,
|
||||||
|
+ newval));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ibuf->priv.data.canceltype = (cancelhandling & CANCELTYPE_BITMASK
|
||||||
|
+ ? PTHREAD_CANCEL_ASYNCHRONOUS
|
||||||
|
+ : PTHREAD_CANCEL_DEFERRED);
|
||||||
|
|
||||||
|
/* Store the new cleanup handler info. */
|
||||||
|
THREAD_SETMEM (self, cleanup_jmp_buf, (struct pthread_unwind_buf *) buf);
|
||||||
|
@@ -55,9 +68,26 @@ ___pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf)
|
||||||
|
|
||||||
|
THREAD_SETMEM (self, cleanup_jmp_buf, ibuf->priv.data.prev);
|
||||||
|
|
||||||
|
- THREAD_SETMEM (self, canceltype, ibuf->priv.data.canceltype);
|
||||||
|
- if (ibuf->priv.data.canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
- __pthread_testcancel ();
|
||||||
|
+ if (ibuf->priv.data.canceltype == PTHREAD_CANCEL_DEFERRED)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ if (cancelhandling & CANCELTYPE_BITMASK)
|
||||||
|
+ {
|
||||||
|
+ int newval;
|
||||||
|
+ do
|
||||||
|
+ {
|
||||||
|
+ newval = cancelhandling | CANCELTYPE_BITMASK;
|
||||||
|
+ }
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &cancelhandling, newval));
|
||||||
|
+
|
||||||
|
+ if (cancel_enabled_and_canceled (cancelhandling))
|
||||||
|
+ {
|
||||||
|
+ self->result = PTHREAD_CANCELED;
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
versioned_symbol (libc, ___pthread_unregister_cancel_restore,
|
||||||
|
__pthread_unregister_cancel_restore, GLIBC_2_34);
|
||||||
|
diff --git a/nptl/descr.h b/nptl/descr.h
|
||||||
|
index dabf980e29615db3..dfef9c4bda075d13 100644
|
||||||
|
--- a/nptl/descr.h
|
||||||
|
+++ b/nptl/descr.h
|
||||||
|
@@ -280,18 +280,27 @@ struct pthread
|
||||||
|
|
||||||
|
/* Flags determining processing of cancellation. */
|
||||||
|
int cancelhandling;
|
||||||
|
+ /* Bit set if cancellation is disabled. */
|
||||||
|
+#define CANCELSTATE_BIT 0
|
||||||
|
+#define CANCELSTATE_BITMASK (1 << CANCELSTATE_BIT)
|
||||||
|
+ /* Bit set if asynchronous cancellation mode is selected. */
|
||||||
|
+#define CANCELTYPE_BIT 1
|
||||||
|
+#define CANCELTYPE_BITMASK (1 << CANCELTYPE_BIT)
|
||||||
|
+ /* Bit set if canceling has been initiated. */
|
||||||
|
+#define CANCELING_BIT 2
|
||||||
|
+#define CANCELING_BITMASK (1 << CANCELING_BIT)
|
||||||
|
/* Bit set if canceled. */
|
||||||
|
#define CANCELED_BIT 3
|
||||||
|
-#define CANCELED_BITMASK (0x01 << CANCELED_BIT)
|
||||||
|
+#define CANCELED_BITMASK (1 << CANCELED_BIT)
|
||||||
|
/* Bit set if thread is exiting. */
|
||||||
|
#define EXITING_BIT 4
|
||||||
|
-#define EXITING_BITMASK (0x01 << EXITING_BIT)
|
||||||
|
+#define EXITING_BITMASK (1 << EXITING_BIT)
|
||||||
|
/* Bit set if thread terminated and TCB is freed. */
|
||||||
|
#define TERMINATED_BIT 5
|
||||||
|
-#define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
|
||||||
|
+#define TERMINATED_BITMASK (1 << TERMINATED_BIT)
|
||||||
|
/* Bit set if thread is supposed to change XID. */
|
||||||
|
#define SETXID_BIT 6
|
||||||
|
-#define SETXID_BITMASK (0x01 << SETXID_BIT)
|
||||||
|
+#define SETXID_BITMASK (1 << SETXID_BIT)
|
||||||
|
|
||||||
|
/* Flags. Including those copied from the thread attribute. */
|
||||||
|
int flags;
|
||||||
|
@@ -391,14 +400,6 @@ struct pthread
|
||||||
|
/* Indicates whether is a C11 thread created by thrd_creat. */
|
||||||
|
bool c11;
|
||||||
|
|
||||||
|
- /* Thread cancel state (PTHREAD_CANCEL_ENABLE or
|
||||||
|
- PTHREAD_CANCEL_DISABLE). */
|
||||||
|
- unsigned char cancelstate;
|
||||||
|
-
|
||||||
|
- /* Thread cancel type (PTHREAD_CANCEL_DEFERRED or
|
||||||
|
- PTHREAD_CANCEL_ASYNCHRONOUS). */
|
||||||
|
- unsigned char canceltype;
|
||||||
|
-
|
||||||
|
/* Used in __pthread_kill_internal to detected a thread that has
|
||||||
|
exited or is about to exit. exit_lock must only be acquired
|
||||||
|
after blocking signals. */
|
||||||
|
@@ -418,6 +419,22 @@ struct pthread
|
||||||
|
(sizeof (struct pthread) - offsetof (struct pthread, end_padding))
|
||||||
|
} __attribute ((aligned (TCB_ALIGNMENT)));
|
||||||
|
|
||||||
|
+static inline bool
|
||||||
|
+cancel_enabled_and_canceled (int value)
|
||||||
|
+{
|
||||||
|
+ return (value & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
|
||||||
|
+ | TERMINATED_BITMASK))
|
||||||
|
+ == CANCELED_BITMASK;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool
|
||||||
|
+cancel_enabled_and_canceled_and_async (int value)
|
||||||
|
+{
|
||||||
|
+ return ((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK
|
||||||
|
+ | EXITING_BITMASK | TERMINATED_BITMASK))
|
||||||
|
+ == (CANCELTYPE_BITMASK | CANCELED_BITMASK);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* This yields the pointer that TLS support code calls the thread pointer. */
|
||||||
|
#if TLS_TCB_AT_TP
|
||||||
|
# define TLS_TPADJ(pd) (pd)
|
||||||
|
diff --git a/nptl/libc-cleanup.c b/nptl/libc-cleanup.c
|
||||||
|
index 180d15bc9e9a8368..fccb1abe69aa693c 100644
|
||||||
|
--- a/nptl/libc-cleanup.c
|
||||||
|
+++ b/nptl/libc-cleanup.c
|
||||||
|
@@ -27,9 +27,24 @@ __libc_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer)
|
||||||
|
|
||||||
|
buffer->__prev = THREAD_GETMEM (self, cleanup);
|
||||||
|
|
||||||
|
+ int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+
|
||||||
|
/* Disable asynchronous cancellation for now. */
|
||||||
|
- buffer->__canceltype = THREAD_GETMEM (self, canceltype);
|
||||||
|
- THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
|
||||||
|
+ if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK))
|
||||||
|
+ {
|
||||||
|
+ int newval;
|
||||||
|
+ do
|
||||||
|
+ {
|
||||||
|
+ newval = cancelhandling & ~CANCELTYPE_BITMASK;
|
||||||
|
+ }
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &cancelhandling,
|
||||||
|
+ newval));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ buffer->__canceltype = (cancelhandling & CANCELTYPE_BITMASK
|
||||||
|
+ ? PTHREAD_CANCEL_ASYNCHRONOUS
|
||||||
|
+ : PTHREAD_CANCEL_DEFERRED);
|
||||||
|
|
||||||
|
THREAD_SETMEM (self, cleanup, buffer);
|
||||||
|
}
|
||||||
|
@@ -42,8 +57,22 @@ __libc_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer)
|
||||||
|
|
||||||
|
THREAD_SETMEM (self, cleanup, buffer->__prev);
|
||||||
|
|
||||||
|
- THREAD_SETMEM (self, canceltype, buffer->__canceltype);
|
||||||
|
- if (buffer->__canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
- __pthread_testcancel ();
|
||||||
|
+ int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ if (cancelhandling & CANCELTYPE_BITMASK)
|
||||||
|
+ {
|
||||||
|
+ int newval;
|
||||||
|
+ do
|
||||||
|
+ {
|
||||||
|
+ newval = cancelhandling | CANCELTYPE_BITMASK;
|
||||||
|
+ }
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &cancelhandling, newval));
|
||||||
|
+
|
||||||
|
+ if (cancel_enabled_and_canceled (cancelhandling))
|
||||||
|
+ {
|
||||||
|
+ self->result = PTHREAD_CANCELED;
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
libc_hidden_def (__libc_cleanup_pop_restore)
|
||||||
|
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
|
||||||
|
index 9bac6e3b76a20312..2680b55586e035fe 100644
|
||||||
|
--- a/nptl/pthread_cancel.c
|
||||||
|
+++ b/nptl/pthread_cancel.c
|
||||||
|
@@ -43,18 +43,29 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx)
|
||||||
|
|
||||||
|
struct pthread *self = THREAD_SELF;
|
||||||
|
|
||||||
|
- int ch = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
- /* Cancelation not enabled, not cancelled, or already exitting. */
|
||||||
|
- if (self->cancelstate == PTHREAD_CANCEL_DISABLE
|
||||||
|
- || (ch & CANCELED_BITMASK) == 0
|
||||||
|
- || (ch & EXITING_BITMASK) != 0)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- /* Set the return value. */
|
||||||
|
- THREAD_SETMEM (self, result, PTHREAD_CANCELED);
|
||||||
|
- /* Make sure asynchronous cancellation is still enabled. */
|
||||||
|
- if (self->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
- __do_cancel ();
|
||||||
|
+ int oldval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ /* We are canceled now. When canceled by another thread this flag
|
||||||
|
+ is already set but if the signal is directly send (internally or
|
||||||
|
+ from another process) is has to be done here. */
|
||||||
|
+ int newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
|
||||||
|
+
|
||||||
|
+ if (oldval == newval || (oldval & EXITING_BITMASK) != 0)
|
||||||
|
+ /* Already canceled or exiting. */
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ if (atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &oldval, newval))
|
||||||
|
+ {
|
||||||
|
+ self->result = PTHREAD_CANCELED;
|
||||||
|
+
|
||||||
|
+ /* Make sure asynchronous cancellation is still enabled. */
|
||||||
|
+ if ((oldval & CANCELTYPE_BITMASK) != 0)
|
||||||
|
+ /* Run the registered destructors and terminate the thread. */
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -93,29 +104,70 @@ __pthread_cancel (pthread_t th)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- int oldch = atomic_fetch_or_acquire (&pd->cancelhandling, CANCELED_BITMASK);
|
||||||
|
- if ((oldch & CANCELED_BITMASK) != 0)
|
||||||
|
- return 0;
|
||||||
|
-
|
||||||
|
- if (pd == THREAD_SELF)
|
||||||
|
+ /* Some syscalls are never restarted after being interrupted by a signal
|
||||||
|
+ handler, regardless of the use of SA_RESTART (they always fail with
|
||||||
|
+ EINTR). So pthread_cancel cannot send SIGCANCEL unless the cancellation
|
||||||
|
+ is enabled and set as asynchronous (in this case the cancellation will
|
||||||
|
+ be acted in the cancellation handler instead by the syscall wrapper).
|
||||||
|
+ Otherwise the target thread is set as 'cancelling' (CANCELING_BITMASK)
|
||||||
|
+ by atomically setting 'cancelhandling' and the cancelation will be acted
|
||||||
|
+ upon on next cancellation entrypoing in the target thread.
|
||||||
|
+
|
||||||
|
+ It also requires to atomically check if cancellation is enabled and
|
||||||
|
+ asynchronous, so both cancellation state and type are tracked on
|
||||||
|
+ 'cancelhandling'. */
|
||||||
|
+
|
||||||
|
+ int result = 0;
|
||||||
|
+ int oldval = atomic_load_relaxed (&pd->cancelhandling);
|
||||||
|
+ int newval;
|
||||||
|
+ do
|
||||||
|
{
|
||||||
|
- /* A single-threaded process should be able to kill itself, since there
|
||||||
|
- is nothing in the POSIX specification that says that it cannot. So
|
||||||
|
- we set multiple_threads to true so that cancellation points get
|
||||||
|
- executed. */
|
||||||
|
- THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
|
||||||
|
+ newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
|
||||||
|
+ if (oldval == newval)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ /* If the cancellation is handled asynchronously just send a
|
||||||
|
+ signal. We avoid this if possible since it's more
|
||||||
|
+ expensive. */
|
||||||
|
+ if (cancel_enabled_and_canceled_and_async (newval))
|
||||||
|
+ {
|
||||||
|
+ /* Mark the cancellation as "in progress". */
|
||||||
|
+ int newval2 = oldval | CANCELING_BITMASK;
|
||||||
|
+ if (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling,
|
||||||
|
+ &oldval, newval2))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ if (pd == THREAD_SELF)
|
||||||
|
+ /* This is not merely an optimization: An application may
|
||||||
|
+ call pthread_cancel (pthread_self ()) without calling
|
||||||
|
+ pthread_create, so the signal handler may not have been
|
||||||
|
+ set up for a self-cancel. */
|
||||||
|
+ {
|
||||||
|
+ pd->result = PTHREAD_CANCELED;
|
||||||
|
+ if ((newval & CANCELTYPE_BITMASK) != 0)
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ /* The cancellation handler will take care of marking the
|
||||||
|
+ thread as canceled. */
|
||||||
|
+ result = __pthread_kill_internal (th, SIGCANCEL);
|
||||||
|
+
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* A single-threaded process should be able to kill itself, since
|
||||||
|
+ there is nothing in the POSIX specification that says that it
|
||||||
|
+ cannot. So we set multiple_threads to true so that cancellation
|
||||||
|
+ points get executed. */
|
||||||
|
+ THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
|
||||||
|
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
|
||||||
|
__libc_multiple_threads = 1;
|
||||||
|
#endif
|
||||||
|
-
|
||||||
|
- THREAD_SETMEM (pd, result, PTHREAD_CANCELED);
|
||||||
|
- if (pd->cancelstate == PTHREAD_CANCEL_ENABLE
|
||||||
|
- && pd->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
- __do_cancel ();
|
||||||
|
- return 0;
|
||||||
|
}
|
||||||
|
+ while (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling, &oldval,
|
||||||
|
+ newval));
|
||||||
|
|
||||||
|
- return __pthread_kill_internal (th, SIGCANCEL);
|
||||||
|
+ return result;
|
||||||
|
}
|
||||||
|
versioned_symbol (libc, __pthread_cancel, pthread_cancel, GLIBC_2_34);
|
||||||
|
|
||||||
|
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
|
||||||
|
index 7303069316caef13..617056ef10671607 100644
|
||||||
|
--- a/nptl/pthread_join_common.c
|
||||||
|
+++ b/nptl/pthread_join_common.c
|
||||||
|
@@ -57,12 +57,9 @@ __pthread_clockjoin_ex (pthread_t threadid, void **thread_return,
|
||||||
|
if ((pd == self
|
||||||
|
|| (self->joinid == pd
|
||||||
|
&& (pd->cancelhandling
|
||||||
|
- & (CANCELED_BITMASK | EXITING_BITMASK
|
||||||
|
+ & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
|
||||||
|
| TERMINATED_BITMASK)) == 0))
|
||||||
|
- && !(self->cancelstate == PTHREAD_CANCEL_ENABLE
|
||||||
|
- && (pd->cancelhandling & (CANCELED_BITMASK | EXITING_BITMASK
|
||||||
|
- | TERMINATED_BITMASK))
|
||||||
|
- == CANCELED_BITMASK))
|
||||||
|
+ && !cancel_enabled_and_canceled (self->cancelhandling))
|
||||||
|
/* This is a deadlock situation. The threads are waiting for each
|
||||||
|
other to finish. Note that this is a "may" error. To be 100%
|
||||||
|
sure we catch this error we would have to lock the data
|
||||||
|
diff --git a/nptl/pthread_setcancelstate.c b/nptl/pthread_setcancelstate.c
|
||||||
|
index 7e2b6e4974bd58bd..cb567be5926816f1 100644
|
||||||
|
--- a/nptl/pthread_setcancelstate.c
|
||||||
|
+++ b/nptl/pthread_setcancelstate.c
|
||||||
|
@@ -31,9 +31,29 @@ __pthread_setcancelstate (int state, int *oldstate)
|
||||||
|
|
||||||
|
self = THREAD_SELF;
|
||||||
|
|
||||||
|
- if (oldstate != NULL)
|
||||||
|
- *oldstate = self->cancelstate;
|
||||||
|
- self->cancelstate = state;
|
||||||
|
+ int oldval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ int newval = (state == PTHREAD_CANCEL_DISABLE
|
||||||
|
+ ? oldval | CANCELSTATE_BITMASK
|
||||||
|
+ : oldval & ~CANCELSTATE_BITMASK);
|
||||||
|
+
|
||||||
|
+ if (oldstate != NULL)
|
||||||
|
+ *oldstate = ((oldval & CANCELSTATE_BITMASK)
|
||||||
|
+ ? PTHREAD_CANCEL_DISABLE : PTHREAD_CANCEL_ENABLE);
|
||||||
|
+
|
||||||
|
+ if (oldval == newval)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ if (atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &oldval, newval))
|
||||||
|
+ {
|
||||||
|
+ if (cancel_enabled_and_canceled_and_async (newval))
|
||||||
|
+ __do_cancel ();
|
||||||
|
+
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c
|
||||||
|
index e7b24ae733dcc0f2..e08ff7b141f904f1 100644
|
||||||
|
--- a/nptl/pthread_setcanceltype.c
|
||||||
|
+++ b/nptl/pthread_setcanceltype.c
|
||||||
|
@@ -29,11 +29,32 @@ __pthread_setcanceltype (int type, int *oldtype)
|
||||||
|
|
||||||
|
volatile struct pthread *self = THREAD_SELF;
|
||||||
|
|
||||||
|
- if (oldtype != NULL)
|
||||||
|
- *oldtype = self->canceltype;
|
||||||
|
- self->canceltype = type;
|
||||||
|
- if (type == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
|
- __pthread_testcancel ();
|
||||||
|
+ int oldval = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ int newval = (type == PTHREAD_CANCEL_ASYNCHRONOUS
|
||||||
|
+ ? oldval | CANCELTYPE_BITMASK
|
||||||
|
+ : oldval & ~CANCELTYPE_BITMASK);
|
||||||
|
+
|
||||||
|
+ if (oldtype != NULL)
|
||||||
|
+ *oldtype = ((oldval & CANCELTYPE_BITMASK)
|
||||||
|
+ ? PTHREAD_CANCEL_ASYNCHRONOUS : PTHREAD_CANCEL_DEFERRED);
|
||||||
|
+
|
||||||
|
+ if (oldval == newval)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ if (atomic_compare_exchange_weak_acquire (&self->cancelhandling,
|
||||||
|
+ &oldval, newval))
|
||||||
|
+ {
|
||||||
|
+ if (cancel_enabled_and_canceled_and_async (newval))
|
||||||
|
+ {
|
||||||
|
+ THREAD_SETMEM (self, result, PTHREAD_CANCELED);
|
||||||
|
+ __do_cancel ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
diff --git a/nptl/pthread_testcancel.c b/nptl/pthread_testcancel.c
|
||||||
|
index 31185d89f2ab84c6..25230215fd607e8b 100644
|
||||||
|
--- a/nptl/pthread_testcancel.c
|
||||||
|
+++ b/nptl/pthread_testcancel.c
|
||||||
|
@@ -24,13 +24,10 @@ void
|
||||||
|
___pthread_testcancel (void)
|
||||||
|
{
|
||||||
|
struct pthread *self = THREAD_SELF;
|
||||||
|
- int cancelhandling = THREAD_GETMEM (self, cancelhandling);
|
||||||
|
- if (self->cancelstate == PTHREAD_CANCEL_ENABLE
|
||||||
|
- && (cancelhandling & CANCELED_BITMASK)
|
||||||
|
- && !(cancelhandling & EXITING_BITMASK)
|
||||||
|
- && !(cancelhandling & TERMINATED_BITMASK))
|
||||||
|
+ int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
|
||||||
|
+ if (cancel_enabled_and_canceled (cancelhandling))
|
||||||
|
{
|
||||||
|
- THREAD_SETMEM (self, result, PTHREAD_CANCELED);
|
||||||
|
+ self->result = PTHREAD_CANCELED;
|
||||||
|
__do_cancel ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
|
||||||
|
index b39dfbff2c6678d5..23aa4cfc0b784dfc 100644
|
||||||
|
--- a/sysdeps/nptl/dl-tls_init_tp.c
|
||||||
|
+++ b/sysdeps/nptl/dl-tls_init_tp.c
|
||||||
|
@@ -107,7 +107,4 @@ __tls_init_tp (void)
|
||||||
|
It will be bigger than it actually is, but for unwind.c/pt-longjmp.c
|
||||||
|
purposes this is good enough. */
|
||||||
|
THREAD_SETMEM (pd, stackblock_size, (size_t) __libc_stack_end);
|
||||||
|
-
|
||||||
|
- THREAD_SETMEM (pd, cancelstate, PTHREAD_CANCEL_ENABLE);
|
||||||
|
- THREAD_SETMEM (pd, canceltype, PTHREAD_CANCEL_DEFERRED);
|
||||||
|
}
|
||||||
|
diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h
|
||||||
|
index 374657a2fd0ee19a..b968afc4c6b61b92 100644
|
||||||
|
--- a/sysdeps/nptl/pthreadP.h
|
||||||
|
+++ b/sysdeps/nptl/pthreadP.h
|
||||||
|
@@ -276,7 +276,7 @@ __do_cancel (void)
|
||||||
|
struct pthread *self = THREAD_SELF;
|
||||||
|
|
||||||
|
/* Make sure we get no more cancellations. */
|
||||||
|
- THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
|
||||||
|
+ atomic_bit_set (&self->cancelhandling, EXITING_BIT);
|
||||||
|
|
||||||
|
__pthread_unwind ((__pthread_unwind_buf_t *)
|
||||||
|
THREAD_GETMEM (self, cleanup_jmp_buf));
|
||||||
|
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
|
||||||
|
index c65710169697ad95..00419c4d199df912 100644
|
||||||
|
--- a/sysdeps/pthread/Makefile
|
||||||
|
+++ b/sysdeps/pthread/Makefile
|
||||||
|
@@ -69,6 +69,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
|
||||||
|
tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel16 \
|
||||||
|
tst-cancel18 tst-cancel19 tst-cancel20 tst-cancel21 \
|
||||||
|
tst-cancel22 tst-cancel23 tst-cancel26 tst-cancel27 tst-cancel28 \
|
||||||
|
+ tst-cancel29 \
|
||||||
|
tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \
|
||||||
|
tst-clock1 \
|
||||||
|
tst-cond-except \
|
||||||
|
diff --git a/sysdeps/pthread/tst-cancel29.c b/sysdeps/pthread/tst-cancel29.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000..4f0d99e002883be4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/sysdeps/pthread/tst-cancel29.c
|
||||||
|
@@ -0,0 +1,207 @@
|
||||||
|
+/* Check if a thread that disables cancellation and which call functions
|
||||||
|
+ that might be interrupted by a signal do not see the internal SIGCANCEL.
|
||||||
|
+
|
||||||
|
+ Copyright (C) 2022 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 <array_length.h>
|
||||||
|
+#include <errno.h>
|
||||||
|
+#include <inttypes.h>
|
||||||
|
+#include <poll.h>
|
||||||
|
+#include <support/check.h>
|
||||||
|
+#include <support/support.h>
|
||||||
|
+#include <support/temp_file.h>
|
||||||
|
+#include <support/xthread.h>
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
+#include <signal.h>
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+
|
||||||
|
+/* On Linux some interfaces are never restarted after being interrupted by
|
||||||
|
+ a signal handler, regardless of the use of SA_RESTART. It means that
|
||||||
|
+ if asynchronous cancellation is not enabled, the pthread_cancel can not
|
||||||
|
+ set the internal SIGCANCEL otherwise the interface might see a spurious
|
||||||
|
+ EINTR failure. */
|
||||||
|
+
|
||||||
|
+static pthread_barrier_t b;
|
||||||
|
+
|
||||||
|
+/* Cleanup handling test. */
|
||||||
|
+static int cl_called;
|
||||||
|
+static void
|
||||||
|
+cl (void *arg)
|
||||||
|
+{
|
||||||
|
+ ++cl_called;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_sigtimedwait (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ sigset_t mask;
|
||||||
|
+ sigemptyset (&mask);
|
||||||
|
+ r = sigtimedwait (&mask, NULL, &(struct timespec) { 0, 250000000 });
|
||||||
|
+ if (r != -1)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+ if (errno != EAGAIN)
|
||||||
|
+ return (void*) -2;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_poll (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ r = poll (NULL, 0, 250);
|
||||||
|
+ if (r != 0)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_ppoll (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ r = ppoll (NULL, 0, &(struct timespec) { 0, 250000000 }, NULL);
|
||||||
|
+ if (r != 0)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_select (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ r = select (0, NULL, NULL, NULL, &(struct timeval) { 0, 250000 });
|
||||||
|
+ if (r != 0)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_pselect (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ r = pselect (0, NULL, NULL, NULL, &(struct timespec) { 0, 250000000 }, NULL);
|
||||||
|
+ if (r != 0)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void *
|
||||||
|
+tf_clock_nanosleep (void *arg)
|
||||||
|
+{
|
||||||
|
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ int r;
|
||||||
|
+ pthread_cleanup_push (cl, NULL);
|
||||||
|
+
|
||||||
|
+ r = clock_nanosleep (CLOCK_REALTIME, 0, &(struct timespec) { 0, 250000000 },
|
||||||
|
+ NULL);
|
||||||
|
+ if (r != 0)
|
||||||
|
+ return (void*) -1;
|
||||||
|
+
|
||||||
|
+ pthread_cleanup_pop (0);
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+struct cancel_test_t
|
||||||
|
+{
|
||||||
|
+ const char *name;
|
||||||
|
+ void * (*cf) (void *);
|
||||||
|
+} tests[] =
|
||||||
|
+{
|
||||||
|
+ { "sigtimedwait", tf_sigtimedwait, },
|
||||||
|
+ { "poll", tf_poll, },
|
||||||
|
+ { "ppoll", tf_ppoll, },
|
||||||
|
+ { "select", tf_select, },
|
||||||
|
+ { "pselect", tf_pselect , },
|
||||||
|
+ { "clock_nanosleep", tf_clock_nanosleep, },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+do_test (void)
|
||||||
|
+{
|
||||||
|
+ for (int i = 0; i < array_length (tests); i++)
|
||||||
|
+ {
|
||||||
|
+ xpthread_barrier_init (&b, NULL, 2);
|
||||||
|
+
|
||||||
|
+ cl_called = 0;
|
||||||
|
+
|
||||||
|
+ pthread_t th = xpthread_create (NULL, tests[i].cf, NULL);
|
||||||
|
+
|
||||||
|
+ xpthread_barrier_wait (&b);
|
||||||
|
+
|
||||||
|
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
|
||||||
|
+ while (nanosleep (&ts, &ts) != 0)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ xpthread_cancel (th);
|
||||||
|
+
|
||||||
|
+ void *status = xpthread_join (th);
|
||||||
|
+ if (status != NULL)
|
||||||
|
+ printf ("test '%s' failed: %" PRIdPTR "\n", tests[i].name,
|
||||||
|
+ (intptr_t) status);
|
||||||
|
+ TEST_VERIFY (status == NULL);
|
||||||
|
+
|
||||||
|
+ xpthread_barrier_destroy (&b);
|
||||||
|
+
|
||||||
|
+ TEST_COMPARE (cl_called, 0);
|
||||||
|
+
|
||||||
|
+ printf ("in-time cancel test of '%s' successful\n", tests[i].name);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#include <support/test-driver.c>
|
23
glibc-upstream-2.34-164.patch
Normal file
23
glibc-upstream-2.34-164.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
commit 5d8c7776343b3f1b96ef7777e4504378f23c041a
|
||||||
|
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||||
|
Date: Tue Apr 12 22:14:34 2022 +0200
|
||||||
|
|
||||||
|
hurd: Fix arbitrary error code
|
||||||
|
|
||||||
|
ELIBBAD is Linux-specific.
|
||||||
|
|
||||||
|
(cherry picked from commit 67ab66541dc1164540abda284645e38be90b5119)
|
||||||
|
|
||||||
|
diff --git a/nss/nss_test_errno.c b/nss/nss_test_errno.c
|
||||||
|
index 680f8a07b97fe263..59a5c717bebd296f 100644
|
||||||
|
--- a/nss/nss_test_errno.c
|
||||||
|
+++ b/nss/nss_test_errno.c
|
||||||
|
@@ -28,7 +28,7 @@ static void __attribute__ ((constructor))
|
||||||
|
init (void)
|
||||||
|
{
|
||||||
|
/* An arbitrary error code which is otherwise not used. */
|
||||||
|
- errno = ELIBBAD;
|
||||||
|
+ errno = -1009;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lookup functions for pwd follow that do not return any data. */
|
104
glibc-upstream-2.34-165.patch
Normal file
104
glibc-upstream-2.34-165.patch
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
commit b87b697f15d6bf7e576a2eeadc1f740172f9d013
|
||||||
|
Author: =Joshua Kinard <kumba@gentoo.org>
|
||||||
|
Date: Mon Apr 18 09:55:08 2022 -0300
|
||||||
|
|
||||||
|
mips: Fix mips64n32 64 bit time_t stat support (BZ#29069)
|
||||||
|
|
||||||
|
Add missing support initially added by 4e8521333bea6e89fcef1020
|
||||||
|
(which missed n32 stat).
|
||||||
|
|
||||||
|
(cherry picked from commit 78fb88827362fbd2cc8aa32892ae5b015106e25c)
|
||||||
|
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
|
||||||
|
index ab9f474cbc271b7c..ed5b1bc00ba52406 100644
|
||||||
|
--- a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
|
||||||
|
+++ b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
|
||||||
|
@@ -131,27 +131,30 @@ struct stat64
|
||||||
|
|
||||||
|
struct stat
|
||||||
|
{
|
||||||
|
+# ifdef __USE_TIME_BITS64
|
||||||
|
+# include <bits/struct_stat_time64_helper.h>
|
||||||
|
+# else
|
||||||
|
__dev_t st_dev;
|
||||||
|
int st_pad1[3]; /* Reserved for st_dev expansion */
|
||||||
|
-# ifndef __USE_FILE_OFFSET64
|
||||||
|
+# ifndef __USE_FILE_OFFSET64
|
||||||
|
__ino_t st_ino;
|
||||||
|
-# else
|
||||||
|
+# else
|
||||||
|
__ino64_t st_ino;
|
||||||
|
-# endif
|
||||||
|
+# endif
|
||||||
|
__mode_t st_mode;
|
||||||
|
__nlink_t st_nlink;
|
||||||
|
__uid_t st_uid;
|
||||||
|
__gid_t st_gid;
|
||||||
|
__dev_t st_rdev;
|
||||||
|
-# if !defined __USE_FILE_OFFSET64
|
||||||
|
+# if !defined __USE_FILE_OFFSET64
|
||||||
|
unsigned int st_pad2[2]; /* Reserved for st_rdev expansion */
|
||||||
|
__off_t st_size;
|
||||||
|
int st_pad3;
|
||||||
|
-# else
|
||||||
|
+# else
|
||||||
|
unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
|
||||||
|
__off64_t st_size;
|
||||||
|
-# endif
|
||||||
|
-# ifdef __USE_XOPEN2K8
|
||||||
|
+# endif
|
||||||
|
+# ifdef __USE_XOPEN2K8
|
||||||
|
/* Nanosecond resolution timestamps are stored in a format
|
||||||
|
equivalent to 'struct timespec'. This is the type used
|
||||||
|
whenever possible but the Unix namespace rules do not allow the
|
||||||
|
@@ -161,30 +164,34 @@ struct stat
|
||||||
|
struct timespec st_atim; /* Time of last access. */
|
||||||
|
struct timespec st_mtim; /* Time of last modification. */
|
||||||
|
struct timespec st_ctim; /* Time of last status change. */
|
||||||
|
-# define st_atime st_atim.tv_sec /* Backward compatibility. */
|
||||||
|
-# define st_mtime st_mtim.tv_sec
|
||||||
|
-# define st_ctime st_ctim.tv_sec
|
||||||
|
-# else
|
||||||
|
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
|
||||||
|
+# define st_mtime st_mtim.tv_sec
|
||||||
|
+# define st_ctime st_ctim.tv_sec
|
||||||
|
+# else
|
||||||
|
__time_t st_atime; /* Time of last access. */
|
||||||
|
unsigned long int st_atimensec; /* Nscecs of last access. */
|
||||||
|
__time_t st_mtime; /* Time of last modification. */
|
||||||
|
unsigned long int st_mtimensec; /* Nsecs of last modification. */
|
||||||
|
__time_t st_ctime; /* Time of last status change. */
|
||||||
|
unsigned long int st_ctimensec; /* Nsecs of last status change. */
|
||||||
|
-# endif
|
||||||
|
+# endif
|
||||||
|
__blksize_t st_blksize;
|
||||||
|
unsigned int st_pad4;
|
||||||
|
-# ifndef __USE_FILE_OFFSET64
|
||||||
|
+# ifndef __USE_FILE_OFFSET64
|
||||||
|
__blkcnt_t st_blocks;
|
||||||
|
-# else
|
||||||
|
+# else
|
||||||
|
__blkcnt64_t st_blocks;
|
||||||
|
-# endif
|
||||||
|
+# endif
|
||||||
|
int st_pad5[14];
|
||||||
|
+# endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __USE_LARGEFILE64
|
||||||
|
struct stat64
|
||||||
|
{
|
||||||
|
+# ifdef __USE_TIME_BITS64
|
||||||
|
+# include <bits/struct_stat_time64_helper.h>
|
||||||
|
+# else
|
||||||
|
__dev_t st_dev;
|
||||||
|
unsigned int st_pad1[3]; /* Reserved for st_dev expansion */
|
||||||
|
__ino64_t st_ino;
|
||||||
|
@@ -217,6 +224,7 @@ struct stat64
|
||||||
|
unsigned int st_pad3;
|
||||||
|
__blkcnt64_t st_blocks;
|
||||||
|
int st_pad4[14];
|
||||||
|
+# endif /* __USE_TIME_BITS64 */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
35
glibc-upstream-2.34-166.patch
Normal file
35
glibc-upstream-2.34-166.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
commit 71326f1f2fd09dafb9c34404765fb88129e94237
|
||||||
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
Date: Wed Apr 20 12:01:43 2022 -0300
|
||||||
|
|
||||||
|
nptl: Fix pthread_cancel cancelhandling atomic operations
|
||||||
|
|
||||||
|
The 404656009b reversion did not setup the atomic loop to set the
|
||||||
|
cancel bits correctly. The fix is essentially what pthread_cancel
|
||||||
|
did prior 26cfbb7162ad.
|
||||||
|
|
||||||
|
Checked on x86_64-linux-gnu and aarch64-linux-gnu.
|
||||||
|
|
||||||
|
(cherry picked from commit 62be9681677e7ce820db721c126909979382d379)
|
||||||
|
|
||||||
|
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
|
||||||
|
index 2680b55586e035fe..64fd183fde59907b 100644
|
||||||
|
--- a/nptl/pthread_cancel.c
|
||||||
|
+++ b/nptl/pthread_cancel.c
|
||||||
|
@@ -122,6 +122,7 @@ __pthread_cancel (pthread_t th)
|
||||||
|
int newval;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
+ again:
|
||||||
|
newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
|
||||||
|
if (oldval == newval)
|
||||||
|
break;
|
||||||
|
@@ -135,7 +136,7 @@ __pthread_cancel (pthread_t th)
|
||||||
|
int newval2 = oldval | CANCELING_BITMASK;
|
||||||
|
if (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling,
|
||||||
|
&oldval, newval2))
|
||||||
|
- continue;
|
||||||
|
+ goto again;
|
||||||
|
|
||||||
|
if (pd == THREAD_SELF)
|
||||||
|
/* This is not merely an optimization: An application may
|
74
glibc.spec
74
glibc.spec
@ -148,7 +148,7 @@ end \
|
|||||||
Summary: The GNU libc libraries
|
Summary: The GNU libc libraries
|
||||||
Name: glibc
|
Name: glibc
|
||||||
Version: %{glibcversion}
|
Version: %{glibcversion}
|
||||||
Release: 29%{?dist}
|
Release: 30%{?dist}
|
||||||
|
|
||||||
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
|
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
|
||||||
# libraries.
|
# libraries.
|
||||||
@ -403,6 +403,40 @@ Patch196: glibc-upstream-2.34-129.patch
|
|||||||
Patch197: glibc-upstream-2.34-130.patch
|
Patch197: glibc-upstream-2.34-130.patch
|
||||||
Patch198: glibc-upstream-2.34-131.patch
|
Patch198: glibc-upstream-2.34-131.patch
|
||||||
Patch199: glibc-upstream-2.34-132.patch
|
Patch199: glibc-upstream-2.34-132.patch
|
||||||
|
Patch200: glibc-upstream-2.34-133.patch
|
||||||
|
Patch201: glibc-upstream-2.34-134.patch
|
||||||
|
Patch202: glibc-upstream-2.34-135.patch
|
||||||
|
Patch203: glibc-upstream-2.34-136.patch
|
||||||
|
Patch204: glibc-upstream-2.34-137.patch
|
||||||
|
Patch205: glibc-upstream-2.34-138.patch
|
||||||
|
Patch206: glibc-upstream-2.34-139.patch
|
||||||
|
Patch207: glibc-upstream-2.34-140.patch
|
||||||
|
Patch208: glibc-upstream-2.34-141.patch
|
||||||
|
Patch209: glibc-upstream-2.34-142.patch
|
||||||
|
Patch210: glibc-upstream-2.34-143.patch
|
||||||
|
Patch211: glibc-upstream-2.34-144.patch
|
||||||
|
Patch212: glibc-upstream-2.34-145.patch
|
||||||
|
Patch213: glibc-upstream-2.34-146.patch
|
||||||
|
Patch214: glibc-upstream-2.34-147.patch
|
||||||
|
Patch215: glibc-upstream-2.34-148.patch
|
||||||
|
Patch216: glibc-upstream-2.34-149.patch
|
||||||
|
Patch217: glibc-upstream-2.34-150.patch
|
||||||
|
Patch218: glibc-upstream-2.34-151.patch
|
||||||
|
Patch219: glibc-upstream-2.34-152.patch
|
||||||
|
Patch220: glibc-upstream-2.34-153.patch
|
||||||
|
Patch221: glibc-upstream-2.34-154.patch
|
||||||
|
Patch222: glibc-upstream-2.34-155.patch
|
||||||
|
Patch223: glibc-upstream-2.34-156.patch
|
||||||
|
Patch224: glibc-upstream-2.34-157.patch
|
||||||
|
Patch225: glibc-upstream-2.34-158.patch
|
||||||
|
Patch226: glibc-upstream-2.34-159.patch
|
||||||
|
Patch227: glibc-upstream-2.34-160.patch
|
||||||
|
# glibc-2.34-161-gceed89d089 only changes NEWS.
|
||||||
|
Patch228: glibc-upstream-2.34-162.patch
|
||||||
|
Patch229: glibc-upstream-2.34-163.patch
|
||||||
|
Patch230: glibc-upstream-2.34-164.patch
|
||||||
|
Patch231: glibc-upstream-2.34-165.patch
|
||||||
|
Patch232: glibc-upstream-2.34-166.patch
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Continued list of core "glibc" package information:
|
# Continued list of core "glibc" package information:
|
||||||
@ -2459,6 +2493,44 @@ fi
|
|||||||
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
|
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Apr 21 2022 Carlos O'Donell <carlos@redhat.com> - 2.34-30
|
||||||
|
- Sync with upstream branch release/2.34/master,
|
||||||
|
commit 71326f1f2fd09dafb9c34404765fb88129e94237:
|
||||||
|
- nptl: Fix pthread_cancel cancelhandling atomic operations
|
||||||
|
- mips: Fix mips64n32 64 bit time_t stat support (BZ#29069)
|
||||||
|
- hurd: Fix arbitrary error code
|
||||||
|
- nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
|
||||||
|
- S390: Add new s390 platform z16.
|
||||||
|
- NEWS: Update fixed bug list for LD_AUDIT backports.
|
||||||
|
- hppa: Fix bind-now audit (BZ #28857)
|
||||||
|
- elf: Replace tst-audit24bmod2.so with tst-audit24bmod2
|
||||||
|
- Fix elf/tst-audit25a with default bind now toolchains
|
||||||
|
- elf: Fix runtime linker auditing on aarch64 (BZ #26643)
|
||||||
|
- elf: Issue la_symbind for bind-now (BZ #23734)
|
||||||
|
- elf: Fix initial-exec TLS access on audit modules (BZ #28096)
|
||||||
|
- elf: Add la_activity during application exit
|
||||||
|
- elf: Do not fail for failed dlmopen on audit modules (BZ #28061)
|
||||||
|
- elf: Issue audit la_objopen for vDSO
|
||||||
|
- elf: Add audit tests for modules with TLSDESC
|
||||||
|
- elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)
|
||||||
|
- elf: Add _dl_audit_pltexit
|
||||||
|
- elf: Add _dl_audit_pltenter
|
||||||
|
- elf: Add _dl_audit_preinit
|
||||||
|
- elf: Add _dl_audit_symbind_alt and _dl_audit_symbind
|
||||||
|
- elf: Add _dl_audit_objclose
|
||||||
|
- elf: Add _dl_audit_objsearch
|
||||||
|
- elf: Add _dl_audit_activity_map and _dl_audit_activity_nsid
|
||||||
|
- elf: Add _dl_audit_objopen
|
||||||
|
- elf: Move la_activity (LA_ACT_ADD) after _dl_add_to_namespace_list() (BZ #28062)
|
||||||
|
- elf: Move LAV_CURRENT to link_lavcurrent.h
|
||||||
|
- elf: Fix elf_get_dynamic_info() for bootstrap
|
||||||
|
- elf: Fix dynamic-link.h usage on rtld.c
|
||||||
|
- elf: Fix elf_get_dynamic_info definition
|
||||||
|
- elf: Avoid nested functions in the loader [BZ #27220]
|
||||||
|
- powerpc: Delete unneeded ELF_MACHINE_BEFORE_RTLD_RELOC
|
||||||
|
- hppa: Use END instead of PSEUDO_END in swapcontext.S
|
||||||
|
- hppa: Implement swapcontext in assembler (bug 28960)
|
||||||
|
|
||||||
* Tue Mar 15 2022 Florian Weimer <fweimer@redhat.com> - 2.34-29
|
* Tue Mar 15 2022 Florian Weimer <fweimer@redhat.com> - 2.34-29
|
||||||
- Sync with upstream branch release/2.34/master,
|
- Sync with upstream branch release/2.34/master,
|
||||||
commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704:
|
commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704:
|
||||||
|
Loading…
Reference in New Issue
Block a user