요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
KASAN is supported on powerpc on 32-bit and Radix 64-bit only.
32 bit support
==============
KASAN is supported on both hash and nohash MMUs on 32-bit.
The shadow area sits at the top of the kernel virtual memory space above the
fixmap area and occupies one eighth of the total kernel virtual memory space.
Instrumentation of the vmalloc area is optional, unless built with modules,
in which case it is required.
64 bit support
==============
Currently, only the radix MMU is supported. There have been versions for hash
and Book3E processors floating around on the mailing list, but nothing has been
merged.
KASAN support on Book3S is a bit tricky to get right:
- It would be good to support inline instrumentation so as to be able to catch
stack issues that cannot be caught with outline mode.
- Inline instrumentation requires a fixed offset.
- Book3S runs code with translations off ("real mode") during boot, including a
lot of generic device-tree parsing code which is used to determine MMU
features.
- Some code - most notably a lot of KVM code - also runs with translations off
after boot.
- Therefore any offset has to point to memory that is valid with
translations on or off.
One approach is just to give up on inline instrumentation. This way boot-time
checks can be delayed until after the MMU is set is up, and we can just not
instrument any code that runs with translations off after booting. This is the
current approach.
To avoid this limitation, the KASAN shadow would have to be placed inside the
linear mapping, using the same high-bits trick we use for the rest of the linear
mapping. This is tricky:
- We'd like to place it near the start of physical memory. In theory we can do
this at run-time based on how much physical memory we have, but this requires
being able to arbitrarily relocate the kernel, which is basically the tricky
part of KASLR. Not being game to implement both tricky things at once, this
is hopefully something we can revisit once we get KASLR for Book3S.
- Alternatively, we can place the shadow at the _end_ of memory, but this
requires knowing how much contiguous physical memory a system has _at compile
time_. This is a big hammer, and has some unfortunate consequences: inablity
to handle discontiguous physical memory, total failure to boot on machines
with less memory than specified, and that machines with more memory than
specified can't use it. This was deemed unacceptable.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
PowerPC KASAN 지원 범위
1-2PowerPC의 KASAN은 32-bit와 Radix MMU를 사용하는 64-bit 구성에서만 지원됩니다.
32-bit 지원
3-1332-bit에서는 hash MMU와 nohash MMU를 모두 지원합니다. Shadow area는 fixmap 위, kernel virtual memory space의 맨 위에 놓이며 전체 kernel virtual memory space의 1/8을 차지합니다.
`vmalloc` area instrumentation은 선택 사항이지만 module을 함께 build하면 반드시 필요합니다.
64-bit 지원과 real mode 제약
14-42현재 64-bit에서는 radix MMU만 지원합니다. Hash와 Book3E processor용 구현이 mailing list에 있었지만 merge되지는 않았습니다.
Book3S에서 KASAN을 올바르게 지원하기 어려운 이유는 다음과 같습니다.
- Outline mode가 잡지 못하는 stack 문제를 탐지하려면 inline instrumentation이 바람직합니다.
- Inline instrumentation에는 fixed offset인 고정 shadow offset이 필요합니다.
- Book3S는 boot 중 MMU feature를 알아내는 generic device-tree parsing code를 포함해 translation이 꺼진 real mode에서 많은 코드를 실행합니다.
- Boot 뒤에도 많은 KVM code가 translation이 꺼진 상태에서 실행됩니다.
- 따라서 shadow offset이 가리키는 memory는 translation on/off 양쪽에서 모두 유효해야 합니다.
현재 방식은 inline instrumentation을 포기하는 것입니다. Boot-time check를 MMU setup 뒤로 미루고, boot 이후 translation off로 실행되는 code는 instrument하지 않습니다.
Linear mapping 안의 shadow 배치 대안
43-58제약을 없애려면 KASAN shadow를 linear mapping 내부에 두고 나머지 linear mapping과 같은 high-bit 기법을 사용해야 하지만 배치가 어렵습니다.
- Physical memory 시작 부근에 두려면 runtime memory size에 따라 배치할 수 있어야 합니다. 그러나 이는 kernel을 임의 위치로 relocate하는 기능, 즉 KASLR의 어려운 부분을 요구합니다. Book3S KASLR이 마련된 뒤 다시 검토할 수 있습니다.
- Memory 끝에 두는 대안은 compile time에 contiguous physical memory 크기를 알아야 합니다. discontiguous physical memory를 처리하지 못하고, 지정량보다 적은 memory에서는 boot가 완전히 실패하며, 더 많은 memory가 있어도 초과분을 쓸 수 없어 허용할 수 없는 방식으로 판단되었습니다.
요약과 해설
kasan.txt:1-58Book3S의 translation-off 실행 경로 때문에 inline KASAN shadow offset을 양쪽 address mode에서 유효하게 만들기 어렵습니다. 현재 64-bit 구현은 radix와 outline 방식에 한정됩니다.