|
|
d8307d |
From 0d3905b110000463775b3fb189213833acaebf81 Mon Sep 17 00:00:00 2001
|
|
|
d8307d |
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
|
d8307d |
Date: Mon, 1 Jul 2019 12:23:10 -0700
|
|
|
d8307d |
Subject: Call _dl_open_check after relocation [BZ #24259]
|
|
|
d8307d |
|
|
|
d8307d |
This is a workaround for [BZ #20839] which doesn't remove the NODELETE
|
|
|
d8307d |
object when _dl_open_check throws an exception. Move it after relocation
|
|
|
d8307d |
in dl_open_worker to avoid leaving the NODELETE object mapped without
|
|
|
d8307d |
relocation.
|
|
|
d8307d |
|
|
|
d8307d |
[BZ #24259]
|
|
|
d8307d |
* elf/dl-open.c (dl_open_worker): Call _dl_open_check after
|
|
|
d8307d |
relocation.
|
|
|
d8307d |
* sysdeps/x86/Makefile (tests): Add tst-cet-legacy-5a,
|
|
|
d8307d |
tst-cet-legacy-5b, tst-cet-legacy-6a and tst-cet-legacy-6b.
|
|
|
d8307d |
(modules-names): Add tst-cet-legacy-mod-5a, tst-cet-legacy-mod-5b,
|
|
|
d8307d |
tst-cet-legacy-mod-5c, tst-cet-legacy-mod-6a, tst-cet-legacy-mod-6b
|
|
|
d8307d |
and tst-cet-legacy-mod-6c.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-5a.c): New.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-5b.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-5a.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-5b.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-5c.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-6a.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-6b.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-6a.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-6b.c): Likewise.
|
|
|
d8307d |
(CFLAGS-tst-cet-legacy-mod-6c.c): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-5a): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-5a.out): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-mod-5a.so): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-mod-5b.so): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-5b): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-5b.out): Likewise.
|
|
|
d8307d |
(tst-cet-legacy-5b-ENV): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-6a): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-6a.out): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-mod-6a.so): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-mod-6b.so): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-6b): Likewise.
|
|
|
d8307d |
($(objpfx)tst-cet-legacy-6b.out): Likewise.
|
|
|
d8307d |
(tst-cet-legacy-6b-ENV): Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-5.c: New file.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-5a.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-5b.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-6.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-6a.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-6b.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-5.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-5a.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-5b.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-5c.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-6.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-6a.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-6b.c: Likewise.
|
|
|
d8307d |
* sysdeps/x86/tst-cet-legacy-mod-6c.c: Likewise.
|
|
|
d8307d |
|
|
|
d8307d |
(cherry picked from commit d0093c5cefb7f7a4143f3bb03743633823229cc6)
|
|
|
d8307d |
|
|
|
d8307d |
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
|
|
d8307d |
index f6c8ef1043..518a6cad69 100644
|
|
|
d8307d |
--- a/elf/dl-open.c
|
|
|
d8307d |
+++ b/elf/dl-open.c
|
|
|
d8307d |
@@ -292,8 +292,6 @@ dl_open_worker (void *a)
|
|
|
d8307d |
_dl_debug_state ();
|
|
|
d8307d |
LIBC_PROBE (map_complete, 3, args->nsid, r, new);
|
|
|
d8307d |
|
|
|
d8307d |
- _dl_open_check (new);
|
|
|
d8307d |
-
|
|
|
d8307d |
/* Print scope information. */
|
|
|
d8307d |
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES))
|
|
|
d8307d |
_dl_show_scope (new, 0);
|
|
|
d8307d |
@@ -366,6 +364,12 @@ dl_open_worker (void *a)
|
|
|
d8307d |
_dl_relocate_object (l, l->l_scope, reloc_mode, 0);
|
|
|
d8307d |
}
|
|
|
d8307d |
|
|
|
d8307d |
+ /* NB: Workaround for [BZ #20839] which doesn't remove the NODELETE
|
|
|
d8307d |
+ object when _dl_open_check throws an exception. Move it after
|
|
|
d8307d |
+ relocation to avoid leaving the NODELETE object mapped without
|
|
|
d8307d |
+ relocation. */
|
|
|
d8307d |
+ _dl_open_check (new);
|
|
|
d8307d |
+
|
|
|
d8307d |
/* If the file is not loaded now as a dependency, add the search
|
|
|
d8307d |
list of the newly loaded object to the scope. */
|
|
|
d8307d |
bool any_tls = false;
|
|
|
d8307d |
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
|
|
|
d8307d |
index 337b0b63dc..43ad4a79ff 100644
|
|
|
d8307d |
--- a/sysdeps/x86/Makefile
|
|
|
d8307d |
+++ b/sysdeps/x86/Makefile
|
|
|
d8307d |
@@ -19,12 +19,17 @@ ifeq ($(subdir),elf)
|
|
|
d8307d |
sysdep-dl-routines += dl-cet
|
|
|
d8307d |
|
|
|
d8307d |
tests += tst-cet-legacy-1 tst-cet-legacy-2 tst-cet-legacy-2a \
|
|
|
d8307d |
- tst-cet-legacy-3 tst-cet-legacy-4
|
|
|
d8307d |
+ tst-cet-legacy-3 tst-cet-legacy-4 \
|
|
|
d8307d |
+ tst-cet-legacy-5a tst-cet-legacy-6a
|
|
|
d8307d |
ifneq (no,$(have-tunables))
|
|
|
d8307d |
-tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c
|
|
|
d8307d |
+tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c \
|
|
|
d8307d |
+ tst-cet-legacy-5b tst-cet-legacy-6b
|
|
|
d8307d |
endif
|
|
|
d8307d |
modules-names += tst-cet-legacy-mod-1 tst-cet-legacy-mod-2 \
|
|
|
d8307d |
- tst-cet-legacy-mod-4
|
|
|
d8307d |
+ tst-cet-legacy-mod-4 tst-cet-legacy-mod-5a \
|
|
|
d8307d |
+ tst-cet-legacy-mod-5b tst-cet-legacy-mod-5c \
|
|
|
d8307d |
+ tst-cet-legacy-mod-6a tst-cet-legacy-mod-6b \
|
|
|
d8307d |
+ tst-cet-legacy-mod-6c
|
|
|
d8307d |
|
|
|
d8307d |
CFLAGS-tst-cet-legacy-2.c += -fcf-protection=branch
|
|
|
d8307d |
CFLAGS-tst-cet-legacy-2a.c += -fcf-protection
|
|
|
d8307d |
@@ -35,6 +40,16 @@ CFLAGS-tst-cet-legacy-4.c += -fcf-protection=branch
|
|
|
d8307d |
CFLAGS-tst-cet-legacy-4a.c += -fcf-protection
|
|
|
d8307d |
CFLAGS-tst-cet-legacy-4b.c += -fcf-protection
|
|
|
d8307d |
CFLAGS-tst-cet-legacy-mod-4.c += -fcf-protection=none
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-5a.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-5b.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-5a.c += -fcf-protection=none
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-5b.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-5c.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-6a.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-6b.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-6a.c += -fcf-protection=none
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-6b.c += -fcf-protection
|
|
|
d8307d |
+CFLAGS-tst-cet-legacy-mod-6c.c += -fcf-protection
|
|
|
d8307d |
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-1: $(objpfx)tst-cet-legacy-mod-1.so \
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-mod-2.so
|
|
|
d8307d |
@@ -44,6 +59,17 @@ $(objpfx)tst-cet-legacy-2a: $(objpfx)tst-cet-legacy-mod-2.so $(libdl)
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-2a.out: $(objpfx)tst-cet-legacy-mod-1.so
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4: $(libdl)
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4.out: $(objpfx)tst-cet-legacy-mod-4.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-5a: $(libdl)
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-5a.out: $(objpfx)tst-cet-legacy-mod-5a.so \
|
|
|
d8307d |
+ $(objpfx)tst-cet-legacy-mod-5b.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-mod-5a.so: $(objpfx)tst-cet-legacy-mod-5c.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-mod-5b.so: $(objpfx)tst-cet-legacy-mod-5c.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-6a: $(libdl)
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-6a.out: $(objpfx)tst-cet-legacy-mod-6a.so \
|
|
|
d8307d |
+ $(objpfx)tst-cet-legacy-mod-6b.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-mod-6a.so: $(objpfx)tst-cet-legacy-mod-6c.so
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-mod-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so
|
|
|
d8307d |
+LDFLAGS-tst-cet-legacy-mod-6c.so = -Wl,--enable-new-dtags,-z,nodelete
|
|
|
d8307d |
ifneq (no,$(have-tunables))
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4a: $(libdl)
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so
|
|
|
d8307d |
@@ -54,6 +80,14 @@ tst-cet-legacy-4b-ENV = GLIBC_TUNABLES=glibc.tune.x86_shstk=on
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4c: $(libdl)
|
|
|
d8307d |
$(objpfx)tst-cet-legacy-4c.out: $(objpfx)tst-cet-legacy-mod-4.so
|
|
|
d8307d |
tst-cet-legacy-4c-ENV = GLIBC_TUNABLES=glibc.tune.x86_shstk=off
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-5b: $(libdl)
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-5b.out: $(objpfx)tst-cet-legacy-mod-5a.so \
|
|
|
d8307d |
+ $(objpfx)tst-cet-legacy-mod-5b.so
|
|
|
d8307d |
+tst-cet-legacy-5b-ENV = GLIBC_TUNABLES=glibc.tune.x86_ibt=off:glibc.tune.x86_shstk=off
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-6b: $(libdl)
|
|
|
d8307d |
+$(objpfx)tst-cet-legacy-6b.out: $(objpfx)tst-cet-legacy-mod-6a.so \
|
|
|
d8307d |
+ $(objpfx)tst-cet-legacy-mod-6b.so
|
|
|
d8307d |
+tst-cet-legacy-6b-ENV = GLIBC_TUNABLES=glibc.tune.x86_ibt=off:glibc.tune.x86_shstk=off
|
|
|
d8307d |
endif
|
|
|
d8307d |
endif
|
|
|
d8307d |
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-5.c b/sysdeps/x86/tst-cet-legacy-5.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..fbf640f664
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-5.c
|
|
|
d8307d |
@@ -0,0 +1,76 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <dlfcn.h>
|
|
|
d8307d |
+#include <stdio.h>
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+#include <stdbool.h>
|
|
|
d8307d |
+#include <string.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+static void
|
|
|
d8307d |
+do_test_1 (const char *modname, bool fail)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ int (*fp) (void);
|
|
|
d8307d |
+ void *h;
|
|
|
d8307d |
+
|
|
|
d8307d |
+ h = dlopen (modname, RTLD_LAZY);
|
|
|
d8307d |
+ if (h == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ if (fail)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ const char *err = dlerror ();
|
|
|
d8307d |
+ if (strstr (err, "shadow stack isn't enabled") == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ printf ("incorrect dlopen '%s' error: %s\n", modname,
|
|
|
d8307d |
+ dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ return;
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ fp = dlsym (h, "test");
|
|
|
d8307d |
+ if (fp == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ printf ("cannot get symbol 'test': %s\n", dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ if (fp () != 0)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ puts ("test () != 0");
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ dlclose (h);
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+static int
|
|
|
d8307d |
+do_test (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ do_test_1 ("tst-cet-legacy-mod-5a.so", true);
|
|
|
d8307d |
+ do_test_1 ("tst-cet-legacy-mod-5b.so", false);
|
|
|
d8307d |
+ return 0;
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <support/test-driver.c>
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-5a.c b/sysdeps/x86/tst-cet-legacy-5a.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..fc5a609dff
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-5a.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-5.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-5b.c b/sysdeps/x86/tst-cet-legacy-5b.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..fc5a609dff
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-5b.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-5.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-6.c b/sysdeps/x86/tst-cet-legacy-6.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..9151225264
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-6.c
|
|
|
d8307d |
@@ -0,0 +1,76 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <dlfcn.h>
|
|
|
d8307d |
+#include <stdio.h>
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+#include <stdbool.h>
|
|
|
d8307d |
+#include <string.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+static void
|
|
|
d8307d |
+do_test_1 (const char *modname, bool fail)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ int (*fp) (void);
|
|
|
d8307d |
+ void *h;
|
|
|
d8307d |
+
|
|
|
d8307d |
+ h = dlopen (modname, RTLD_LAZY);
|
|
|
d8307d |
+ if (h == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ if (fail)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ const char *err = dlerror ();
|
|
|
d8307d |
+ if (strstr (err, "shadow stack isn't enabled") == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ printf ("incorrect dlopen '%s' error: %s\n", modname,
|
|
|
d8307d |
+ dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ return;
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ fp = dlsym (h, "test");
|
|
|
d8307d |
+ if (fp == NULL)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ printf ("cannot get symbol 'test': %s\n", dlerror ());
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ if (fp () != 0)
|
|
|
d8307d |
+ {
|
|
|
d8307d |
+ puts ("test () != 0");
|
|
|
d8307d |
+ exit (1);
|
|
|
d8307d |
+ }
|
|
|
d8307d |
+
|
|
|
d8307d |
+ dlclose (h);
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+static int
|
|
|
d8307d |
+do_test (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ do_test_1 ("tst-cet-legacy-mod-6a.so", true);
|
|
|
d8307d |
+ do_test_1 ("tst-cet-legacy-mod-6b.so", false);
|
|
|
d8307d |
+ return 0;
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <support/test-driver.c>
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-6a.c b/sysdeps/x86/tst-cet-legacy-6a.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..2d1546d36b
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-6a.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-6.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-6b.c b/sysdeps/x86/tst-cet-legacy-6b.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..2d1546d36b
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-6b.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-6.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-5.c b/sysdeps/x86/tst-cet-legacy-mod-5.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..3c1071c2ef
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-5.c
|
|
|
d8307d |
@@ -0,0 +1,31 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <error.h>
|
|
|
d8307d |
+#include <stdio.h>
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+extern void foo (void);
|
|
|
d8307d |
+
|
|
|
d8307d |
+int
|
|
|
d8307d |
+test (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ foo ();
|
|
|
d8307d |
+ return 0;
|
|
|
d8307d |
+}
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-5a.c b/sysdeps/x86/tst-cet-legacy-mod-5a.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..daa43e4e8d
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-5a.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-mod-5.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-5b.c b/sysdeps/x86/tst-cet-legacy-mod-5b.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..daa43e4e8d
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-5b.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-mod-5.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-5c.c b/sysdeps/x86/tst-cet-legacy-mod-5c.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..e529a42ac0
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-5c.c
|
|
|
d8307d |
@@ -0,0 +1,36 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+static int called = 0;
|
|
|
d8307d |
+
|
|
|
d8307d |
+static void
|
|
|
d8307d |
+__attribute__ ((constructor))
|
|
|
d8307d |
+init (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ called = 1;
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+void
|
|
|
d8307d |
+foo (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ if (!called)
|
|
|
d8307d |
+ abort ();
|
|
|
d8307d |
+}
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-6.c b/sysdeps/x86/tst-cet-legacy-mod-6.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..3c1071c2ef
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-6.c
|
|
|
d8307d |
@@ -0,0 +1,31 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <error.h>
|
|
|
d8307d |
+#include <stdio.h>
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+extern void foo (void);
|
|
|
d8307d |
+
|
|
|
d8307d |
+int
|
|
|
d8307d |
+test (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ foo ();
|
|
|
d8307d |
+ return 0;
|
|
|
d8307d |
+}
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-6a.c b/sysdeps/x86/tst-cet-legacy-mod-6a.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..c89b8fe8ff
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-6a.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-mod-6.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-6b.c b/sysdeps/x86/tst-cet-legacy-mod-6b.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..c89b8fe8ff
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-6b.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-mod-6.c"
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-6c.c b/sysdeps/x86/tst-cet-legacy-mod-6c.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..e529a42ac0
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-6c.c
|
|
|
d8307d |
@@ -0,0 +1,36 @@
|
|
|
d8307d |
+/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
|
d8307d |
+ shared object.
|
|
|
d8307d |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <stdlib.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+static int called = 0;
|
|
|
d8307d |
+
|
|
|
d8307d |
+static void
|
|
|
d8307d |
+__attribute__ ((constructor))
|
|
|
d8307d |
+init (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ called = 1;
|
|
|
d8307d |
+}
|
|
|
d8307d |
+
|
|
|
d8307d |
+void
|
|
|
d8307d |
+foo (void)
|
|
|
d8307d |
+{
|
|
|
d8307d |
+ if (!called)
|
|
|
d8307d |
+ abort ();
|
|
|
d8307d |
+}
|
|
|
d8307d |
diff --git a/sysdeps/x86/tst-cet-legacy-mod-6d.c b/sysdeps/x86/tst-cet-legacy-mod-6d.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000..eb233a1d10
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/x86/tst-cet-legacy-mod-6d.c
|
|
|
d8307d |
@@ -0,0 +1 @@
|
|
|
d8307d |
+#include "tst-cet-legacy-mod-6c.c"
|