DOCUMENTATION / V1.0.0 LTS
Release notes — v0.1.18
A program that obtains something it did not carry
Since v0.1.14 a ring 3 program could speak. Since v0.1.17 it did not even have to be part of the kernel. But whatever it displayed, it had brought with it: the string was in its own image, assembled or typed alongside its code. A program that can only show what it already contains is closer to a recording than to software.
read gives it a third source. user run cat
asks for /tmp/lu.txt and gets:
[syscall] read path=/tmp/lu.txt bytes=25 vers=0x8000010f00
[user] contenu-lu-depuis-anneau3
[syscall] exit code=25
Those 25 bytes are in neither the program nor the kernel. The file was written from the shell a moment earlier. The program exits with the count it was given, so the number is produced by the read rather than by the assertion.
The part that actually needed care
This is the first syscall in which the kernel writes into user memory.
Every earlier validation asked one question: is this page present and
reachable from ring 3? That is the right question when the kernel only
reads what it is shown — a wrong address leaks, and peek
has been demonstrating the refusal since v0.1.14. It is not the right
question for a destination.
A destination is now checked by range_is_writable, which
demands the W bit in addition to U/S. To find out whether that mattered,
the check was replaced by the read-side one and poke — a
program that names its own read-only code page as the destination — was
run:
[page_fault] addr=0x8000000000 rip=0x2b0af9 error=0x3
[page_fault] cause=violation_de_protection acces=ecriture mode=noyau
page_fault_fatal=1 recovered=0
[exception] KERNEL HALTED
This contradicted the comment that had been written before the
measurement. The assumption was that the kernel, running in ring 0,
would not be stopped by the W bit, and that an unvalidated destination
would let a program have its own code rewritten. CR0.WP is
armed, so the kernel is subject to the W bit. The real
consequence is worse and more immediate: an unprivileged task halts the
entire system with a single call. The comment was corrected to state
what was observed.
One thing follows that is worth writing down rather than discovering
later: the kernel never writes CR0. It inherits that bit
from the bootloader. If it were ever cleared, this refusal would stop
being a guard against a halt and become the only thing standing between
ring 3 and having the kernel rewrite its code.
Choices, and what they cost
Four arguments. The boundary carried three. The
fourth passes in r10 rather than rcx,
following the Linux convention — syscall overwrites
rcx with the return address. We enter through
int 0x80, which does not, so nothing forced the choice
today. Adopting it now avoids rewriting every user program the day
syscall replaces the interrupt gate.
All or nothing. A file larger than the buffer is refused, not truncated. There is no cursor, so a truncated read could not be resumed: the program would receive a fragment it had no way to complete and no way to distinguish from a whole file. A refusal is less convenient and more honest.
Refusals stay at their level. -2 for a
pointer the boundary will not take, -5 for a path the
filesystem does not have, -6 for a file that does not fit.
If they all said the same thing, a failing program could not tell a bad
address from a missing file.
Confinement is not re-implemented.
fs::read_file already canonicalises and refuses what leaves
/tmp. Repeating the rule at the syscall boundary would have
produced two copies to keep in step, and the second one would eventually
be the one that is wrong.
Measurements
| What | Value |
|---|---|
scripts/test_ring3.sh |
19 → 22 assertion groups, all green |
scripts/test_regression_full.sh |
15 → 16 structural checks |
| Host tests | 250, unchanged |
| Clippy | 0 warnings |
scripts/test_regression_all.sh |
PASS |
Counter-proofs performed:
- behavioural — replacing
range_is_writablewithrange_is_readablehalts the kernel whenpokeruns, as quoted above; - structural — dropping
mapping.writablemakes check 16 oftest_regression_full.shfail.
Host tests stay at 250. This milestone adds no pure logic: what it establishes is enforced by the MMU, and a host test that did not consult real page tables would be asserting against a fiction. Saying so is better than manufacturing tests to move a number.
What this release does not do
- No file descriptors, no
open, no cursor, noseek. - No way for a program to write a file; the traffic goes one way.
- A read is bounded at 1024 bytes, a path at 128.
- Still no user heap: the buffer has to come from the program's own stack or from a writable segment of its image.