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>,
stable@vger.kernel.org
Subject: [PATCH v2 1/3] sparc64: Start bottom-up mmap searches at mm->mmap_base
Date: Sun, 18 Oct 2026 14:27:32 +0200 [thread overview]
Message-ID: <20261018122734.2594904-2-stian@itx.no> (raw)
In-Reply-To: <20261018122734.2594904-1-stian@itx.no>
arch_pick_mmap_layout() randomizes mm->mmap_base for the bottom-up
layout, which every 64-bit task uses, but arch_get_unmapped_area()
starts its search at TASK_UNMAPPED_BASE and never looks at it. Shared
libraries and anonymous mappings of 64-bit tasks therefore land at the
same address on every run; only the stack is randomized.
Before the conversion to vm_unmapped_area() the search started at
mm->free_area_cache, which binfmt_elf set to mm->mmap_base. Use
mm->mmap_base as the low limit again, as generic_get_unmapped_area()
does.
Fixes: bb64f55019c7 ("mm: use vm_unmapped_area() on sparc64 architecture")
Link: https://github.com/sparclinux/issues/issues/119
Cc: stable@vger.kernel.org
Tested-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Stian Halseth <stian@itx.no>
---
arch/sparc/kernel/sys_sparc_64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index ecefcffcf7b10..087595fa43081 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -142,7 +142,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
}
info.length = len;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mm->mmap_base;
info.high_limit = min(task_size, VA_EXCLUDE_START);
info.align_mask = get_align_mask(filp, flags);
if (!file_hugepage)
@@ -151,7 +151,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
VM_BUG_ON(addr != -ENOMEM);
- info.low_limit = VA_EXCLUDE_END;
+ info.low_limit = max(mm->mmap_base, VA_EXCLUDE_END);
info.high_limit = task_size;
addr = vm_unmapped_area(&info);
}
--
2.43.0
next prev 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 ` Stian Halseth [this message]
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-2-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 \
--cc=stable@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®