From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, 1749393@bugs.launchpad.net
Subject: [Qemu-devel] [PATCH] linux-user: Allocate extra space for brk in PIE executable
Date: Fri, 16 Mar 2018 18:34:08 +0800 [thread overview]
Message-ID: <20180316103408.22295-1-richard.henderson@linaro.org> (raw)
Limit this to 16M; there does not appear to be any special
support for this in the kernel itself, at least for i686.
Fixes: https://bugs.launchpad.net/bugs/1749393
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
Commentary in the launchpad bug suggests 128M gap for x86_64, but that's
somewhat irrelevant to the given i686 test case. There's certainly nothing
in the referenced kernel patch that does any more than we had been doing
without this patch.
I'm not sure what other limits on extra_size might we want to impose.
With -R set to something less than the full address space we could easily
wind up asking for more space than is available.
r~
---
linux-user/elfload.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 9d10a5f592..e51d441fb9 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2055,7 +2055,15 @@ static void load_elf_image(const char *image_name, int image_fd,
image is pre-linked, LOADDR will be non-zero. Since we do
not supply MAP_FIXED here we'll use that address if and
only if it remains available. */
- load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE,
+ abi_ulong total_size = hiaddr - loaddr;
+ if (pinterp_name != NULL) {
+ /* This is the main executable.
+ * Hack to reserve some extra space for brk.
+ */
+ abi_ulong extra_size = 16 * 1024 * 1024;
+ load_addr = mmap_find_vma(loaddr, total_size + extra_size);
+ }
+ load_addr = target_mmap(load_addr, total_size, PROT_NONE,
MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
-1, 0);
if (load_addr == -1) {
--
2.14.3
next reply other threads:[~2018-03-16 10:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 10:34 Richard Henderson [this message]
2018-03-16 11:01 ` [Qemu-devel] [PATCH] linux-user: Allocate extra space for brk in PIE executable Peter Maydell
2018-03-16 11:44 ` Richard Henderson
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=20180316103408.22295-1-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=1749393@bugs.launchpad.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).