Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1656332

[PATCH 1/6] binfmt_elf: document load_bias a little bit

From riel@redhat.com
Newsgroups linux.kernel
Subject [PATCH 1/6] binfmt_elf: document load_bias a little bit
Date 2017-06-02 17:30 +0200
Message-ID <tNWGu-2XT-7@gated-at.bofh.it> (permalink)
References <tNWGu-2XT-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rik van Riel <riel@redhat.com>

After me and another unnamed developer got confused by the subtraction
of vaddr in this branch of the code, followed by adding vaddr back in
a little bit later, for the third time, maybe it is time to document
this quirky bit of code.

Signed-off-by: Rik van Riel <riel@redhat.com>
---
 fs/binfmt_elf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 5075fd5c62c8..8c3f4dbc7603 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -930,10 +930,16 @@ static int load_elf_binary(struct linux_binprm *bprm)
 		if (loc->elf_ex.e_type == ET_EXEC || load_addr_set) {
 			elf_flags |= MAP_FIXED;
 		} else if (loc->elf_ex.e_type == ET_DYN) {
-			/* Try and get dynamic programs out of the way of the
+			/*
+			 * Try and get dynamic programs out of the way of the
 			 * default mmap base, as well as whatever program they
 			 * might try to exec.  This is because the brk will
-			 * follow the loader, and is not movable.  */
+			 * follow the loader, and is not movable.
+			 *
+			 * The load_bias is the difference between the address
+			 * in the elf header and the address where the binary
+			 * is mmapped.
+			 */
 			load_bias = ELF_ET_DYN_BASE - vaddr;
 			if (current->flags & PF_RANDOMIZE)
 				load_bias += arch_mmap_rnd();
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] move mmap_area and PIE binaries away from the stack riel@redhat.com - 2017-06-02 17:30 +0200
  [PATCH 1/6] binfmt_elf: document load_bias a little bit riel@redhat.com - 2017-06-02 17:30 +0200
    Re: [kernel-hardening] [PATCH 1/6] binfmt_elf: document load_bias a  little bit Kees Cook <keescook@chromium.org> - 2017-06-02 21:30 +0200
  [PATCH 6/6] powerpc,mmap: properly account for stack randomization in mmap_base riel@redhat.com - 2017-06-02 17:30 +0200
  [PATCH 4/6] arm64/mmap: properly account for stack randomization in mmap_base riel@redhat.com - 2017-06-02 17:30 +0200
  [PATCH 2/6] x86/elf: move 32 bit ELF_ET_DYN_BASE to 256MB riel@redhat.com - 2017-06-02 17:30 +0200
    Re: [PATCH 2/6] x86/elf: move 32 bit ELF_ET_DYN_BASE to 256MB Kees Cook <keescook@chromium.org> - 2017-06-03 06:30 +0200
      Re: [PATCH 2/6] x86/elf: move 32 bit ELF_ET_DYN_BASE to 256MB Daniel Micay <danielmicay@gmail.com> - 2017-06-03 14:00 +0200
      Re: [PATCH 2/6] x86/elf: move 32 bit ELF_ET_DYN_BASE to 256MB Rik van Riel <riel@redhat.com> - 2017-06-05 16:00 +0200
  [PATCH 3/6] x86/mmap: properly account for stack randomization in mmap_base riel@redhat.com - 2017-06-02 17:30 +0200
    Re: [kernel-hardening] [PATCH 3/6] x86/mmap: properly account for  stack randomization in mmap_base Kees Cook <keescook@chromium.org> - 2017-06-03 06:50 +0200
      Re: [kernel-hardening] [PATCH 3/6] x86/mmap: properly account for  stack randomization in mmap_base Daniel Micay <danielmicay@gmail.com> - 2017-06-03 14:20 +0200
  [PATCH 5/6] arm64: move COMPAT_ELF_ET_DYN_BASE lower in the address space riel@redhat.com - 2017-06-02 17:30 +0200
  Re: [kernel-hardening] [PATCH 0/6] move mmap_area and PIE binaries  away from the stack Kees Cook <keescook@chromium.org> - 2017-06-03 06:40 +0200
    Re: [kernel-hardening] [PATCH 0/6] move mmap_area and PIE binaries  away from the stack Daniel Micay <danielmicay@gmail.com> - 2017-06-03 14:20 +0200

csiph-web