Skip to content

RFC x86_64: Harden compressed kernel, part 1

Evgeniy Baskov linux-hardening lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86/boot: Align vmlinuz sections on page sizearch/x86/boot/compressed/vmlinux.lds.S+6 -00 replies
2/8x86/build: Remove RWX sections and align on 4KBarch/x86/kernel/vmlinux.lds.S+8 -70 replies
3/8x86/boot: Set cr0 to known state in trampolinearch/x86/boot/compressed/head_64.S+2 -30 replies
4/8x86/boot: Increase boot page table sizearch/x86/include/asm/boot.h+14 -120 replies
5/8x86/boot: Support 4KB pages for identity mappingarch/x86/include/asm/init.h arch/x86/mm/ident_map.c+155 -320 replies
6/8x86/boot: Setup memory protection for bzImage codearch/x86/boot/compressed/head_64.S arch/x86/boot/compressed/ident_map_64.c arch/x86/boot/compressed/misc.c +5 more+168 -640 replies
7/8x86/boot: Map memory explicitlyarch/x86/boot/compressed/acpi.c arch/x86/boot/compressed/efi.c arch/x86/boot/compressed/kaslr.c+42 -20 replies
8/8x86/boot: Remove mapping from page fault handlerarch/x86/boot/compressed/ident_map_64.c+10 -160 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC PATCH 0/8] x86_64: Harden compressed kernel, part 1

This is the first half of changes aimed to increase security of early boot code of compressed kernel for x86_64 by enforcing memory protection on page table level.

It applies memory protection to the compressed kernel code executing outside EFI environment and makes all identity mappings explicit to reduce probability of hiding erroneous memory accesses.

Second half makes kernel more compliant PE image and enforces memory protection for EFISTUB code, thus completing W^X support for compressed kernel.

I'll send second half for review later.

Evgeniy Baskov (8):
x86/boot: Align vmlinuz sections on page size x86/build: Remove RWX sections and align on 4KB x86/boot: Set cr0 to known state in trampoline x86/boot: Increase boot page table size x86/boot: Support 4KB pages for identity mapping x86/boot: Setup memory protection for bzImage code x86/boot: Map memory explicitly
x86/boot: Remove mapping from page fault handler

 arch/x86/boot/compressed/acpi.c         |  21 ++-
 arch/x86/boot/compressed/efi.c          |  19 ++-
 arch/x86/boot/compressed/head_64.S      |   7 +-
 arch/x86/boot/compressed/ident_map_64.c | 128 ++++++++++------
 arch/x86/boot/compressed/kaslr.c        |   4 +
 arch/x86/boot/compressed/misc.c         |  52 ++++++-
 arch/x86/boot/compressed/misc.h         |  16 +-
 arch/x86/boot/compressed/pgtable.h      |  20 ---
 arch/x86/boot/compressed/pgtable_64.c   |   2 +-
 arch/x86/boot/compressed/sev.c          |   6 +-
 arch/x86/boot/compressed/vmlinux.lds.S  |   6 +
 arch/x86/include/asm/boot.h             |  26 ++--
 arch/x86/include/asm/init.h             |   1 +
 arch/x86/include/asm/shared/pgtable.h   |  29 ++++
 arch/x86/kernel/vmlinux.lds.S           |  15 +-
 arch/x86/mm/ident_map.c                 | 186 ++++++++++++++++++++----
 16 files changed, 403 insertions(+), 135 deletions(-)
 delete mode 100644 arch/x86/boot/compressed/pgtable.h
 create mode 100644 arch/x86/include/asm/shared/pgtable.h
Signature · 1 line
2.35.1