← Documents Documentation/arch/powerpc/kaslr-booke32.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

KASLR for Freescale BookE32

Fixed TLB1 mapping 아래에서 512MB window, 64MB zone과 16KB offset으로 kernel을 재배치하는 절차입니다.

Source pathDocumentation/arch/powerpc/kaslr-booke32.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

kaslr-booke32.rst:1-42

BookE32 KASLR은 kernel을 random address에 직접 map하지 않고 선택한 lowmem 위치로 copy한 뒤 restart/relocate합니다. Bootloader의 `/chosen/kaslr-seed`가 entropy를 보강합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===========================
4 KASLR for Freescale BookE32
5 ===========================
6
7 The word KASLR stands for Kernel Address Space Layout Randomization.
8
9 This document tries to explain the implementation of the KASLR for
10 Freescale BookE32. KASLR is a security feature that deters exploit
11 attempts relying on knowledge of the location of kernel internals.
12
13 Since CONFIG_RELOCATABLE has already supported, what we need to do is
14 map or copy kernel to a proper place and relocate. Freescale Book-E
15 parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1
16 entries are not suitable to map the kernel directly in a randomized
17 region, so we chose to copy the kernel to a proper place and restart to
18 relocate.
19
20 Entropy is derived from the banner and timer base, which will change every
21 build and boot. This not so much safe so additionally the bootloader may
22 pass entropy via the /chosen/kaslr-seed node in device tree.
23
24 We will use the first 512M of the low memory to randomize the kernel
25 image. The memory will be split in 64M zones. We will use the lower 8
26 bit of the entropy to decide the index of the 64M zone. Then we chose a
27 16K aligned offset inside the 64M zone to put the kernel in::
28
29 KERNELBASE
30
31 |--> 64M <--|
32 | |
33 +---------------+ +----------------+---------------+
34 | |....| |kernel| | |
35 +---------------+ +----------------+---------------+
36 | |
37 |-----> offset <-----|
38
39 kernstart_virt_addr
40
41 To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you
42 want to disable it at runtime, add "nokaslr" to the kernel cmdline.
43

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Freescale BookE32 KASLR

1-12

KASLR은 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-40

Kernel image는 low memory의 첫 512MB 안에서 randomize됩니다. 이 범위를 64MB zone으로 나누고 entropy의 하위 8bit로 zone index를 선택한 뒤, zone 내부의 16KB-aligned offset에 kernel을 배치합니다.

KERNELBASE

    |-->   64M   <--|
    |               |
    +---------------+    +----------------+---------------+
    |               |....|    |kernel|    |               |
    +---------------+    +----------------+---------------+
    |                         |
    |----->   offset    <-----|

                          kernstart_virt_addr
BookE32 KASLR 위치 선택
Low memory 첫 512MB64MB zone 분할Entropy 하위 8bit로 zone 선택16KB-aligned offset 선택Kernel copy`kernstart_virt_addr`로 restart/relocate

고정 TLB1 mapping 제약 안에서 zone과 aligned offset을 단계적으로 고릅니다.

Randomized kernel memory layout
구성 요소크기/정렬역할
Randomization window512MBLow memory 첫 구간
Zone64MBEntropy로 선택
Offset16KB aligned선택 zone 내부 위치
Kernel imageBuild별 크기`kernstart_virt_addr`에 배치

`KERNELBASE`에서 선택한 64MB zone과 내부 offset을 더해 kernel 시작 주소를 정합니다.

활성화와 runtime 해제

41-42

KASLR을 활성화하려면 `CONFIG_RANDOMIZE_BASE=y`로 build합니다. 활성화된 kernel에서 runtime에 끄려면 kernel command line에 `nokaslr`를 추가합니다.