lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bojp5stg.fsf_-_@xmission.com>
Date:	Sun, 08 Jul 2012 23:53:15 -0700
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	Tejun Heo <tj@...nel.org>, hacklu <embedway.linux@...il.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH 2/4] x86 boot: Optimize the elf header handling.


Create a space for the elf headers at the begginng of the kernels
image in memory.

- Rework arch/x86/kernel/vmlinux.lds.S so that we allow room for
  the ELF header in the loaded image.  This removes the need in
  the ELF executalbe to insert padding between the ELf headers
  and the data of the first program segment.  This reduces the
  size of vmlinux by 2MB on x86_64.  This removes an overlap
  of the ELF header and kernel text in arch/x86/boot/compressed
  that required code to moved.

- Move the symbol _text outside of the .text section, and add the
  fixups in relocs.c to add relocations against _text.  This allows
  the symbol _text to come before the ELF header and effectively
  including the ELF header in the text section.

  If this isn't done _text moves 344 bytes in memory on x86_64 and
  creates subtle breakage in routines like cleanup_highmap, which
  assume _text is at the beginning of the kernels memory and that
  _text is 4K+ aligned.

  The current usage of the symbol _text is already that _text
  specifies the beginning of the kernel's memory and that _stext
  specifies where the kernel's code actually starts.

Signed-off-by: Eric W. Biederman <ebiederm@...ssion.com>
---
 arch/x86/kernel/vmlinux.lds.S |    9 +++++----
 arch/x86/tools/relocs.c       |    1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 22a1530..d6e1a44 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -68,7 +68,7 @@ jiffies_64 = jiffies;
 #endif
 
 PHDRS {
-	text PT_LOAD FLAGS(5);          /* R_E */
+	text PT_LOAD FLAGS(5) FILEHDR;  /* R_E */
 	data PT_LOAD FLAGS(6);          /* RW_ */
 #ifdef CONFIG_X86_64
 #ifdef CONFIG_SMP
@@ -82,16 +82,17 @@ PHDRS {
 SECTIONS
 {
 #ifdef CONFIG_X86_32
-        . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
+	_text = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
+        . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR + SIZEOF_HEADERS;
         phys_startup_32 = startup_32 - LOAD_OFFSET;
 #else
-        . = __START_KERNEL;
+	_text = __START_KERNEL;
+        . = __START_KERNEL + SIZEOF_HEADERS;
         phys_startup_64 = startup_64 - LOAD_OFFSET;
 #endif
 
 	/* Text and read-only data */
 	.text :  AT(ADDR(.text) - LOAD_OFFSET) {
-		_text = .;
 		/* bootstrapping code */
 		HEAD_TEXT
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 5a1847d..6f32b7b 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -72,6 +72,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
 	"__end_rodata|"
 	"__initramfs_start|"
 	"(jiffies|jiffies_64)|"
+	"_text|"
 	"_end)$"
 };
 
-- 
1.7.5.4

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ