From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56885606A31A for ; Tue, 1 Dec 2026 03:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=x+JQiPLd; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=FxuclsEh DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=47HtP2mX+MWhSdYU6KYip9kTnkZ9UYS4C8HkodObB9M=; b=x+JQiPLdpH28ne87rxI04+j6TK EEoAKY+OKv/2/PCrG6HNcLPDVUglXIaFgV60C+ATKDq0bQi/kdFDMZnu+OT9PrkrEh86c4kLEY6Xo Qe87oLsctiZzDJ7aHE/3dc+gHZSVwpWeIcIASJkziKUbUuTgKJs4s5qH5ofB7/q9jTAOcm4ziXegZ V/JUnJiGUNSIh9ovHPPaUn23f2hkvoLPxsv4Nnx1tdbOnLVqiHstoXjk2ekj2haeWvGbMgUcZUTd7 GkbzM4ZT36ZCnJucq0PaLyTFGyw+HBmu0wUB+UwOh370LVm+7o/h+XbpXg98/qjdY21T/7UdZmq7E XcIgLLHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYErJ-00000006U4e-3jey; Tue, 01 Dec 2026 03:48:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYErD-00000006U40-2n8h for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 03:48:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A49EF1575; Mon, 30 Nov 2026 19:48:38 -0800 (PST) Received: from localhost (a085714.arm.com [10.164.19.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCE003F632; Mon, 30 Nov 2026 19:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796096921; bh=AJO93fG4ahovm06sP2KtSznXnvpGG99LjMr+NPX4WA4=; h=From:To:Cc:Subject:Date:From; b=FxuclsEh6Px1FlSJe33Ull09DO95aut0+MXO4DeC8hZc5CNsPD/Spl10tUUL29GeF AX12L+uXr3v0T882PZnbvvYRNZtt+VdiKJeW9gMdgDXjbmWeBzH/gR8OxhZI66Ov/L TZi53gauVuG+yONgC50fBld9MwdBicaw6Ra60uh0= From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org Cc: Anshuman Khandual , Mark Rutland , Ryan Roberts , Andrew Morton , Daniel Cashman , linux-kernel@vger.kernel.org Subject: [PATCH V2] arm64/mm: Limit ARCH_MMAP_RND_BITS_MAX to 23 for 42-bit VA Date: Tue, 1 Dec 2026 09:18:34 +0530 Message-ID: <20261201034834.700673-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.43.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_194843_870330_43F4B580 X-CRM114-Status: GOOD ( 14.77 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The existing ARCH_MMAP_RND_BITS_MAX value of 27 for 42-bit VA (64K) pgtable configuration allows mmap() randomization range which exceeds the available user space address space constraints. This can cause mmap() allocations to fail when the maximum randomization is enabled. Although it still requires CONFIG_EXPERT for ARCH_MMAP_RND_BITS to accept values up to ARCH_MMAP_RND_BITS_MAX. 8>------------------------------------------------------------------------ [ 2.269084] Failed to execute /init (error -12) [ 2.269114] Run /sbin/init as init process [ 2.269137] with arguments: [ 2.269153] /sbin/init [ 2.269175] with environment: [ 2.269192] HOME=/ [ 2.269213] TERM=linux [ 2.270517] Starting init: /sbin/init exists but couldn't execute it (error -12) [ 2.270550] Run /etc/init as init process [ 2.270573] with arguments: [ 2.270589] /etc/init [ 2.270611] with environment: [ 2.270628] HOME=/ [ 2.270649] TERM=linux [ 2.270703] Run /bin/init as init process [ 2.270726] with arguments: [ 2.270742] /bin/init [ 2.270764] with environment: [ 2.270781] HOME=/ [ 2.270802] TERM=linux [ 2.270856] Run /bin/sh as init process [ 2.270878] with arguments: [ 2.270895] /bin/sh [ 2.270916] with environment: [ 2.270933] HOME=/ [ 2.270954] TERM=linux [ 2.272254] Starting init: /bin/sh exists but couldn't execute it (error -12) [ 2.272294] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. [ 2.273501] CPU: 0 UID: 0 PID: 1 Comm: sh Not tainted 7.4.0-rc2-00002-g8c7973a9cac1 #1 PREEMPT(full) [ 2.273656] Hardware name: Foundation-v8A (DT) [ 2.273734] Call trace: [ 2.273793] show_stack+0x18/0x24 (C) [ 2.273919] dump_stack_lvl+0x60/0x80 [ 2.274056] dump_stack+0x18/0x24 [ 2.274189] vpanic+0x168/0x354 [ 2.274318] do_panic_on_target_cpu+0x0/0x1c [ 2.274458] kernel_init+0x120/0x150 [ 2.274611] ret_from_fork+0x10/0x20 [ 2.274755] SMP: stopping secondary CPUs [ 2.274835] Kernel Offset: disabled [ 2.274897] CPU features: 0x0,00000000,0030002e,fbb88b43,2edce72f [ 2.274998] Memory Limit: none [ 2.275065] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]--- 8<------------------------------------------------------------------------ Reduce ARCH_MMAP_RND_BITS_MAX from 27 to 23 for 42-bit VA configuration on 64K base page size, which ensures randomization range remains within total available user space. It follows (ARCH_MMAP_RND_BITS_MAX = VA_BITS - PAGE_SHIFT - 3), established via the commit 8f0d3aa9de57 ("arm64: mm: support ARCH_MMAP_RND_BITS") which got changed later in commit 51ecb29f7a65 ("arm64/mm: Define PTDESC_ORDER"), rather erroneously. Revert back to that earlier comment but using the macro PTDESC_ORDER instead. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Ryan Roberts Cc: Andrew Morton Cc: Daniel Cashman Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Fixes: 8f0d3aa9de57 ("arm64: mm: support ARCH_MMAP_RND_BITS") Signed-off-by: Anshuman Khandual --- This patch is based on 7.4-rc5 Changes in V2: - Changed ARCH_MMAP_RND_BITS_MAX from 24 to 23 for 42-bit VA - Changed the in code comment for ARCH_MMAP_RND_BITS_MAX's formula - Changed the commit message Changes in V1: https://lore.kernel.org/all/20261111042027.1541604-1-anshuman.khandual@arm.com/ arch/arm64/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9b08b2457a55..1c3599c9b26e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -296,11 +296,11 @@ config ARCH_MMAP_RND_BITS_MIN default 18 # max bits determined by the following formula: -# VA_BITS - PTDESC_TABLE_SHIFT +# VA_BITS - PAGE_SHIFT - PTDESC_ORDER config ARCH_MMAP_RND_BITS_MAX default 19 if ARM64_VA_BITS=36 default 24 if ARM64_VA_BITS=39 - default 27 if ARM64_VA_BITS=42 + default 23 if ARM64_VA_BITS=42 default 30 if ARM64_VA_BITS=47 default 29 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_64K_PAGES default 31 if (ARM64_VA_BITS=48 || ARM64_VA_BITS=52) && ARM64_16K_PAGES -- 2.43.0