Repository navigation
Harden the serial path, boot input and the boot log against denial of service - #10
Merged
Merged
Conversation
… service - Count dropped error characters and mask the receive interrupt until the next tick after 256 of them - Refuse a redistributor stride that overflows the frame walk and treat an overflowing step as the end of the range - Refuse a DTB pointer at the end of the address range or beyond the address width of the CPU - Bound RAM by the address width of the CPU in the kernel and in the loader check - Do not hand out a memory gap without a whole page - Give the lines printed when a task ends their own share of the boot log - Add host tests for these, and model tests for self referencing capabilities and composed address space operations
- `tools/fdt-patch.py` edits a device tree blob without dtc - `K0_IMAGE_DTB_POINTER` makes the runner boot with another DTB pointer - Six rows cover a bad pointer, a bad stride, RAM beyond the address width and a range without a whole page - The terminal test sends a flood of breaks on QEMU 8 or later
- Serial error character budget, boot input refusals and the boot log share in SECURITY, INTRODUCTION, USAGE and the design notes - New test and boot matrix counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
An availability review of
main(6324648) was checked claim by claim against the code and by runs under QEMU. It found no way for an EL0 task or for serial input to stop the kernel, but it found four places where an outside party or boot input could cost more than intended. This pull request closes them.DROP_MAXincrates/k0-conin). Only the tick reopens it.map_dtb, and a pointer below 2^47 but beyond the CPU's physical address width faulted on the first read. Both are nowk0: dtb rejected: bad pointer.redistributor-stridenear 2^64 overflowed the frame walk. A stride at or above 2^52 is now refused, and the walk treats an overflowing step as the end of the range.Untypedcapability that nothing can be made from. It is no longer handed out, and the kernel printsk0: memory <base> + <size> not handed out (no whole page).tools/fdt-patch.py) so the rows need nodtc.The documents in English and Korean describe the new behaviour and its limits.
How it was tested
tools/host-test.shtools/qemu-boot-test.shDetails:
Host tests: 377 pass on an AArch64 host (289 without
k0-mmon other hosts), also from agit archiveexport of the branch. The newk0-conintests fail without the budget ("5000 error characters taken in one tick"), and the newk0-eficase fails without the loader change.Boot matrix: all 82 rows of
tools/boot-matrix.shpass locally (Apple M5 Pro, QEMU 11.1.3,K0_MATRIX_HVF=1).tools/qemu-boot-test.shruns as the judge of its pass rows.CI: the run for this pull request passed on both runners: the host tests, and all 71 rows of the boot matrix on QEMU 7.2, with the six new rows among them.
Before and after, on QEMU
virtwithcortex-a72:maink0: PANICatkernel/src/main.rs:848k0: dtb rejected: bad pointerk0: EXCEPTION sync-spxk0: dtb rejected: bad pointerk0: PANICatcrates/k0-arch/src/irq.rs:303k0: platform rejected: BadRedistributork0: EXCEPTION sync-spxk0: platform rejected: MemoryAboveLimitUntypedUntypedBoot log share: checked once with a throwaway root task that made 406 faulting tasks. On
mainthe log filled with 170 fault lines and lost every later line. On this branch it holds 46 fault lines, the note line and the later lines.Not covered:
tools/term-test.pyruns only on QEMU 8.0 or later, so it is expected to be skipped in CI (the CI log does not show the skip line). QEMU 7.2 puts a break into its PL011 receive FIFO without a depth check (pl011_eventcallspl011_put_fifodirectly inhw/char/pl011.cat v7.2.0, read in the source, not run), and breaks pile up there while the kernel keeps the interrupt masked. The step checks only that input is not cut off and recovers. The bound itself is shown by the host tests.Security notes
TaskLine::begin(crates/k0-arch/src/earlycon.rs). It reads the log length with interrupts masked and has its// SAFETY:comment. The new host tests useunsafethe way the existing ones do.k0-mmtakesk0-capas a dev-dependency for the composed test.CAP_REVOKEon a largeUntypedis still not preemptible, andk0-ipcandk0-schedstill have no host tests.AI assistance
The verification of the review, the design, the code, the tests, the tools and the documents in this pull request were made with Claude (Anthropic), and reviewed by two additional Claude agents whose confirmed findings were fixed. The scope was chosen by the maintainer. The results under "How it was tested" are from real runs on the machine named there.
Contributor License Agreement
CLA signaturescheck shows who still needs to sign.