From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795043411; b=tgrIpZtnDbQ4x05Xbva+h8vSGWBRhQacCEPb/haHjNCojRTUQet4wizLQfS/ihHzd5Al mv7B8Vy/o6Pre+0E6aYdgdraUqjcBVmoR0Zos9SJHOE2dfqYsgxM6XQGu8pNs1toa3zLR l1H1d4uFuBXOVE5C1tKlUJJrzscXfExPg5KAl4IBdb3yjkv3X7snNTq7qV0Y96XD7/gGh WQhGX6GhjpZolA8SfAIQCh5kGr0ppRfpCWiSWkDWyL5yKfin3ZSIsblVMwMDsP46ODDFw fPTXK9GOPZO8O35BkMVnOBP0Da+Sq1d005Yy7TtAomDmHGh9pdFtSJh60SQYvCRIERQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795043411; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=EMZgcMiQYlSuu18wVtUpMlWK0qL8TI7fnK9J2X2Puko=; b=HUPrImkXkS+aI1v2OkA0uFmBp3JuSIoMX0h+VOu6a0S0JELepWCTYVuBZnKKxGXxwDlf iEdLWIuuro+DDdiGNNjqL/VrueA+Eb8tm/kWdt0TzGdTP3YJSfJ0GVV2PNELXOEbxVhUH 5k4FckaapHsXN8Lr2S6A1jaCZrQee0KtX0eo9kKWD9caXZZlRHJCr0k3cw4s7BAmVncJ1 W/YdvZ/DnPA671Ca8F9oHFtEm9UOLS1D41OGJJerezlVBnKUItstoydUc1BqIxQ1NWEJz eSe5+80EhLGDUUQhcc/nJUIbNw43a8S7W8Nt7TKzw8ZpqjxURI2XMmO8HZ3RRhQ1QKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xcplPAlP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDD6E606A335; Wed, 18 Nov 2026 23:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xcplPAlP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17AB41F000C8; Wed, 18 Nov 2026 23:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795043411; bh=EMZgcMiQYlSuu18wVtUpMlWK0qL8TI7fnK9J2X2Puko=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xcplPAlPpPQvH+EYb8DACBA3eB8AQzRLsDjik62iVGI45yY3a19L7n1Jxm9h0a3ss mIjJh5GWhRilGAgWmV5cNnytFvYhFtfNZ9cFj9EkWRvRLgbN4YS/PJV3yfJ2WF/dBf Hy+13NveX3Ss2VCujx+UKGWskrgvrLdsicRJUrfs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, liulhong617 , Will Deacon , Sasha Levin Subject: [PATCH 6.1 0202/2857] arm64: mm: fix accidental linear mapping of no-map reserved memory Date: Wed, 18 Nov 2026 15:20:36 +0100 Message-ID: <20261118150208.623702986@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: liulhong617 [ Upstream commit 7ace06a01efaba1ec585630aa4c98ac39b38452a ] When reserved-memory regions with the "no-map" property are not page-aligned, the kernel may accidentally map them into the linear mapping, contradicting the no-map semantics. The root cause is a mismatch between /proc/iomem's address boundaries and the actual page table mapping boundaries: 1. /proc/iomem derives its ranges from memblock via memblock_region_reserved_base_pfn/memblock_region_reserved_end_pfn, which perform PFN rounding so the displayed boundaries are page-aligned. This gives the impression that the no-map region occupies whole pages. 2. However, memblock_mark_nomap() splits memblock.memory regions at exact byte boundaries (memblock_isolate_range preserves raw DT base/size with no alignment). When for_each_mem_range iterates the non-NOMAP regions adjacent to a no-map region, it returns start/end values that are NOT page-aligned — they are the precise byte boundaries from the memblock split. 3. These sub-page-aligned values are passed to __create_pgd_mapping_locked(), which does: phys &= PAGE_MASK; addr = virt & PAGE_MASK; end = PAGE_ALIGN(virt + size); The downward rounding of phys via PAGE_MASK extends the mapped range backward into the adjacent no-map region, effectively including no-map memory in the linear mapping. For example, with 64K pages, reserved_region@A2000000 (base=0xA2000000, size=0x8000, no-map) causes for_each_mem_range to return start=0xA2008000 for the next mappable region. After phys &= PAGE_MASK, the actual mapping starts at 0xA2000000 — the entire no-map region is incorrectly mapped. Fix this by rounding the mappable range inward to PAGE_SIZE boundaries before passing it to __map_memblock: start is rounded UP and end is rounded DOWN. This ensures the mapped area never overlaps with adjacent no-map regions. The cost is at most one page of unmapped gap at each boundary, which is preferable to violating no-map semantics. Signed-off-by: liulhong617 Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/mm/mmu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 72fb70f2bfb20..fb6a731970028 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -623,6 +623,20 @@ static void __init map_mem(pgd_t *pgdp) for_each_mem_range(i, &start, &end) { if (start >= end) break; + /* + * for_each_mem_range may return sub-page-aligned boundaries + * after memblock_mark_nomap() splits regions at byte precision. + * __create_pgd_mapping_locked aligns phys down to PAGE_MASK, + * which could accidentally map no-map memory on the boundary. + * Round the mappable range inward: start UP, end DOWN, so + * that the mapped area never overlaps with adjacent no-map + * regions. The cost is at most one page of unmapped gap at + * each boundary. + */ + start = PAGE_ALIGN(start); + end = end & PAGE_MASK; + if (start >= end) + continue; /* * The linear map must allow allocation tags reading/writing * if MTE is present. Otherwise, it has the same attributes as -- 2.53.0