[PATCH 2/2][BZ #12416] Use stack boundaries from /proc/PID/maps to make stack executable

Siddhesh Poyarekar siddhesh@redhat.com
Thu Apr 19 06:29:00 GMT 2012


Hi,

Using __libc_stack_end as the end of stack to mark an executable stack
misses pages at the end of stack that are used to store program
arguments, environment variables and auxiliary elf information. Due to
this, the stack vma gets split and later requests for stack address
using pthread_getattr_np() return a different value than before.

This behaviour can be seen using the reproducer in bz#12416.

This patch fixes an inconsistency between the treatment of stack size
in pthread_getattr_np and _dl_make_stack_executable where the former
used __libc_stack_end to find the stack vma in /proc/PID/maps and used
the real stack end while the latter used the __libc_stack_end itself as
the stack end.

I have modified tst-execstack to test this in make check. Testsuite
reports no new regressions from this patch.

Regards,
Siddhesh

2012-04-19  Siddhesh Poyarekar  <siddhesh@redhat.com>

	[BZ #12416]
	* elf/tst-execstack.c (get_main_stack_bounds): New function.
	(do_test): Modify test to also verify that main stack bounds do
	not change after execstack-dso.so is dlopen'd.
	* sysdeps/unix/sysv/linux/dl-execstack.c (__strtoul_internal):
	Declare extern.
	(__read_one_line, __get_map_bounds): New functions.
	(_dl_make_stack_executable): Use stack bounds
	from /proc/PID/maps if available.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Use-stack-boundaries-from-proc-PID-maps-to-make-stac.patch
Type: text/x-patch
Size: 6054 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120419/05681d2e/attachment.bin>


More information about the Libc-alpha mailing list