From nobody Sat Oct 25 11:05:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521196543815481.36399998416584; Fri, 16 Mar 2018 03:35:43 -0700 (PDT) Received: from localhost ([::1]:55937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewmhp-0003hT-PI for importer@patchew.org; Fri, 16 Mar 2018 06:35:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewmgu-0003Kz-8g for qemu-devel@nongnu.org; Fri, 16 Mar 2018 06:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewmgr-0006o7-71 for qemu-devel@nongnu.org; Fri, 16 Mar 2018 06:34:28 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ewmgr-0006nu-0u for qemu-devel@nongnu.org; Fri, 16 Mar 2018 06:34:25 -0400 Received: by mail-pl0-x241.google.com with SMTP id k22-v6so4813131pls.6 for ; Fri, 16 Mar 2018 03:34:24 -0700 (PDT) Received: from cloudburst.twiddle.net ([182.239.85.222]) by smtp.gmail.com with ESMTPSA id j83sm15767853pfj.18.2018.03.16.03.34.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Mar 2018 03:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=aDVyUMJyRTHGyZGcSY8R9M13WBNWj7sJ5+W5PWQLQQw=; b=LwPZ9YyLcnf1hXFMuRYzDX2fW3A+6ojLJlK/CbebFo+pgvYYJwW16RSOceNK9iKeUO CmjciQ+xMKooR37YOVe5ReqSQw6VbK9XxK9jbq2eD8JRU3dTiG8f4DtjGGRb3tjJRHFe TOzKwS9CK0dxnJJ2DF1TXRjcsAIDlv2mJaDDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aDVyUMJyRTHGyZGcSY8R9M13WBNWj7sJ5+W5PWQLQQw=; b=jUNvVItmAJMmW15GusjeVJFheWBP2NL74VMimamgOd1mAw7TD+WAJj1clWGzSWyv9K Hry9hDAYbOyVKPv+yNs+8NWr3gvoS9XcD/jMhH4Jdvx9IDhfVtEhK75vBG78NCPkSP9/ r4HEQsKf4UyUsYudBKtgCc7tYluNB49Svea1H4Lg1DpxKoqesjPIKn6s4i541F0Gr1TR 3SamCx8CQbqXjLiNMcVMHf0N7Ne5+djLiZHg0tLGJ3rshbQlZG8oSJ/wyTL0EnCE/p9x evdjrGFLMBSHdj6BBwPZE2b8xFtUWWNRUBrGFLEEd0iLuKPF2ePdEPO/PnqMCTKhdiQF eKLw== X-Gm-Message-State: AElRT7H07F4JLI3EuIE26BrcsLhUgS2NE6xV9oZXJs5pdi6hrN+D3iq+ x5vZkWSpvUsKfDdZln4cFpyekEeTDhE= X-Google-Smtp-Source: AG47ELvZ8UCuBlYRot43E9OJpwqYqVHnKovfPJ05QNy9FXEcfJGpm1e/W6mx+O1bhyVuCM2Wb9iTaQ== X-Received: by 2002:a17:902:a702:: with SMTP id w2-v6mr1593961plq.340.1521196463136; Fri, 16 Mar 2018 03:34:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 16 Mar 2018 18:34:08 +0800 Message-Id: <20180316103408.22295-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH] linux-user: Allocate extra space for brk in PIE executable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, 1749393@bugs.launchpad.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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, i= nt 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 =3D target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, + abi_ulong total_size =3D hiaddr - loaddr; + if (pinterp_name !=3D NULL) { + /* This is the main executable. + * Hack to reserve some extra space for brk. + */ + abi_ulong extra_size =3D 16 * 1024 * 1024; + load_addr =3D mmap_find_vma(loaddr, total_size + extra_size); + } + load_addr =3D target_mmap(load_addr, total_size, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0); if (load_addr =3D=3D -1) { --=20 2.14.3