diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-06-03 02:43:46 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-06-03 02:43:46 +0000 |
commit | 855c7fda61d9313052a0afdfe851a4b390da845c (patch) | |
tree | 642f6df81dd43219455c140bfcfad9c24efc94e9 /libpthread/nptl/allocatestack.c | |
parent | 03e2c9f6f3d0b3a61208948123fc20393744da27 (diff) | |
download | uClibc-alpine-855c7fda61d9313052a0afdfe851a4b390da845c.tar.bz2 uClibc-alpine-855c7fda61d9313052a0afdfe851a4b390da845c.tar.xz |
Prevent the stack from being executable. This will prevent some NPTL tests
from passing, but it will require some intrustive changes.
Diffstat (limited to 'libpthread/nptl/allocatestack.c')
-rw-r--r-- | libpthread/nptl/allocatestack.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index fcb6c6e47..8d26b2e21 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -29,6 +29,10 @@ #include <tls.h> #include <lowlevellock.h> +#ifdef __UCLIBC__ +#include <link.h> +#define __getpagesize getpagesize +#endif #ifndef NEED_SEPARATE_REGISTER_STACK @@ -389,7 +393,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, size_t reqsize; void *mem; const int prot = (PROT_READ | PROT_WRITE +#ifdef __UCLIBC__ + ); +#else | ((GL(dl_stack_flags) & PF_X) ? PROT_EXEC : 0)); +#endif #if COLORING_INCREMENT != 0 /* Add one more page for stack coloring. Don't do it for stacks @@ -524,6 +532,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, caused the stacks to get exec permission while this new stack was prepared. Detect if this was possible and change the permission if necessary. */ +#ifndef __UCLIBC__ if (__builtin_expect ((GL(dl_stack_flags) & PF_X) != 0 && (prot & PROT_EXEC) == 0, 0)) { @@ -540,6 +549,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, return err; } } +#endif /* Note that all of the stack and the thread descriptor is @@ -671,7 +681,11 @@ internal_function __make_stacks_executable (void **stack_endp) { /* First the main thread's stack. */ +#ifdef __UCLIBC__ + int err = EPERM; +#else int err = _dl_make_stack_executable (stack_endp); +#endif if (err != 0) return err; @@ -910,6 +924,10 @@ __nptl_setxid (struct xid_command *cmdp) static inline void __attribute__((always_inline)) init_one_static_tls (struct pthread *curp, struct link_map *map) { +#ifdef __UCLIBC__ + extern void *__mempcpy (void *dstpp, const void *srcpp, size_t len); +#endif + dtv_t *dtv = GET_DTV (TLS_TPADJ (curp)); # if TLS_TCB_AT_TP void *dest = (char *) curp - map->l_tls_offset; @@ -924,7 +942,11 @@ init_one_static_tls (struct pthread *curp, struct link_map *map) dtv[map->l_tls_modid].pointer.is_static = true; /* Initialize the memory. */ +#ifdef __UCLIBC__ + memset ((void *) __mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), +#else memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), +#endif '\0', map->l_tls_blocksize - map->l_tls_initimage_size); } |