]> www.infradead.org Git - users/jedix/linux-maple.git/commit
arm64/mm: Sanity check PTE address before runtime P4D/PUD folding
authorArd Biesheuvel <ardb@kernel.org>
Tue, 5 Nov 2024 09:39:20 +0000 (10:39 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 5 Nov 2024 11:48:58 +0000 (11:48 +0000)
commitbaec2397971960e8d5661c616ce20d6a24d7dc4f
tree13533e3d86b4e6fb27d983715b5a1a372ce833a2
parentced841702ee7013ef08159a2cb5cadf0e0820b13
arm64/mm: Sanity check PTE address before runtime P4D/PUD folding

The runtime P4D/PUD folding logic assumes that the respective pgd_t* and
p4d_t* arguments are pointers into actual page tables that are part of
the hierarchy being operated on.

This may not always be the case, and we have been bitten once by this
already [0], where the argument was actually a stack variable, and in
this case, the logic does not work at all.

So let's add a VM_BUG_ON() for each case, to ensure that the address of
the provided page table entry is consistent with the address being
translated.

[0] https://lore.kernel.org/all/20240725090345.28461-1-will@kernel.org/T/#u

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20241105093919.1312049-2-ardb+git@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/pgtable.h