|
Packit Service |
6fbbd5 |
/* Check compatibility of CET-enabled executable with dlopened legacy
|
|
Packit Service |
6fbbd5 |
shared object.
|
|
Packit Service |
6fbbd5 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
6fbbd5 |
This file is part of the GNU C Library.
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
6fbbd5 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
6fbbd5 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
6fbbd5 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
6fbbd5 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
6fbbd5 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
6fbbd5 |
Lesser General Public License for more details.
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
6fbbd5 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
6fbbd5 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
#include <dlfcn.h>
|
|
Packit Service |
6fbbd5 |
#include <stdio.h>
|
|
Packit Service |
6fbbd5 |
#include <stdlib.h>
|
|
Packit Service |
6fbbd5 |
#include <stdbool.h>
|
|
Packit Service |
6fbbd5 |
#include <string.h>
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
static void
|
|
Packit Service |
6fbbd5 |
do_test_1 (const char *modname, bool fail)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
int (*fp) (void);
|
|
Packit Service |
6fbbd5 |
void *h;
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
h = dlopen (modname, RTLD_LAZY);
|
|
Packit Service |
6fbbd5 |
if (h == NULL)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
if (fail)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
const char *err = dlerror ();
|
|
Packit Service |
6fbbd5 |
if (strstr (err, "shadow stack isn't enabled") == NULL)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
printf ("incorrect dlopen '%s' error: %s\n", modname,
|
|
Packit Service |
6fbbd5 |
dlerror ());
|
|
Packit Service |
6fbbd5 |
exit (1);
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
return;
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
printf ("cannot open '%s': %s\n", modname, dlerror ());
|
|
Packit Service |
6fbbd5 |
exit (1);
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
fp = dlsym (h, "test");
|
|
Packit Service |
6fbbd5 |
if (fp == NULL)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
printf ("cannot get symbol 'test': %s\n", dlerror ());
|
|
Packit Service |
6fbbd5 |
exit (1);
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
if (fp () != 0)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
puts ("test () != 0");
|
|
Packit Service |
6fbbd5 |
exit (1);
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
dlclose (h);
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
static int
|
|
Packit Service |
6fbbd5 |
do_test (void)
|
|
Packit Service |
6fbbd5 |
{
|
|
Packit Service |
6fbbd5 |
do_test_1 ("tst-cet-legacy-mod-6a.so", true);
|
|
Packit Service |
6fbbd5 |
do_test_1 ("tst-cet-legacy-mod-6b.so", false);
|
|
Packit Service |
6fbbd5 |
return 0;
|
|
Packit Service |
6fbbd5 |
}
|
|
Packit Service |
6fbbd5 |
|
|
Packit Service |
6fbbd5 |
#include <support/test-driver.c>
|