diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-09-04 18:14:16 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-09-04 18:19:51 +0200 |
| commit | aee4582fb5144e1dd493041a8d1fc0c08146a622 (patch) | |
| tree | 645aa86673379885a1bf712c21c15024a2eed09a /arch | |
| parent | 041ae23d5d952f134533443b508b1287af2357d3 (diff) | |
| download | kernel-aee4582fb5144e1dd493041a8d1fc0c08146a622.tar.xz kernel-aee4582fb5144e1dd493041a8d1fc0c08146a622.zip | |
x86_64/cpu: isolate kernel and IST1 stack
Previously, the kernel stack was allocated inside the .kernel_bss
section, along other uninitialized data. While this works, it assumes
that the section will always be laid out with the kernel stack at the
top. If that is not the case, the allocated guard page before
.kernel_bss would not trigger a #PF since out-of-bounds (overflow)
access would quietly overwrite other data in the section, thus
potentially corrupting global kernel data.
At the same time, there was no separate section (and guard page) for the
future #DF exception stack (IST1 in our case). Thus we allocate a
section, and a guard page, while we are already modifying the linker script.
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index e6ae3425..8cd6c1c3 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -98,9 +98,21 @@ SECTIONS . += 4K; + .kernel_stack ALIGN(4K) : AT (ADDR (.kernel_stack) - TEACHOS_VMA) + { + *(.stack) + } :kernel_data + + . += 4K; + + .kernel_ist1_stack ALIGN(4K) : AT (ADDR (.kernel_ist1_stack) - TEACHOS_VMA) + { + *(.ist1_stack) + } :kernel_data + .kernel_bss ALIGN(4K) : AT (ADDR (.kernel_bss) - TEACHOS_VMA) { - *(.stack .bss*) + *(.bss*) } :kernel_data .kernel_text ALIGN(4K) : AT(ADDR (.kernel_text) - TEACHOS_VMA) |
