|
|
b1dca6 |
commit b3fbfe81961a1d14d7b54d1c9757e1f487073bcb
|
|
|
b1dca6 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
b1dca6 |
Date: Tue Feb 12 13:51:43 2019 +0100
|
|
|
b1dca6 |
|
|
|
b1dca6 |
elf: Test for LD_AUDIT module returning zero from la_version [BZ #24122]
|
|
|
b1dca6 |
|
|
|
b1dca6 |
This includes the original test case from commit
|
|
|
b1dca6 |
8e889c5da3c5981c5a46a93fec02de40131ac5a6 ("elf: Fix LD_AUDIT for
|
|
|
b1dca6 |
modules with invalid version (BZ#24122)).
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Conflicts:
|
|
|
b1dca6 |
elf/Makefile
|
|
|
b1dca6 |
(Different backport order of tests.)
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
b1dca6 |
index 6d1962b2e4deb871..4e1356b9172aee02 100644
|
|
|
b1dca6 |
--- a/elf/Makefile
|
|
|
b1dca6 |
+++ b/elf/Makefile
|
|
|
b1dca6 |
@@ -191,6 +191,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
|
|
|
b1dca6 |
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
|
|
|
b1dca6 |
tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \
|
|
|
b1dca6 |
tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note \
|
|
|
b1dca6 |
+ tst-audit13 \
|
|
|
b1dca6 |
tst-sonamemove-link tst-sonamemove-dlopen tst-initfinilazyfail \
|
|
|
b1dca6 |
tst-dlopenfail tst-dlopenfail-2 \
|
|
|
b1dca6 |
tst-filterobj tst-filterobj-dlopen tst-auxobj tst-auxobj-dlopen
|
|
|
b1dca6 |
@@ -300,7 +301,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
|
|
b1dca6 |
tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin \
|
|
|
b1dca6 |
tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \
|
|
|
b1dca6 |
tst-absolute-zero-lib tst-big-note-lib \
|
|
|
b1dca6 |
- tst-sonamemove-linkmod1 \
|
|
|
b1dca6 |
+ tst-audit13mod1 tst-sonamemove-linkmod1 \
|
|
|
b1dca6 |
tst-sonamemove-runmod1 tst-sonamemove-runmod2 \
|
|
|
b1dca6 |
tst-initlazyfailmod tst-finilazyfailmod \
|
|
|
b1dca6 |
tst-dlopenfailmod1 tst-dlopenfaillinkmod tst-dlopenfailmod2 \
|
|
|
b1dca6 |
@@ -1428,6 +1429,10 @@ tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so
|
|
|
b1dca6 |
$(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
|
|
|
b1dca6 |
LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+$(objpfx)tst-audit13.out: $(objpfx)tst-audit13mod1.so
|
|
|
b1dca6 |
+LDFLAGS-tst-audit13mod1.so = -Wl,-z,lazy
|
|
|
b1dca6 |
+tst-audit13-ENV = LD_AUDIT=$(objpfx)tst-audit13mod1.so
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
# tst-sonamemove links against an older implementation of the library.
|
|
|
b1dca6 |
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
|
|
b1dca6 |
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
|
|
b1dca6 |
diff --git a/elf/tst-audit13.c b/elf/tst-audit13.c
|
|
|
b1dca6 |
new file mode 100644
|
|
|
b1dca6 |
index 0000000000000000..6f587baf581ce32c
|
|
|
b1dca6 |
--- /dev/null
|
|
|
b1dca6 |
+++ b/elf/tst-audit13.c
|
|
|
b1dca6 |
@@ -0,0 +1,28 @@
|
|
|
b1dca6 |
+/* Check for invalid audit version (BZ#24122).
|
|
|
b1dca6 |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
b1dca6 |
+ This file is part of the GNU C Library.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
b1dca6 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
b1dca6 |
+ License as published by the Free Software Foundation; either
|
|
|
b1dca6 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
b1dca6 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b1dca6 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
b1dca6 |
+ Lesser General Public License for more details.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
b1dca6 |
+ License along with the GNU C Library; if not, see
|
|
|
b1dca6 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+#include <stdio.h>
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+static int
|
|
|
b1dca6 |
+do_test (void)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ puts ("plt call");
|
|
|
b1dca6 |
+ return 0;
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+#include <support/test-driver.c>
|
|
|
b1dca6 |
diff --git a/elf/tst-audit13mod1.c b/elf/tst-audit13mod1.c
|
|
|
b1dca6 |
new file mode 100644
|
|
|
b1dca6 |
index 0000000000000000..cf017e235c7ae030
|
|
|
b1dca6 |
--- /dev/null
|
|
|
b1dca6 |
+++ b/elf/tst-audit13mod1.c
|
|
|
b1dca6 |
@@ -0,0 +1,93 @@
|
|
|
b1dca6 |
+/* Check for invalid audit version (BZ#24122).
|
|
|
b1dca6 |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
b1dca6 |
+ This file is part of the GNU C Library.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
b1dca6 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
b1dca6 |
+ License as published by the Free Software Foundation; either
|
|
|
b1dca6 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
b1dca6 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b1dca6 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
b1dca6 |
+ Lesser General Public License for more details.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
b1dca6 |
+ License along with the GNU C Library; if not, see
|
|
|
b1dca6 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+#include <link.h>
|
|
|
b1dca6 |
+#include <stdlib.h>
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+unsigned int
|
|
|
b1dca6 |
+la_version (unsigned int version)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ /* The audit specification says that a version of 0 or a version
|
|
|
b1dca6 |
+ greater than any version supported by the dynamic loader shall
|
|
|
b1dca6 |
+ cause the module to be ignored. */
|
|
|
b1dca6 |
+ return 0;
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+void
|
|
|
b1dca6 |
+la_activity (uintptr_t *cookie, unsigned int flag)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+char *
|
|
|
b1dca6 |
+la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+unsigned int
|
|
|
b1dca6 |
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t * cookie)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+void
|
|
|
b1dca6 |
+la_preinit (uintptr_t * cookie)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+uintptr_t
|
|
|
b1dca6 |
+#if __ELF_NATIVE_CLASS == 32
|
|
|
b1dca6 |
+la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
|
|
b1dca6 |
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
|
|
b1dca6 |
+#else
|
|
|
b1dca6 |
+la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
|
|
b1dca6 |
+ uintptr_t *defcook, unsigned int *flags, const char *symname)
|
|
|
b1dca6 |
+#endif
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+unsigned int
|
|
|
b1dca6 |
+la_objclose (uintptr_t * cookie)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+#include <tst-audit.h>
|
|
|
b1dca6 |
+#if (!defined (pltenter) || !defined (pltexit) || !defined (La_regs) \
|
|
|
b1dca6 |
+ || !defined (La_retval) || !defined (int_retval))
|
|
|
b1dca6 |
+# error "architecture specific code needed in sysdeps/CPU/tst-audit.h"
|
|
|
b1dca6 |
+#endif
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ElfW(Addr)
|
|
|
b1dca6 |
+pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
|
b1dca6 |
+ uintptr_t *defcook, La_regs *regs, unsigned int *flags,
|
|
|
b1dca6 |
+ const char *symname, long int *framesizep)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+unsigned int
|
|
|
b1dca6 |
+pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
|
b1dca6 |
+ uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
|
|
|
b1dca6 |
+ const char *symname)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ exit (EXIT_FAILURE);
|
|
|
b1dca6 |
+}
|