Commit Graph

5 Commits

Author SHA1 Message Date
Siddhesh Poyarekar 9c6ea9facb Fix stack size and address inconsistency due to executable stack
When a stack is marked executable due to loading a DSO that requires
an executable stack, the logic tends to leave out a portion of stack
after the first frame, thus causing a difference in the value returned
by pthread_getattr_np before and after the stack is marked
executable. It ought to be possible to fix this by marking the rest of
the stack as executable too, but in the interest of marking as less of
the stack as executable as possible, the path this fix takes is to
make pthread_getattr_np also look at the first frame as the underflow
end of the stack and compute size and stack top accordingly.

The above happens only for the main process stack. NPTL thread stacks
are not affected by this change.
2012-05-26 09:48:26 +05:30
Ulrich Drepper 3005703bb9 Add cast in tst-execstack to avoid warning. 2009-10-30 09:26:00 -07:00
Ulrich Drepper d9961b6a4f * elf/tst-execstack.c (do_test): Don't fail if SELinux forbids
executable stacks.
2007-12-17 00:00:57 +00:00
Roland McGrath 26e059c142 2004-04-01 Roland McGrath <roland@redhat.com>
* elf/tst-execstack.c (do_test): Make F static.
2004-04-02 02:23:05 +00:00
Roland McGrath 2abf9ff113 * sysdeps/i386/dl-machine.h (RTLD_START): Set __libc_stack_end before
calling _dl_start, using GOTOFF access.

	* configure.in (libc_cv_z_execstack): New check.
	* configure: Regenerated.
	* config.make.in (have-z-execstack): New variable set by it.
	* elf/tst-execstack.c: New file.
	* elf/tst-execstack-mod.c: New file.
	* elf/tst-execstack-needed.c: New file.
	* elf/Makefile (tests-execstack-yes, modules-execstack-yes): New
	variables.
	(tests, modules-names): Conditionally include them.
	(distribute): Add tst-execstack-mod.c here.
	($(objpfx)tst-execstack, $(objpfx)tst-execstack.out): New targets.
	(LDFLAGS-tst-execstack, LDFLAGS-tst-execstack-mod): New variables.
	($(objpfx)tst-execstack-needed): New target.
	(LDFLAGS-tst-execstack-needed): New variable.

	* sysdeps/generic/ldsodefs.h (struct rtld_global): Add _dl_stack_flags
	and _dl_make_stack_executable_hook.  Declare _dl_make_stack_executable.
	* elf/rtld.c (_rtld_global): Add initializer for _dl_stack_flags.
	(dl_main): Reset _dl_stack_flags according to PT_GNU_STACK phdr.
	Initialize _dl_make_stack_executable_hook.
	* elf/dl-support.c: Define those new variables.
	(_dl_non_dynamic_init): Scan phdrs for PT_GNU_STACK.
	(_dl_phdr): Fix type.
	* elf/dl-load.c (_dl_map_object_from_fd): Grok PT_GNU_STACK phdr and
	enable execute permission for the stack if necessary.
	* sysdeps/generic/dl-execstack.c: New file.
	* elf/Makefile (dl-routines): Add it.
	* elf/Versions (ld: GLIBC_PRIVATE): Add _dl_make_stack_executable.
	* sysdeps/unix/sysv/linux/dl-execstack.c: New file.
2003-09-23 12:07:26 +00:00