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 0/3] sparc64: Randomize mmap base and PIE executables
Date: Sun, 18 Oct 2026 14:27:31 +0200 [thread overview]
Message-ID: <20261018122734.2594904-1-stian@itx.no> (raw)
On sparc64 a 64-bit process gets little address space randomization:
the stack moves, but shared libraries, anonymous mappings, PIE
executables and the brk heap land at the same address on every run.
Patch 1 makes arch_get_unmapped_area() start at the randomized
mm->mmap_base again, which it has ignored since v3.8. Patch 2 moves the
32-bit PIE base out of the legacy mmap area, so that patch 3 can select
ARCH_HAS_ELF_RANDOMIZE and randomize PIE executables and brk as on
other architectures.
Found while adding PIE support to the sparc64 Go port:
https://github.com/sparclinux/issues/issues/119
Tested on a T4-1 and a T7-1 (sun4v) and a V240 (sun4u), with 64-bit and
32-bit userland. With the series the program image, brk, shared
libraries and mmap base move between runs, and with
randomize_va_space=0 or setarch -R the layout is the same as before.
The exec and mm selftests, glibc's elf and nptl tests, the Python test
suite and a kernel build give the same results with and without the
series.
Changes in v2:
- New patch 2: move COMPAT_ELF_ET_DYN_BASE below the 32-bit legacy mmap
base, so a 32-bit PIE and the brk of an explicitly executed loader no
longer land in the mmap area (Sashiko). Tested on the T4 with 32-bit
userland, including PIEs with large p_align.
- Add Jan's Tested-by to patches 1 and 3.
v1: https://lore.kernel.org/all/20261017100451.2266781-1-stian@itx.no/
Stian Halseth (3):
sparc64: Start bottom-up mmap searches at mm->mmap_base
sparc64: Move the 32-bit PIE base below the legacy mmap base
sparc64: Randomize the load address of PIE executables
.../features/vm/ELF-ASLR/arch-support.txt | 2 +-
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/elf_64.h | 2 +-
arch/sparc/kernel/sys_sparc_64.c | 18 ++++++++++++++----
4 files changed, 17 insertions(+), 6 deletions(-)
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.43.0
next 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 Stian Halseth [this message]
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 ` [PATCH v2 2/3] sparc64: Move the 32-bit PIE base below the legacy mmap base Stian Halseth
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-1-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®