Repository navigation
kernel: #! scripts, random stack and mapping addresses; net: TCP SACK and loss recovery - #117
Merged
Merged
Conversation
spawn and execve refused every file that was not an ELF executable. A
file that starts with "#!" now runs the interpreter named on its first
line ("#!interpreter [argument]", at most 255 bytes): the interpreter
gets its argument, the script's canonical path and the caller's remaining
arguments. The interpreter is found like any program, may be a script
itself up to four levels (Loop beyond that), and a malformed line is
BadExecutable. /bin/axis already takes a script path, so AXIS scripts can
be started directly.
Self-tests cover the line parser, the argument order, a missing
interpreter, a script that interprets itself and a non-ELF interpreter;
a new ring-3 check runs AXIS scripts by path and by name (the expected
number of exec checks in test.ps1 goes from 13 to 14).
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
Every process had its stack right below 0x7FFF_FFFF_0000 and its first anonymous mapping at 0x1000_0000_0000, so heap and stack addresses were the same in every run. Each program image (spawn and execve) now gets a stack top up to 16 GiB lower (whole pages, 22 random bits) and a mapping base up to 1 TiB higher (64 KiB steps, 24 random bits), drawn from the kernel's random source. Mappings end below the lowest place a stack can be. Program segments stay at their link addresses: the loader takes ET_EXEC only, so code addresses are not randomised yet. probe reports its stack and first mapping address; a new ring-3 check starts it four times and expects the addresses to differ and to lie in the documented ranges (15 exec checks in test.ps1). Also correct the storage documentation: FAT32 has kept dirty FAT sectors and FSInfo in memory until the volume is quiet since #41. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
|
Caution Review failedThe pull request is closed. Pre-merge checks:
|
Contributor
Merging this PR will degrade performance by 10.54%1 warning
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
The stack buffered out-of-order segments but could only acknowledge them cumulatively, and after three duplicate ACKs it sent everything from the first loss again. - The SYN offers SACK-permitted; a SYN-ACK carries it when the peer offered it. The codec parses and writes both options (blocks behind two NOPs, at most four parsed and three sent); segments without them are encoded byte for byte as before. - Receiver: every ACK sent while out-of-order data is held names it, the range with the most recent arrival first. - Sender: blocks inside (snd_una, snd_max] are merged into a scoreboard. An ACK that reports new data counts as a duplicate ACK; fast recovery retransmits only the holes below the highest block and does not repeat a hole on a partial ACK. A retransmission timeout forgets the scoreboard and sends everything again, as RFC 2018 asks. Tests (network/net/tests/sack.rs) join two connections by a wire that loses chosen segments: the options through the codec, malformed options, the blocks a receiver reports, exactly the two lost segments sent again out of forty, a peer without SACK, and bogus blocks. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
A script could not see the arguments it was started with. $0 is the
script's path, $1..$9 its arguments, $# their number; unquoted $@
expands to one word per argument (for a in $@ { ... }) and inside
double quotes to all of them joined by spaces. The same names work in
expressions.
"#" after "$" no longer starts a comment; AXIS now uses the shell
crate's comment stripper instead of its own copy.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
Measured against the Linux TCP stack over a TAP device with a relay that drops 2 % of the data segments in each direction (4 MiB each way): - Before SACK (main), the download never finished within 200 s in three of three runs, and the upload ran at 1.8 to 3.2 MiB/s with 5 to 10 retransmission timeouts and about 290 segments sent again needlessly. - The first SACK commit made the download work (1 to 7 MiB/s) but Linux still sent a third of the data twice, and the upload stalled on the timer more often than before. Three causes, fixed here: - The out-of-order queue held 64 segments; what arrived behind a loss beyond that was dropped. It holds 256 now, a full receive window. Download: 20 to 31 MiB/s, Linux sends about 60 segments again for about 115 lost. - In a SACK recovery everything up to snd_nxt counted as in flight, the data the peer already held included, so later holes waited for the window. The scoreboard gives the real figure (RFC 6675's pipe), and the congestion window is no longer inflated by duplicate ACKs. - A loss in a small window (after a timeout, or the end of a transfer) never drew three duplicate ACKs. The first two now let one new segment out each (limited transmit, RFC 3042), and with SACK a flight of fewer than four segments with nothing left to send is repaired after one fewer duplicate ACK than segments (early retransmit, RFC 5827). Upload: 3.9 to 13 MiB/s with 0 to 3 timeouts in four runs. A data segment sent while out-of-order data is held carries the SACK option; its payload is now shortened by the option so the segment still fits the MSS. Without loss the same path runs at 63 MiB/s up and 54 MiB/s down. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
Parsing a segment decoded the SACK option into a 36-byte block list in every Segment, whether or not it carried one; CodSpeed reported tcp_parse_segment_1460 12 % slower. The parser now only checks the option's length and keeps a slice of it; the connection decodes the blocks when it records them. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
v3nn7
marked this pull request as ready for review
November 12, 2026 09:00
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 does this change?
Four changes in separate commits. The script commit was pushed to #116 a moment after that pull request was merged, so it is not in
mainyet; the description of #116 mentions it by mistake.#!scriptsspawnandexecverefused every file that was not an ELF executable. A file that starts with#!now runs the interpreter named on its first line (#!interpreter [argument], at most 255 bytes).argv= interpreter, its argument, the script's canonical path, then the caller's arguments afterargv[0]. The process keeps the script's name./binand/usr/bin) and may be a script itself, four levels deep; a longer chain fails withLoop, a malformed line withBadExecutable.AXIS script arguments
$0is the script's path,$1..$9its arguments,$#their number. Unquoted$@expands to one word per argument (for a in $@ { ... }); inside double quotes it is all of them joined by spaces.#after$no longer starts a comment; AXIS uses the shell crate's comment stripper instead of its own copy.Random stack and mapping addresses
Every process had its stack right below
0x7FFF_FFFF_0000and its first anonymous mapping at0x1000_0000_0000. Each program image (spawnandexecve) now gets:Both come from the kernel's random source. Mappings end below the lowest place a stack can be. Program segments stay at their link addresses, because the loader takes
ET_EXEConly.TCP: selective acknowledgements and loss recovery
The stack buffered out-of-order segments but acknowledged them only cumulatively, and after three duplicate ACKs it sent everything from the first loss again.
Documentation
docs/kernel.md,docs/memory.mdanddocs/syscall-abi.mddescribe the loader changes.docs/storage.mdanddocs/roadmap.mdsaid FAT32 writes its metadata through on every change; it has delayed FAT sectors and FSInfo since #41.How was it tested?
QEMU 8.2.2 (TCG) with OVMF on Linux, test image built from the same steps as
build.ps1 -NoZen -Cmdline 'test.exit boot.fast init.args=tests',-cpu qemu64,...,+smep,+smap:#!line parser, the argument order, a missing interpreter, a script that interprets itself, a non-ELF interpreter.exec: #! scripts run their interpreter: AXIS scripts started by path and by interpreter name write a file that is read back; a script with arguments writes$1+$2+$#and one line per$@word.exec: stack and mapping addresses differ between processes: four runs ofprobe, for example stacks7ffc9b83f000,7ffe87652000,7ffedd6db000,7ffc6eec6000and mappings10ed7f8e1000,10003b1e1000,109772ea1000,107726621000.init.args=desktop, 2 CPUs) for 60 s: PRISM composes frames, no fault in the serial log.cargo test --locked -p osyx-shell: 14 passed (one new).scripts/test.ps1: the expected number of exec checks goes from 13 to 15.TCP:
cargo test --locked -p osyx-net: 69 passed. The eight new tests innetwork/net/tests/sack.rsjoin two connections by a wire that loses chosen segments: the options through the codec, malformed options, the blocks a receiver reports, exactly the two lost segments of forty sent again without a timeout, a peer without SACK, bogus blocks, the size of a data segment with blocks, and a loss in a three-segment flight repaired without a timeout.init.args=tests,netbench,<tcp>,<udp>,4,tcpwithscripts/net-bench-host.py, 4 MiB each way.tcpdumpshowssackOKon both SYNs and SACK blocks from both sides.main(3 runs)scripts/net-host.pythe same checks pass.Limitations or screenshots
maintoo:ipc: ordinary users cannot register services, take the display or read input.mainwithout loss was not measured on this path.scripts/test.ps1,scripts/net-test.ps1,scripts/net-bench.ps1andscripts/net-stress.ps1themselves (PowerShell, Windows host), the Win32 and Zen suites (winrununder the new address layout is untested), real hardware.ET_DYN) programs.AT_EXECFNis the interpreter's path.Labels
Labels: security, kernel, network
🤖 Generated with Claude Code
https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK