From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0270B282F30 for ; Fri, 20 Mar 2026 14:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774018803; cv=none; b=jx6cyV/3Bkw/FnwAKCVb1zjHnf7D4wMdRO8ViWU+3EgTxRibvhY3DRJKDLZgQ2q8omNEtHJlm95W92/AXC/VA86O9Q1ErJgMDkZjTlFT5U4NTytkoqooLYSeoOkppWSKrfaFshh31+U9dzaeiGCnX76ClGTkAiAugGVexY/ZOHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774018803; c=relaxed/simple; bh=GlF9REALPH8Thgc2BqeIb8XMITT2gtWDfWbp3wAEW7k=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=VEqSXgogKY3V/QHlRg12mbCaUPVT7vwFAzljwMKLe0aLgu4D/SQcoqUW7lDyi31FJRpIWZk2dKEwlgZjBNaS4xfxyolIoQkVPDCOF7dH4/ZNCyYILiX6WG//7RkU1pWpIIQbF9FOZNCoX0KTl5oaY+tu8krKz8edOFm83ajw5mU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XablGZRN; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XablGZRN" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-439c112b1a4so421320f8f.3 for ; Fri, 20 Mar 2026 07:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774018798; x=1774623598; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=MdVeokZjbztoTDx0L1beL77+M+R2awklYBvUejvaGn0=; b=XablGZRN22ujDRK8AOeGickbHh0Ajfgo0CVNxfQIUHBKgPjH3x3+dqB63zfbrJm7kV 3FRkK6s/QibOvuPNIJPhD5jQ3C5TolAJDHjDvNLieTkM5jbf0QSCAQKqH51TLV8WmRPp VkJDdDD8yUAlJSZhI03T0Sr3M5dyUpujKjiaOwTJYXI/+8j/XHhs+ZKeB617LaDJjZHb QMUDNUfZXEMvDc/MtxBxbitguOts6kklIlOMiFqjmdCAE3/JMN8ffExsn21Mbu2/52CG XxdVF6V/qme2djJ8U/0O6sLVFbT0I5qawDG62wL8jn4IDmGhr6eyXBmbyn5aP6KXyZfk Bz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774018798; x=1774623598; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MdVeokZjbztoTDx0L1beL77+M+R2awklYBvUejvaGn0=; b=JAkobszwfeiUPCIciKc/0ACO26/86F0nFPmMfx0bMvG8jGHscC3eejlj/dKRGU4OBO axRR4kgrvUkEXm6FBXhSccgliEGfpnF0CXPZ0l5eyTuCYYLhnv9mTXXX89j8h2sUIbwp fySbKPeUVowoG+ynAxvs1+RAkF0BRXHEoKbwFv7onArXweejEXw+GLbdYTIIEVT8aehK fOJZa00ttBwX4jYxkvjTzY9h+KhPjrlCNhCgh5yKDcgRCZHF8/EDPHTjs0t3RQsMourK ByBm3Tr6QbLNQOvYX/dBSCo1dFntckbKmJg2P9k+oFeRMwP/l7fpzBY0dlDJQFFS5FlS 4Wmg== X-Gm-Message-State: AOJu0Yz/2QT6vxZAYG9J9p247cc44gyLmTxrMMvR+9c2ZYxR3RBM3vfv DkgKGZ7VZ4695H2OMseIQ7TnP4RchK+FZtr00TZnc0TLmpjrq0LuysKTfbvvK6cZHNGdYgE6Nwp 9ZCngR6Lgy1PGGTsCXISZY9UsqlEOXuKWCid/QLJdGU+GxaoIL4c2USyztamx/PXyZGG4YPyXva iIfrWS5SrAUEcx8HGef1A8f151j9R7vILG9Q== X-Received: from wmdd6.prod.google.com ([2002:a05:600c:a206:b0:485:3f38:3dd2]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c16e:b0:485:9a50:3370 with SMTP id 5b1f17b1804b1-486fedb9497mr47266945e9.8.1774018797760; Fri, 20 Mar 2026 07:59:57 -0700 (PDT) Date: Fri, 20 Mar 2026 15:59:35 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2793; i=ardb@kernel.org; h=from:subject; bh=Kl2s1+jB9ADBOpcUfcC5kqKIeNKk1TvIXb5NWMCOWDY=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIXNvwvVCm4W7k+S+9jxJDjINjj92aRLDxz2bDl3M7b2wp s9KPyGoo5SFQYyLQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEzE5AjDP53LXxQmHHy20vSM lOnRvwbnXbXOGrF9D47dVOH2/+g/Ph1Ghk2fVeM2bYvJrH70s8vMJO5+75m5nzYEPL4y4+RbeZF dx3kA X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260320145934.2349881-15-ardb+git@google.com> Subject: [PATCH v3 00/13] arm64: Unmap linear alias of kernel data/bss From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Ard Biesheuvel , Ryan Roberts , Anshuman Khandual , Liz Prucka , Seth Jenkins , Kees Cook , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel One of the reasons the lack of randomization of the linear map on arm64 is considered problematic is the fact that bootloaders adhering to the original arm64 boot protocol may place the kernel at the base of DRAM, and therefore at the base of the non-randomized linear map. This puts a writable alias of the kernel's data and bss regions at a predictable location, removing the need for an attacker to guess where KASLR mapped the kernel. Let's unmap this linear, writable alias entirely, so that knowing the location of the linear alias does not give write access to the kernel's data and bss regions. Changes since v2: - Keep bm_pte[] in the region that is remapped r/o or unmapped, as it is only manipulated via its kernel alias - Drop check that prohibits any manipulation of descriptors with the CONT bit set - Add Ryan's ack to a couple of patches - Rebase onto v7.0-rc4 Changes since v1: - Put zero page patch at the start of the series - Tweak __map_memblock() API to respect existing table and contiguous mappings, so that the logic to map the kernel alias can be simplified - Stop abusing the MEMBLOCK_NOMAP flag to initially omit the kernel linear alias from the linear map - Some additional cleanup patches - Use proper API [set_memory_valid()] to (un)map the linear alias of data/bss. Cc: Ryan Roberts Cc: Anshuman Khandual Cc: Liz Prucka Cc: Seth Jenkins Cc: Kees Cook Cc: linux-hardening@vger.kernel.org Ard Biesheuvel (13): arm64: Move the zero page to rodata arm64: mm: Preserve existing table mappings when mapping DRAM arm64: mm: Preserve non-contiguous descriptors when mapping DRAM arm64: mm: Remove bogus stop condition from map_mem() loop arm64: mm: Drop redundant pgd_t* argument from map_mem() arm64: mm: Permit contiguous descriptors to be rewritten arm64: mm: Use hierarchical XN mapping for the fixmap arm64: kfence: Avoid NOMAP tricks when mapping the early pool arm64: mm: Permit contiguous attribute for preliminary mappings arm64: Move fixmap page tables to end of kernel image arm64: mm: Don't abuse memblock NOMAP to check for overlaps arm64: mm: Map the kernel data/bss read-only in the linear map arm64: mm: Unmap kernel data/bss entirely from the linear map arch/arm64/include/asm/pgtable.h | 4 + arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 6 + arch/arm64/mm/fixmap.c | 8 +- arch/arm64/mm/mmu.c | 138 +++++++++++--------- 5 files changed, 90 insertions(+), 67 deletions(-) base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c -- 2.53.0.959.g497ff81fa9-goog