]> Gentwo Git Trees - linux/.git/commit
riscv: fix overlap of allocated page and PTR_ERR
authorNam Cao <namcao@linutronix.de>
Thu, 25 Apr 2024 11:52:01 +0000 (13:52 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Mon, 3 Jun 2024 14:41:09 +0000 (07:41 -0700)
commit994af1825a2aa286f4903ff64a1c7378b52defe6
tree0bd0dc5f245f88b8271f3df2f06af00d1a2bb56b
parentc3f38fa61af77b49866b006939479069cd451173
riscv: fix overlap of allocated page and PTR_ERR

On riscv32, it is possible for the last page in virtual address space
(0xfffff000) to be allocated. This page overlaps with PTR_ERR, so that
shouldn't happen.

There is already some code to ensure memblock won't allocate the last page.
However, buddy allocator is left unchecked.

Fix this by reserving physical memory that would be mapped at virtual
addresses greater than 0xfffff000.

Reported-by: Björn Töpel <bjorn@kernel.org>
Closes: https://lore.kernel.org/linux-riscv/878r1ibpdn.fsf@all.your.base.are.belong.to.us
Fixes: 76d2a0493a17 ("RISC-V: Init and Halt Code")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: <stable@vger.kernel.org>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
Link: https://lore.kernel.org/r/20240425115201.3044202-1-namcao@linutronix.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/mm/init.c