mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andi Kleen <andi@firstfloor.org>,
	Roland McGrath <roland@redhat.com>,
	Petr Tesarik <ptesarik@suse.cz>
Subject: [PATCH v3 7/9] x86: mark writable vDSO sections as broken
Date: Tue, 16 Jun 2009 14:55:27 +0200	[thread overview]
Message-ID: <1245156929-30395-8-git-send-email-ptesarik@suse.cz> (raw)
In-Reply-To: <1245156929-30395-1-git-send-email-ptesarik@suse.cz>

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@suse.cz>
---
 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 : {
 		*(.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.
 		 */
 		*(.plt)
-- 
1.6.0.2


  parent reply	other threads:[~2009-06-16 12:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16 12:55 [PATCH v3 0/9] clean up vdso-layout.lds.S Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 1/9] x86: Adjust the coding style of vdso-layout.lds.S Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 2/9] x86: Remove .sdata from the vDSO linker script Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 3/9] x86: add .broken section to " Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 4/9] x86: mark altinstr-related sections in vDSO as broken Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 5/9] x86: mark some standard sections as broken in a vDSO Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 6/9] x86: move 32-bit vDSO padding from .data to .rodata Petr Tesarik
2009-06-16 12:55 ` Petr Tesarik [this message]
2009-06-16 12:55 ` [PATCH v3 8/9] x86: check the size of GOT in vDSO Petr Tesarik
2009-06-16 12:55 ` [PATCH v3 9/9] x86: remove .gnu.warning* sections from the vDSO Petr Tesarik
2009-06-26 11:45 ` [PATCH v3 0/9] clean up vdso-layout.lds.S Petr Tesarik
2009-06-26 17:16   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245156929-30395-8-git-send-email-ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®