|
|
c5d972 |
Added $(objpfx)tst-auditmod20: $(libdl) in elf/Makefile since
|
|
|
c5d972 |
we still have $(libdl) in RHEL8.
|
|
|
c5d972 |
|
|
|
c5d972 |
commit 484e672ddabe0a919a692520e6ac8f2580866235
|
|
|
c5d972 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
c5d972 |
Date: Wed Jun 30 17:33:57 2021 -0300
|
|
|
c5d972 |
|
|
|
c5d972 |
elf: Do not fail for failed dlmopen on audit modules (BZ #28061)
|
|
|
c5d972 |
|
|
|
c5d972 |
The dl_main sets the LM_ID_BASE to RT_ADD just before starting to
|
|
|
c5d972 |
add load new shared objects. The state is set to RT_CONSISTENT just
|
|
|
c5d972 |
after all objects are loaded.
|
|
|
c5d972 |
|
|
|
c5d972 |
However if a audit modules tries to dlmopen an inexistent module,
|
|
|
c5d972 |
the _dl_open will assert that the namespace is in an inconsistent
|
|
|
c5d972 |
state.
|
|
|
c5d972 |
|
|
|
c5d972 |
This is different than dlopen, since first it will not use
|
|
|
c5d972 |
LM_ID_BASE and second _dl_map_object_from_fd is the sole responsible
|
|
|
c5d972 |
to set and reset the r_state value.
|
|
|
c5d972 |
|
|
|
c5d972 |
So the assert on _dl_open can not really be seen if the state is
|
|
|
c5d972 |
consistent, since _dt_main resets it. This patch removes the assert.
|
|
|
c5d972 |
|
|
|
c5d972 |
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
|
|
c5d972 |
|
|
|
c5d972 |
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
|
|
c5d972 |
|
|
|
c5d972 |
Conflicts:
|
|
|
c5d972 |
elf/dl-open.c
|
|
|
c5d972 |
Uses dl_debug_initialize instead of dl_debug_update.
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
c5d972 |
index f047c1cce0c55da0..7c7b9e1937d3e41c 100644
|
|
|
c5d972 |
--- a/elf/Makefile
|
|
|
c5d972 |
+++ b/elf/Makefile
|
|
|
c5d972 |
@@ -222,6 +222,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
|
|
|
c5d972 |
tst-audit17 \
|
|
|
c5d972 |
tst-audit18 \
|
|
|
c5d972 |
tst-audit19b \
|
|
|
c5d972 |
+ tst-audit20 \
|
|
|
c5d972 |
tst-audit22 \
|
|
|
c5d972 |
# reldep9
|
|
|
c5d972 |
tests-internal += loadtest unload unload2 circleload1 \
|
|
|
c5d972 |
@@ -364,6 +365,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
|
|
c5d972 |
tst-auditmod19a \
|
|
|
c5d972 |
tst-auditmod19b \
|
|
|
c5d972 |
tst-audit19bmod \
|
|
|
c5d972 |
+ tst-auditmod20 \
|
|
|
c5d972 |
tst-auditmod22 \
|
|
|
c5d972 |
|
|
|
c5d972 |
# Most modules build with _ISOMAC defined, but those filtered out
|
|
|
c5d972 |
@@ -1579,6 +1581,10 @@ $(objpfx)tst-audit19b.out: $(objpfx)tst-auditmod19b.so
|
|
|
c5d972 |
$(objpfx)tst-audit19b: $(objpfx)tst-audit19bmod.so
|
|
|
c5d972 |
tst-audit19b-ARGS = -- $(host-test-program-cmd)
|
|
|
c5d972 |
|
|
|
c5d972 |
+$(objpfx)tst-audit20.out: $(objpfx)tst-auditmod20.so
|
|
|
c5d972 |
+tst-audit20-ENV = LD_AUDIT=$(objpfx)tst-auditmod20.so
|
|
|
c5d972 |
+$(objpfx)tst-auditmod20.so: $(libdl)
|
|
|
c5d972 |
+
|
|
|
c5d972 |
$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
|
|
c5d972 |
tst-audit22-ARGS = -- $(host-test-program-cmd)
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
|
|
c5d972 |
index 660a56b2fb2639cd..6b85e9ab4e249f86 100644
|
|
|
c5d972 |
--- a/elf/dl-open.c
|
|
|
c5d972 |
+++ b/elf/dl-open.c
|
|
|
c5d972 |
@@ -911,8 +911,6 @@ no more namespaces available for dlmopen()"));
|
|
|
c5d972 |
the flag here. */
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|
|
|
c5d972 |
- assert (_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT);
|
|
|
c5d972 |
-
|
|
|
c5d972 |
/* Release the lock. */
|
|
|
c5d972 |
__rtld_lock_unlock_recursive (GL(dl_load_lock));
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/tst-audit20.c b/elf/tst-audit20.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..6f39ccee865b012b
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-audit20.c
|
|
|
c5d972 |
@@ -0,0 +1,25 @@
|
|
|
c5d972 |
+/* Check dlopen failure on audit modules.
|
|
|
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-auditmod20.c b/elf/tst-auditmod20.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..c57e50ee4e88dd6b
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-auditmod20.c
|
|
|
c5d972 |
@@ -0,0 +1,57 @@
|
|
|
c5d972 |
+/* Check dlopen failure on audit modules.
|
|
|
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 |
+#include <dlfcn.h>
|
|
|
c5d972 |
+#include <link.h>
|
|
|
c5d972 |
+#include <stdlib.h>
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+unsigned int
|
|
|
c5d972 |
+la_version (unsigned int v)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return LAV_CURRENT;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static void
|
|
|
c5d972 |
+check (void)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ void *mod = dlopen ("nonexistent.so", RTLD_NOW);
|
|
|
c5d972 |
+ if (mod != NULL)
|
|
|
c5d972 |
+ abort ();
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ void *mod = dlmopen (LM_ID_BASE, "nonexistent.so", RTLD_NOW);
|
|
|
c5d972 |
+ if (mod != NULL)
|
|
|
c5d972 |
+ abort ();
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+void
|
|
|
c5d972 |
+la_activity (uintptr_t *cookie, unsigned int flag)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ if (flag != LA_ACT_CONSISTENT)
|
|
|
c5d972 |
+ return;
|
|
|
c5d972 |
+ check ();
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+void
|
|
|
c5d972 |
+la_preinit (uintptr_t *cookie)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ check ();
|
|
|
c5d972 |
+}
|