mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stian Halseth <stian@itx.no>
To: Andreas Larsson <andreas@gaisler.com>,
	"David S . Miller" <davem@davemloft.net>
Cc: Kees Cook <kees@kernel.org>,
	Michel Lespinasse <michel@lespinasse.org>,
	Jan Engelhardt <jengelh@inai.de>,
	sparclinux@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Stian Halseth <stian@itx.no>
Subject: [PATCH v2 2/3] sparc64: Move the 32-bit PIE base below the legacy mmap base
Date: Sun, 18 Oct 2026 14:27:33 +0200	[thread overview]
Message-ID: <20261018122734.2594904-3-stian@itx.no> (raw)
In-Reply-To: <20261018122734.2594904-1-stian@itx.no>

COMPAT_ELF_ET_DYN_BASE is 0x70000000, the same address as
TASK_UNMAPPED_BASE for 32-bit tasks. With the legacy bottom-up layout
the mmap area therefore starts where a 32-bit PIE is loaded, and once
ARCH_HAS_ELF_RANDOMIZE is selected binfmt_elf also moves the brk of an
explicitly executed loader there, on top of the loader itself.

Move it to 1GB. x86, arm64 and powerpc use 4MB, but binfmt_elf now
rounds the load address down to the PIE's p_align, and from a 4MB base
an alignment of 8MB or more can round it down to 0. 1GB keeps every
alignment the old base allowed and leaves room for brk below the mmap
area.

Signed-off-by: Stian Halseth <stian@itx.no>
---
 arch/sparc/include/asm/elf_64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 694ed081cf8d9..3f7050369f79d 100644
--- a/arch/sparc/include/asm/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
@@ -190,7 +190,7 @@ typedef struct {
    that it will "exec", and that there is sufficient room for the brk.  */
 
 #define ELF_ET_DYN_BASE		0x0000010000000000UL
-#define COMPAT_ELF_ET_DYN_BASE	0x0000000070000000UL
+#define COMPAT_ELF_ET_DYN_BASE	0x0000000040000000UL
 
 extern unsigned long sparc64_elf_hwcap;
 #define ELF_HWCAP	sparc64_elf_hwcap
-- 
2.43.0


  parent reply	other threads:[~2026-10-18 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 12:27 [PATCH v2 0/3] sparc64: Randomize mmap base and PIE executables Stian Halseth
2026-10-18 12:27 ` [PATCH v2 1/3] sparc64: Start bottom-up mmap searches at mm->mmap_base Stian Halseth
2026-10-18 12:27 ` Stian Halseth [this message]
2026-10-18 12:27 ` [PATCH v2 3/3] sparc64: Randomize the load address of PIE executables Stian Halseth
2026-10-18 13:09 ` [PATCH v2 0/3] sparc64: Randomize mmap base and " John Paul Adrian Glaubitz
2026-10-18 13:33   ` Stian Halseth
2026-10-18 13:38     ` Stian Halseth
2026-10-18 20:37       ` Magnus Lindholm
2026-10-18 21:08         ` Stian Halseth
2026-10-18 21:12           ` Magnus Lindholm

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=20261018122734.2594904-3-stian@itx.no \
    --to=stian@itx.no \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=jengelh@inai.de \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=michel@lespinasse.org \
    --cc=sparclinux@vger.kernel.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

all inboxes | Powered by JetHome®