linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/5] riscv: Introduce KASLR
@ 2023-07-22 12:38 Alexandre Ghiti
  2023-07-22 12:38 ` [PATCH v6 1/5] riscv: Introduce virtual kernel mapping KASLR Alexandre Ghiti
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Alexandre Ghiti @ 2023-07-22 12:38 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Ard Biesheuvel,
	Kees Cook, linux-riscv, linux-kernel, linux-efi, linux-arm-kernel
  Cc: Alexandre Ghiti

The following KASLR implementation allows to randomize the kernel mapping:

- virtually: we expect the bootloader to provide a seed in the device-tree
- physically: only implemented in the EFI stub, it relies on the firmware to
  provide a seed using EFI_RNG_PROTOCOL. arm64 has a similar implementation
  hence the patch 3 factorizes KASLR related functions for riscv to take
  advantage.

The new virtual kernel location is limited by the early page table that only
has one PUD and with the PMD alignment constraint, the kernel can only take
< 512 positions.

base-commit-tag: v6.5-rc1

Changes in v6:
  * Fix reintroduced build failures by compiling kaslr.c only for arm64
    and riscv, as suggested by Ard

Changes in v5:
  * Renamed efi-stub-kaslr.c into kaslr.c and fix commit log of patch 3,
    as suggested by Ard
  * Removed stubs since the kaslr functions were moved to their own file
    (and then does not trigger any build failure for architectures that do
    not call those functions since they are in their own compilation unit)

Changes in v4:
  * Fix efi_get_kimg macro that returned nothing
  * Moved new kaslr functions into their own files to avoid zboot link
    failures, as suggested by Ard

Changes in v3:
  * Rebase on top of 6.4-rc2
  * Make RANDOMIZE_BASE depend on 64bit
  * Fix efi_icache_sync and efi_get_kimg_min_align which were undefined
    in x86 (and certainly other archs)
  * Add patch 4 to fix warning on rv32

Changes in v2:
  * Rebase on top of 6.3-rc1
  * Add a riscv cache sync after memcpying the kernel
  * Add kaslr_offset implementation for KCOV
  * Add forward declaration to quiet LLVM

Alexandre Ghiti (5):
  riscv: Introduce virtual kernel mapping KASLR
  riscv: Dump out kernel offset information on panic
  arm64: libstub: Move KASLR handling functions to kaslr.c
  libstub: Fix compilation warning for rv32
  riscv: libstub: Implement KASLR by using generic functions

 arch/arm64/include/asm/efi.h              |   2 +
 arch/riscv/Kconfig                        |  19 +++
 arch/riscv/include/asm/efi.h              |   2 +
 arch/riscv/include/asm/page.h             |   3 +
 arch/riscv/kernel/image-vars.h            |   1 +
 arch/riscv/kernel/pi/Makefile             |   2 +-
 arch/riscv/kernel/pi/cmdline_early.c      |  13 ++
 arch/riscv/kernel/pi/fdt_early.c          |  30 ++++
 arch/riscv/kernel/setup.c                 |  25 ++++
 arch/riscv/mm/init.c                      |  36 ++++-
 drivers/firmware/efi/libstub/Makefile     |   4 +-
 drivers/firmware/efi/libstub/arm64-stub.c | 117 ++--------------
 drivers/firmware/efi/libstub/efistub.h    |   8 ++
 drivers/firmware/efi/libstub/kaslr.c      | 159 ++++++++++++++++++++++
 drivers/firmware/efi/libstub/riscv-stub.c |  33 ++---
 15 files changed, 328 insertions(+), 126 deletions(-)
 create mode 100644 arch/riscv/kernel/pi/fdt_early.c
 create mode 100644 drivers/firmware/efi/libstub/kaslr.c

-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-09-06 23:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22 12:38 [PATCH v6 0/5] riscv: Introduce KASLR Alexandre Ghiti
2023-07-22 12:38 ` [PATCH v6 1/5] riscv: Introduce virtual kernel mapping KASLR Alexandre Ghiti
2023-07-22 12:38 ` [PATCH v6 2/5] riscv: Dump out kernel offset information on panic Alexandre Ghiti
2023-07-22 12:38 ` [PATCH v6 3/5] arm64: libstub: Move KASLR handling functions to kaslr.c Alexandre Ghiti
2023-07-22 12:38 ` [PATCH v6 4/5] libstub: Fix compilation warning for rv32 Alexandre Ghiti
2023-07-22 12:38 ` [PATCH v6 5/5] riscv: libstub: Implement KASLR by using generic functions Alexandre Ghiti
2023-08-15 11:24 ` [PATCH v6 0/5] riscv: Introduce KASLR Song Shuai
2023-08-17 13:10   ` Alexandre Ghiti
2023-08-17 13:27     ` Song Shuai
2023-08-30 21:30 ` Sami Tolvanen
2023-08-31  5:33   ` Conor Dooley
2023-09-06 23:27   ` Charlie Jenkins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).