mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-11 22:00:08 +00:00
2c6cabb3a4
As noted in bug 28475, the access attribute on memfrob in <string.h> is incorrect: the function both reads and writes the memory pointed to by its argument, so it needs to use __read_write__, not __write_only__. This incorrect attribute results in a build failure for accessing uninitialized memory for s390x-linux-gnu-O3 with build-many-glibcs.py using GCC mainline. Correct the attribute. Fixing this shows up that some calls to memfrob in elf/ tests are reading uninitialized memory; I'm not entirely sure of the purpose of those calls, but guess they are about ensuring that the stack space is indeed allocated at that point in the function, and so it matters that they are calling a function whose semantics are unknown to the compiler. Thus, change the first memfrob call in those tests to use explicit_bzero instead, as suggested by Florian in <https://sourceware.org/pipermail/libc-alpha/2021-October/132119.html>, to avoid the use of uninitialized memory. Tested for x86_64, and with build-many-glibcs.py (GCC mainline) for s390x-linux-gnu-O3.
35 lines
662 B
C
35 lines
662 B
C
/* Test program for making nonexecutable stacks executable
|
|
on DT_NEEDED load of a DSO that requires executable stacks. */
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <error.h>
|
|
|
|
extern void tryme (void); /* from tst-execstack-mod.so */
|
|
|
|
static void deeper (void (*f) (void));
|
|
|
|
static int
|
|
do_test (void)
|
|
{
|
|
tryme ();
|
|
|
|
/* Test that growing the stack region gets new executable pages too. */
|
|
deeper (&tryme);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
deeper (void (*f) (void))
|
|
{
|
|
char stack[1100 * 1024];
|
|
explicit_bzero (stack, sizeof stack);
|
|
(*f) ();
|
|
memfrob (stack, sizeof stack);
|
|
}
|
|
|
|
#include <support/test-driver.c>
|