All of lore.kernel.org
 help / color / mirror / Atom feed
From: Noam Camus <noamc@ezchip.com>
To: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<viro@zeniv.linux.org.uk>
Cc: <Alexey.Brodkin@synopsys.com>, <vgupta@synopsys.com>,
	<adilger@dilger.ca>, <giladb@ezchip.com>,
	Noam Camus <noamc@ezchip.com>
Subject: [PATCH] fs: heap/bss calculation ignore section above STACK_TOP.
Date: Sun, 26 Jul 2015 09:21:01 +0300	[thread overview]
Message-ID: <1437891661-32007-1-git-send-email-noamc@ezchip.com> (raw)

From: Noam Camus <noamc@ezchip.com>

Today bss/heap is placed above last loaded sections.
Current check is only against TASK_SIZE, maybe since most architectures do:

But this is not true for all of them and a gap between TASK_SIZE
and STACK_TOP is possible and may be used for variant purposes.
For example we use it for a special physical memory mapping.

In such case of section in this gap we skip it for matter of
heap/bss calculation.
set_brk will never work for such case anyway.

Signed-off-by: Noam Camus <noamc@ezchip.com>
---
 fs/binfmt_elf.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 6b65996..e445886 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -962,6 +962,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
 
 		k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz;
 
+		if (k >= STACK_TOP)
+			continue;
+
 		if (k > elf_bss)
 			elf_bss = k;
 		if ((elf_ppnt->p_flags & PF_X) && end_code < k)
-- 
1.7.1


             reply	other threads:[~2015-07-26  6:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-26  6:21 Noam Camus [this message]
2015-07-26  6:27 ` [PATCH] fs: heap/bss calculation ignore section above STACK_TOP Noam Camus

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=1437891661-32007-1-git-send-email-noamc@ezchip.com \
    --to=noamc@ezchip.com \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=adilger@dilger.ca \
    --cc=giladb@ezchip.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgupta@synopsys.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.