|
|
c5d972 |
commit 3908fa933a4354309225af616d9242f595e11ccf
|
|
|
c5d972 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
c5d972 |
Date: Wed Jun 30 00:21:18 2021 -0300
|
|
|
c5d972 |
|
|
|
c5d972 |
elf: Fix audit regression
|
|
|
c5d972 |
|
|
|
c5d972 |
Commit 03e187a41d9 added a regression when an audit module does not have
|
|
|
c5d972 |
libc as DT_NEEDED (although unusual it is possible).
|
|
|
c5d972 |
|
|
|
c5d972 |
Checked on x86_64-linux-gnu.
|
|
|
c5d972 |
|
|
|
c5d972 |
Conflicts:
|
|
|
c5d972 |
elf/Makefile
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
c5d972 |
index 30417c3ce15abcb4..6262a4a65cfd2148 100644
|
|
|
c5d972 |
--- a/elf/Makefile
|
|
|
c5d972 |
+++ b/elf/Makefile
|
|
|
c5d972 |
@@ -218,6 +218,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
|
|
|
c5d972 |
tst-rtld-run-static \
|
|
|
c5d972 |
tst-dlmopen-dlerror \
|
|
|
c5d972 |
tst-dlmopen-gethostbyname \
|
|
|
c5d972 |
+ tst-audit17 \
|
|
|
c5d972 |
# reldep9
|
|
|
c5d972 |
tests-internal += loadtest unload unload2 circleload1 \
|
|
|
c5d972 |
neededtest neededtest2 neededtest3 neededtest4 \
|
|
|
c5d972 |
@@ -1527,6 +1528,16 @@ $(objpfx)tst-auditlogmod-3.so: $(libsupport)
|
|
|
c5d972 |
$(objpfx)tst-audit16.out: \
|
|
|
c5d972 |
$(objpfx)tst-auditlogmod-1.so $(objpfx)tst-auditlogmod-2.so \
|
|
|
c5d972 |
$(objpfx)tst-auditlogmod-3.so
|
|
|
c5d972 |
+$(objpfx)tst-audit17.out: $(objpfx)tst-auditmod17.so
|
|
|
c5d972 |
+# The test check if a audit library without libc.so on DT_NEEDED works as
|
|
|
c5d972 |
+# intended, so it uses an explicit link rule.
|
|
|
c5d972 |
+$(objpfx)tst-auditmod17.so: $(objpfx)tst-auditmod17.os
|
|
|
c5d972 |
+ $(CC) -nostdlib -nostartfiles -shared -o $@.new \
|
|
|
c5d972 |
+ $(filter-out $(map-file),$^)
|
|
|
c5d972 |
+ $(call after-link,$@.new)
|
|
|
c5d972 |
+ mv -f $@.new $@
|
|
|
c5d972 |
+CFLAGS-.os += $(call elide-stack-protector,.os,tst-auditmod17)
|
|
|
c5d972 |
+tst-audit17-ENV = LD_AUDIT=$(objpfx)tst-auditmod17.so
|
|
|
c5d972 |
|
|
|
c5d972 |
# tst-sonamemove links against an older implementation of the library.
|
|
|
c5d972 |
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
|
|
c5d972 |
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
|
|
c5d972 |
index 736df62ce6e46d34..661a2172d1789b26 100644
|
|
|
c5d972 |
--- a/elf/dl-open.c
|
|
|
c5d972 |
+++ b/elf/dl-open.c
|
|
|
c5d972 |
@@ -759,16 +759,9 @@ dl_open_worker_begin (void *a)
|
|
|
c5d972 |
namespace. */
|
|
|
c5d972 |
if (!args->libc_already_loaded)
|
|
|
c5d972 |
{
|
|
|
c5d972 |
+ /* dlopen cannot be used to load an initial libc by design. */
|
|
|
c5d972 |
struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
|
|
|
c5d972 |
-#ifdef SHARED
|
|
|
c5d972 |
- bool initial = libc_map->l_ns == LM_ID_BASE;
|
|
|
c5d972 |
-#else
|
|
|
c5d972 |
- /* In the static case, there is only one namespace, but it
|
|
|
c5d972 |
- contains a secondary libc (the primary libc is statically
|
|
|
c5d972 |
- linked). */
|
|
|
c5d972 |
- bool initial = false;
|
|
|
c5d972 |
-#endif
|
|
|
c5d972 |
- _dl_call_libc_early_init (libc_map, initial);
|
|
|
c5d972 |
+ _dl_call_libc_early_init (libc_map, false);
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|
|
|
c5d972 |
#ifndef SHARED
|
|
|
c5d972 |
diff --git a/elf/tst-audit17.c b/elf/tst-audit17.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..92986699d497845f
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-audit17.c
|
|
|
c5d972 |
@@ -0,0 +1,25 @@
|
|
|
c5d972 |
+/* Check DT_AUDIT with audit not linked against libc.
|
|
|
c5d972 |
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
|
|
c5d972 |
+ This file is part of the GNU C Library.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c5d972 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c5d972 |
+ License as published by the Free Software Foundation; either
|
|
|
c5d972 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c5d972 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c5d972 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c5d972 |
+ Lesser General Public License for more details.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c5d972 |
+ License along with the GNU C Library; if not, see
|
|
|
c5d972 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static int
|
|
|
c5d972 |
+do_test (void)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+#include <support/test-driver.c>
|
|
|
c5d972 |
diff --git a/elf/tst-auditmod17.c b/elf/tst-auditmod17.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..7a4467f597b56cf4
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-auditmod17.c
|
|
|
c5d972 |
@@ -0,0 +1,23 @@
|
|
|
c5d972 |
+/* Check DT_AUDIT with audit not linked against libc.
|
|
|
c5d972 |
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
|
|
c5d972 |
+ This file is part of the GNU C Library.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c5d972 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c5d972 |
+ License as published by the Free Software Foundation; either
|
|
|
c5d972 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c5d972 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c5d972 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c5d972 |
+ Lesser General Public License for more details.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c5d972 |
+ License along with the GNU C Library; if not, see
|
|
|
c5d972 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+unsigned int
|
|
|
c5d972 |
+la_version (unsigned int version)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return version;
|
|
|
c5d972 |
+}
|