Skip to content

arm64/mm: migrate swapper_pg_dir

YaoJun kernel-hardening linux-arm-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4arm64/mm: migrate swapper_pg_dirarch/arm64/include/asm/mmu_context.h arch/arm64/include/asm/pgtable.h arch/arm64/kernel/cpufeature.c +5 more+20 -131 reply
2/4arm64/mm: migrate swapper_pg_dirarch/arm64/include/asm/mmu_context.h arch/arm64/include/asm/pgtable.h arch/arm64/mm/kasan_init.c +1 more+4 -20 replies
3/4arm64/mm: migrate swapper_pg_dirarch/arm64/kernel/entry.S arch/arm64/kernel/vmlinux.lds.S+7 -70 replies
4/4arm64/mm: migrate swapper_pg_dirarch/arm64/mm/mmu.c+46 -210 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] arm64/mm: migrate swapper_pg_dir

Currently, The offset between swapper_pg_dir and _text is fixed. When attackers know the address of _text(no KASLR or breaking KASLR), they can caculate the address of swapper_pg_dir. Then KSMA(Kernel Space Mirroring Attack) can be applied.

The principle of KSMA is to insert a carefully constructed PGD entry into the translation table. The type of this entry is block, which maps the kernel text and its access permissions bits are 01. The user process can then modify kernel text directly through this mapping.

To protect against KSMA, these patches migrate swapper_pg_dir to new place, which is dynamically allocated. Since it is allocated during the kernel boot process and the address is relatively fixed, further randomization may be required.

YaoJun (4):
arm64/mm: Introduce __pa_swapper_pg_dir to save physical
address of swapper_pg_dir. And pass it as an argument to __enable_mmu().
arm64/mm: Introduce new_swapper_pg_dir to save virtual
address of new swapper_pg_dir.
arm64/mm: Make tramp_pg_dir and swapper_pg_dir adjacent. arm64/mm: Migrate swapper_pg_dir and tramp_pg_dir.

 arch/arm64/include/asm/mmu_context.h |  6 +--
 arch/arm64/include/asm/pgtable.h     |  2 +
 arch/arm64/kernel/cpufeature.c       |  2 +-
 arch/arm64/kernel/entry.S            |  4 +-
 arch/arm64/kernel/head.S             | 10 ++--
 arch/arm64/kernel/hibernate.c        |  2 +-
 arch/arm64/kernel/sleep.S            |  2 +
 arch/arm64/kernel/vmlinux.lds.S      | 10 ++--
 arch/arm64/mm/kasan_init.c           |  6 +--
 arch/arm64/mm/mmu.c                  | 72 ++++++++++++++++++++--------
 10 files changed, 75 insertions(+), 41 deletions(-)
Signature · 1 line
2.17.0