요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
===========================
KASLR for Freescale BookE32
===========================
The word KASLR stands for Kernel Address Space Layout Randomization.
This document tries to explain the implementation of the KASLR for
Freescale BookE32. KASLR is a security feature that deters exploit
attempts relying on knowledge of the location of kernel internals.
Since CONFIG_RELOCATABLE has already supported, what we need to do is
map or copy kernel to a proper place and relocate. Freescale Book-E
parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1
entries are not suitable to map the kernel directly in a randomized
region, so we chose to copy the kernel to a proper place and restart to
relocate.
Entropy is derived from the banner and timer base, which will change every
build and boot. This not so much safe so additionally the bootloader may
pass entropy via the /chosen/kaslr-seed node in device tree.
We will use the first 512M of the low memory to randomize the kernel
image. The memory will be split in 64M zones. We will use the lower 8
bit of the entropy to decide the index of the 64M zone. Then we chose a
16K aligned offset inside the 64M zone to put the kernel in::
KERNELBASE
|--> 64M <--|
| |
+---------------+ +----------------+---------------+
| |....| |kernel| | |
+---------------+ +----------------+---------------+
| |
|-----> offset <-----|
kernstart_virt_addr
To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you
want to disable it at runtime, add "nokaslr" to the kernel cmdline.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Freescale BookE32 KASLR
1-12KASLR은 Kernel Address Space Layout Randomization의 약자입니다. Kernel 내부 위치를 알고 있다는 가정에 의존하는 exploit을 어렵게 만드는 보안 기능입니다.
이 문서는 Freescale BookE32에서 KASLR을 구현한 방식을 설명합니다.
TLB1 제약과 재배치 방식
13-19`CONFIG_RELOCATABLE` 지원이 이미 있으므로 kernel image를 적절한 위치로 map 또는 copy한 뒤 relocate하면 됩니다.
Freescale Book-E는 lowmem이 fixed TLB entry인 TLB1으로 map되기를 기대합니다. TLB1은 randomized region에 kernel을 직접 map하기에 적합하지 않으므로 kernel을 선택한 위치로 copy한 뒤 restart하여 relocate합니다.
Entropy 입력
20-23기본 entropy는 build마다 달라지는 banner와 boot마다 달라지는 timer base에서 얻습니다. 이것만으로 충분히 안전하지 않으므로 bootloader가 device tree의 `/chosen/kaslr-seed` node로 추가 entropy를 전달할 수 있습니다.
512MB randomization window
24-40Kernel image는 low memory의 첫 512MB 안에서 randomize됩니다. 이 범위를 64MB zone으로 나누고 entropy의 하위 8bit로 zone index를 선택한 뒤, zone 내부의 16KB-aligned offset에 kernel을 배치합니다.
KERNELBASE
|--> 64M <--|
| |
+---------------+ +----------------+---------------+
| |....| |kernel| | |
+---------------+ +----------------+---------------+
| |
|-----> offset <-----|
kernstart_virt_addr
고정 TLB1 mapping 제약 안에서 zone과 aligned offset을 단계적으로 고릅니다.
`KERNELBASE`에서 선택한 64MB zone과 내부 offset을 더해 kernel 시작 주소를 정합니다.
활성화와 runtime 해제
41-42KASLR을 활성화하려면 `CONFIG_RANDOMIZE_BASE=y`로 build합니다. 활성화된 kernel에서 runtime에 끄려면 kernel command line에 `nokaslr`를 추가합니다.
요약과 해설
kaslr-booke32.rst:1-42BookE32 KASLR은 kernel을 random address에 직접 map하지 않고 선택한 lowmem 위치로 copy한 뒤 restart/relocate합니다. Bootloader의 `/chosen/kaslr-seed`가 entropy를 보강합니다.