Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA
@ 2026-10-15  5:23 Iurii Trukhin
  2026-10-15 13:32 ` Anshuman Khandual
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Iurii Trukhin @ 2026-10-15  5:23 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Kees Cook
  Cc: Anshuman Khandual, Mark Rutland, Ryan Roberts, Ard Biesheuvel,
	Gustavo A. R. Silva, linux-arm-kernel, linux-hardening,
	linux-kernel, Iurii Trukhin

Since commit f101c5644771 ("arm64: Support ARM64_VA_BITS=52 when
setting ARCH_MMAP_RND_BITS_MAX"), arm64 supports up to 33, 31, and 29
bits of mmap ASLR entropy on 48-bit and 52-bit virtual address spaces
for 4K, 16K, and 64K pages respectively. However, ARCH_MMAP_RND_BITS
still defaults to ARCH_MMAP_RND_BITS_MIN (18, 16, and 14 bits), which
was set in commit 8f0d3aa9de57 ("arm64: mm: support ARCH_MMAP_RND_BITS")
when 39-bit VA was the 4K default.

Set the default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA to 28 (4K
pages), 26 (16K pages), and 24 (64K pages), matching x86_64's 1 TiB
randomization range (5 bits below ARCH_MMAP_RND_BITS_MAX) while keeping
ARCH_MMAP_RND_BITS_MIN unchanged for smaller VA configurations.

Closes: https://github.com/KSPP/linux/issues/371
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Iurii Trukhin <yuri@trukhin.com>
---
Changes in v2:
- Add a comment above ARCH_MMAP_RND_BITS explaining the 1 TiB default
  for 48/52-bit VA and the fallback to ARCH_MMAP_RND_BITS_MIN in
  arch/Kconfig for smaller VA sizes (Anshuman Khandual).
- Collect Reviewed-by from Kees Cook.
- Link to v1: https://lore.kernel.org/r/CAOx7e9Jm0N9O_ndL1UApMPrXUN=P4RiptSNibdDP+9prUsNPOw@mail.gmail.com
 arch/arm64/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index cab741a695f5..7bca47269dd5 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -313,6 +313,14 @@ config ARCH_MMAP_RND_BITS_MAX
 	default 16 if ARM64_16K_PAGES
 	default 18

+# default to 1 TiB (5 bits below ARCH_MMAP_RND_BITS_MAX) on 48-bit and
+# 52-bit VA; smaller VA sizes fall back to ARCH_MMAP_RND_BITS_MIN in
+# arch/Kconfig
+config ARCH_MMAP_RND_BITS
+	default 24 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_64K_PAGES
+	default 26 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_16K_PAGES
+	default 28 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52)
+
 config ARCH_MMAP_RND_COMPAT_BITS_MIN
 	default 7 if ARM64_64K_PAGES
 	default 9 if ARM64_16K_PAGES
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA
  2026-10-15  5:23 [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA Iurii Trukhin
@ 2026-10-15 13:32 ` Anshuman Khandual
  2026-10-15 16:35 ` Catalin Marinas
  2026-10-15 18:12 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Anshuman Khandual @ 2026-10-15 13:32 UTC (permalink / raw)
  To: Iurii Trukhin
  Cc: Catalin Marinas, Will Deacon, Kees Cook, Mark Rutland,
	Ryan Roberts, Ard Biesheuvel, Gustavo A. R. Silva,
	linux-arm-kernel, linux-hardening, linux-kernel

On Wed, Oct 14, 2026 at 10:23:35PM -0700, Iurii Trukhin wrote:
> Since commit f101c5644771 ("arm64: Support ARM64_VA_BITS=52 when
> setting ARCH_MMAP_RND_BITS_MAX"), arm64 supports up to 33, 31, and 29
> bits of mmap ASLR entropy on 48-bit and 52-bit virtual address spaces
> for 4K, 16K, and 64K pages respectively. However, ARCH_MMAP_RND_BITS
> still defaults to ARCH_MMAP_RND_BITS_MIN (18, 16, and 14 bits), which
> was set in commit 8f0d3aa9de57 ("arm64: mm: support ARCH_MMAP_RND_BITS")
> when 39-bit VA was the 4K default.
> 
> Set the default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA to 28 (4K
> pages), 26 (16K pages), and 24 (64K pages), matching x86_64's 1 TiB
> randomization range (5 bits below ARCH_MMAP_RND_BITS_MAX) while keeping
> ARCH_MMAP_RND_BITS_MIN unchanged for smaller VA configurations.
> 
> Closes: https://github.com/KSPP/linux/issues/371
> Reviewed-by: Kees Cook <kees@kernel.org>
> Signed-off-by: Iurii Trukhin <yuri@trukhin.com>

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

> ---
> Changes in v2:
> - Add a comment above ARCH_MMAP_RND_BITS explaining the 1 TiB default
>   for 48/52-bit VA and the fallback to ARCH_MMAP_RND_BITS_MIN in
>   arch/Kconfig for smaller VA sizes (Anshuman Khandual).
> - Collect Reviewed-by from Kees Cook.
> - Link to v1: https://lore.kernel.org/r/CAOx7e9Jm0N9O_ndL1UApMPrXUN=P4RiptSNibdDP+9prUsNPOw@mail.gmail.com
>  arch/arm64/Kconfig | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index cab741a695f5..7bca47269dd5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -313,6 +313,14 @@ config ARCH_MMAP_RND_BITS_MAX
>  	default 16 if ARM64_16K_PAGES
>  	default 18
> 
> +# default to 1 TiB (5 bits below ARCH_MMAP_RND_BITS_MAX) on 48-bit and
> +# 52-bit VA; smaller VA sizes fall back to ARCH_MMAP_RND_BITS_MIN in
> +# arch/Kconfig
> +config ARCH_MMAP_RND_BITS
> +	default 24 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_64K_PAGES
> +	default 26 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_16K_PAGES
> +	default 28 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52)
> +
>  config ARCH_MMAP_RND_COMPAT_BITS_MIN
>  	default 7 if ARM64_64K_PAGES
>  	default 9 if ARM64_16K_PAGES
> -- 
> 2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA
  2026-10-15  5:23 [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA Iurii Trukhin
  2026-10-15 13:32 ` Anshuman Khandual
@ 2026-10-15 16:35 ` Catalin Marinas
  2026-10-15 18:12 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2026-10-15 16:35 UTC (permalink / raw)
  To: Iurii Trukhin
  Cc: Will Deacon, Kees Cook, Anshuman Khandual, Mark Rutland,
	Ryan Roberts, Ard Biesheuvel, Gustavo A. R. Silva,
	linux-arm-kernel, linux-hardening, linux-kernel

On Wed, Oct 14, 2026 at 10:23:35PM -0700, Iurii Trukhin wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index cab741a695f5..7bca47269dd5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -313,6 +313,14 @@ config ARCH_MMAP_RND_BITS_MAX
>  	default 16 if ARM64_16K_PAGES
>  	default 18
> 
> +# default to 1 TiB (5 bits below ARCH_MMAP_RND_BITS_MAX) on 48-bit and
> +# 52-bit VA; smaller VA sizes fall back to ARCH_MMAP_RND_BITS_MIN in
> +# arch/Kconfig
> +config ARCH_MMAP_RND_BITS
> +	default 24 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_64K_PAGES
> +	default 26 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_16K_PAGES
> +	default 28 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52)

This looks fine but I was wondering what ARCH_MMAP_RND_BITS_DEFAULT (and
the compat equivalent) is for. It turns out that an int always evaluates
to 'n', so not taken into account. It might be worth removing them
altogether as a separate patch. No-one seems to be using them.

-- 
Catalin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA
  2026-10-15  5:23 [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA Iurii Trukhin
  2026-10-15 13:32 ` Anshuman Khandual
  2026-10-15 16:35 ` Catalin Marinas
@ 2026-10-15 18:12 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2026-10-15 18:12 UTC (permalink / raw)
  To: Will Deacon, Kees Cook, Iurii Trukhin
  Cc: Anshuman Khandual, Mark Rutland, Ryan Roberts, Ard Biesheuvel,
	Gustavo A. R. Silva, linux-arm-kernel, linux-hardening,
	linux-kernel

On Wed, 14 Oct 2026 22:23:35 -0700, Iurii Trukhin wrote:
> Since commit f101c5644771 ("arm64: Support ARM64_VA_BITS=52 when
> setting ARCH_MMAP_RND_BITS_MAX"), arm64 supports up to 33, 31, and 29
> bits of mmap ASLR entropy on 48-bit and 52-bit virtual address spaces
> for 4K, 16K, and 64K pages respectively. However, ARCH_MMAP_RND_BITS
> still defaults to ARCH_MMAP_RND_BITS_MIN (18, 16, and 14 bits), which
> was set in commit 8f0d3aa9de57 ("arm64: mm: support ARCH_MMAP_RND_BITS")
> when 39-bit VA was the 4K default.
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA
      https://git.kernel.org/arm64/c/ac9de62b1902


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-15 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15  5:23 [PATCH v2] arm64: raise default ARCH_MMAP_RND_BITS for 48-bit and 52-bit VA Iurii Trukhin
2026-10-15 13:32 ` Anshuman Khandual
2026-10-15 16:35 ` Catalin Marinas
2026-10-15 18:12 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox