[PATCH v3 7/9] x86: mark writable vDSO sections as broken

From: Petr Tesarik
Date: Tue Jun 16 2009 - 08:57:38 EST

The vDSO is mapped read-only into the process' address space, so
any write accesses to it are broken and would segfault.

Additionally, if there is any uninitialized data, the vDSO setup
code does not allocate any space for it, so this is doubly broken.

The .dynbss section is a place to put symbols which are defined by
dynamic objects, are referenced by regular objects, and are not
functions. Space for these objects is allocated in the process image,
and the dynamic linker copies the object data (using a copy relocation).
So, there should never ever be a .dynbss section in a shared object
(and GNU binutils can't produce one, for sure), but then we can place
it into .broken, too.

As a side effect, the .data section now only contains the Global Offset
Table. Give it a more appropriate name for that.

Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx>
arch/x86/vdso/vdso-layout.lds.S | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S
index 74fc5ae..53317a6 100644
--- a/arch/x86/vdso/vdso-layout.lds.S
+++ b/arch/x86/vdso/vdso-layout.lds.S
@@ -48,13 +48,8 @@ SECTIONS
.rodata : {
} :text
- .data : {
- *(.data*)
+ .got : {
*(.got.plt) *(.got)
- *(.gnu.linkonce.d.*)
- *(.bss*)
- *(.dynbss*)
- *(.gnu.linkonce.b.*)

@@ -76,6 +71,16 @@ SECTIONS
.broken : {
+ * The vDSO is mapped read-only, so any writable
+ * sections are broken (and will segfault at runtime).
+ * Additionally, space for uninitialized data is not
+ * even allocated by the vDSO setup code.
+ */
+ *(.data* .gnu.linkonce.d.*)
+ *(.bss* .gnu.linkonce.b.*)
+ *(.dynbss*)
+ /*
* Code in the Procedure Linkage Table will segfault.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/