|
From: <sv...@va...> - 2013-04-17 10:04:48
|
tom 2013-04-17 11:08:04 +0100 (Wed, 17 Apr 2013)
New Revision: 13368
Log:
Pay attention to PT_GNU_STACK when deciding what permissions to
use for the client stack.
Modified files:
trunk/coregrind/m_initimg/initimg-linux.c
trunk/coregrind/m_ume/elf.c
trunk/coregrind/pub_core_ume.h
Modified: trunk/coregrind/m_initimg/initimg-linux.c (+1 -1)
===================================================================
--- trunk/coregrind/m_initimg/initimg-linux.c 2013-04-11 18:55:39 +01:00 (rev 13367)
+++ trunk/coregrind/m_initimg/initimg-linux.c 2013-04-17 11:08:04 +01:00 (rev 13368)
@@ -557,7 +557,7 @@
res = VG_(am_mmap_anon_fixed_client)(
anon_start -inner_HACK,
anon_size +inner_HACK,
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
+ info->stack_prot
);
}
if ((!ok) || sr_isError(res)) {
Modified: trunk/coregrind/m_ume/elf.c (+7 -0)
===================================================================
--- trunk/coregrind/m_ume/elf.c 2013-04-11 18:55:39 +01:00 (rev 13367)
+++ trunk/coregrind/m_ume/elf.c 2013-04-17 11:08:04 +01:00 (rev 13368)
@@ -354,6 +354,7 @@
info->phnum = e->e.e_phnum;
info->entry = e->e.e_entry + ebase;
info->phdr = 0;
+ info->stack_prot = VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC;
for (i = 0; i < e->e.e_phnum; i++) {
ESZ(Phdr) *ph = &e->p[i];
@@ -416,6 +417,12 @@
}
break;
+ case PT_GNU_STACK:
+ if ((ph->p_flags & PF_X) == 0) info->stack_prot &= ~VKI_PROT_EXEC;
+ if ((ph->p_flags & PF_W) == 0) info->stack_prot &= ~VKI_PROT_WRITE;
+ if ((ph->p_flags & PF_R) == 0) info->stack_prot &= ~VKI_PROT_READ;
+ break;
+
default:
// do nothing
break;
Modified: trunk/coregrind/pub_core_ume.h (+1 -0)
===================================================================
--- trunk/coregrind/pub_core_ume.h 2013-04-11 18:55:39 +01:00 (rev 13367)
+++ trunk/coregrind/pub_core_ume.h 2013-04-17 11:08:04 +01:00 (rev 13368)
@@ -52,6 +52,7 @@
#if !defined(VGO_darwin)
Addr phdr; // OUT: address phdr was mapped at
Int phnum; // OUT: number of phdrs
+ UInt stack_prot; // OUT: stack permissions
Addr interp_base; // OUT: where interpreter (ld.so) was mapped
#else
Addr stack_start; // OUT: address of start of stack segment (hot)
|