mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
* elf/tst-execstack.c (do_test): Don't fail if SELinux forbids
executable stacks.
This commit is contained in:
@ -1,5 +1,8 @@
|
|||||||
2007-12-16 Ulrich Drepper <drepper@redhat.com>
|
2007-12-16 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/tst-execstack.c (do_test): Don't fail if SELinux forbids
|
||||||
|
executable stacks.
|
||||||
|
|
||||||
* malloc/malloc.c (public_mTRIm): Iterate over all arenas and call
|
* malloc/malloc.c (public_mTRIm): Iterate over all arenas and call
|
||||||
mTRIm for all of them.
|
mTRIm for all of them.
|
||||||
(mTRIm): Additionally iterate over all free blocks and use madvise
|
(mTRIm): Additionally iterate over all free blocks and use madvise
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
on load of a DSO that requires executable stacks. */
|
on load of a DSO that requires executable stacks. */
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -45,9 +46,43 @@ waiter_thread (void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static bool allow_execstack = true;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
/* Check whether SELinux is enabled and disallows executable stacks. */
|
||||||
|
FILE *fp = fopen ("/selinux/enforce", "r");
|
||||||
|
if (fp != NULL)
|
||||||
|
{
|
||||||
|
char *line = NULL;
|
||||||
|
size_t linelen = 0;
|
||||||
|
|
||||||
|
bool enabled = false;
|
||||||
|
ssize_t n = getline (&line, &linelen, fp);
|
||||||
|
if (n > 0 && line[0] != '0')
|
||||||
|
enabled = true;
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
fp = fopen ("/selinux/booleans/allow_execstack", "r");
|
||||||
|
if (fp != NULL)
|
||||||
|
{
|
||||||
|
n = getline (&line, &linelen, fp);
|
||||||
|
if (n > 0 && line[0] == '0')
|
||||||
|
allow_execstack = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("executable stacks %sallowed\n", allow_execstack ? "" : "not ");
|
||||||
|
|
||||||
static void *f; /* Address of this is used in other threads. */
|
static void *f; /* Address of this is used in other threads. */
|
||||||
|
|
||||||
#if USE_PTHREADS
|
#if USE_PTHREADS
|
||||||
@ -77,7 +112,7 @@ do_test (void)
|
|||||||
if (h == NULL)
|
if (h == NULL)
|
||||||
{
|
{
|
||||||
printf ("cannot load: %s\n", dlerror ());
|
printf ("cannot load: %s\n", dlerror ());
|
||||||
return 1;
|
return allow_execstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = dlsym (h, "tryme");
|
f = dlsym (h, "tryme");
|
||||||
@ -113,10 +148,10 @@ do_test (void)
|
|||||||
Let them run to test it. */
|
Let them run to test it. */
|
||||||
pthread_barrier_wait (&go_barrier);
|
pthread_barrier_wait (&go_barrier);
|
||||||
|
|
||||||
pthread_exit (0);
|
pthread_exit (! allow_execstack);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return ! allow_execstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user