Repository navigation
fix(security): harden conntrack, console and process memory boundaries - #49
Merged
Merged
Conversation
4 of 5 tasks
YUZHEthefool
marked this pull request as ready for review
October 31, 2026 04:36
Bind socket-confirmed closure to the exact conntrack incarnation and make completed flows replaceable only after any final FIN acknowledgement is accepted by the transmit queue. Preserve half-close protection, queue retry, concurrent egress rollback and namespace isolation. Cover graceful-close capacity recovery, stale tuple tokens, validated socket states and final ACK queue rejection with hosted regressions. Update the net suite count from 135 to 139.
Retry preparation when waiters arrive after the source-length snapshot, before waking or moving any waiter. Bound retries and return a resource error on persistent churn; retain the existing allocation-pressure fallback. Add a deterministic regression for publication between preparation and the locked move, and update the futex hosted suite count from 24 to 25.
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.
Problem and outcome
This change repairs six retained October 31 audit candidates: recoverable conntrack admission, ingress TCP control-state handling, namespace-init signal authority, physical console input ownership, COW heap-shrink invalidation and OOM memory accounting. It is based on
7548e73after the UID quota work merged. Gracefully closed TCP connections also recover admission capacity, and futex requeue preserves sleeping waiters that arrive during target preparation.Closes #48.
Design and scope
/dev/console, duplicated descriptors and poll use the same policy. Unauthorized reads return EPERM; read polling reports POLLERR.pwrite64, and retain a separate non-append libcpwrite()check.The rejected UID quota candidate matches the existing intended policy. The audit's other hardening observations, deferred coverage and full release qualification are outside this scoped repair.
Kernel safety and invariants
syscall_test.Validation evidence
Run locally on Fedora with pinned
nightly-2025-12-08, QEMU 11.1.2, OVMF and musl 1.2.6. Each QEMU gate used a preserved copy of its matching ESP; the musl run used one CPU.make fmt-check,make clippy,make lint(includes ABI oracle)make build; releasesyscall_testandmusl_testkernel buildsbash scripts/tools/hosted_subcrate_tests.shKERNEL_TEST_CPUS=4 KERNEL_TEST_TIMEOUT=240 bash scripts/gates/boot/ring3_mm_oracle.sh <syscall-test-esp>python3 -m unittest discover -s scripts/tests -p 'gate*test.py'760fc1d:cargo fuzz run fuzz_network_packet -- -runs=10000 -max_len=2048BOOT_CHECK_TIMEOUT=120 bash scripts/gates/boot/boot_check.sh <default-esp>KERNEL_TEST_TIMEOUT=120 bash scripts/gates/boot/kernel_test.sh <default-esp>smp_test.shwithSMP_TEST_TIMEOUT=120;smp_test_4core.shwithSMP_4CORE_TEST_TIMEOUT=120760fc1d:KERNEL_TEST_DISK=<journaled-disk-copy> KERNEL_TEST_TIMEOUT=120 bash scripts/gates/boot/kernel_test.sh <default-esp>MUSL_CHECK_TIMEOUT=300 make musl-check(writableTMPDIR, retained serial logs)cargo check --no-default-features, hosted allocator)7c841717a6475e39d6ff7dd130cbcb0720b3b4cdc83f87f1a6ee98f8c7c10582; musl fixture SHA-256e9e5b7c271ac66e80769c7c135e14c00cde77214b2ecaa31756bbe4c68ab0c71The local musl rebuild exposed two existing fixture portability assumptions: debug-heavy host archives produced a 452,984-byte image above the 256 KiB exec budget, and musl 1.2.6 intentionally changed append-mode
pwrite()semantics (upstream release announcement). The fixture now strips non-runtime sections and tests the intended Linux append ABI directly, retaining the data/offset assertions and a libcpwrite()check on a non-append descriptor. No exec limit was raised and no gate assertion was disabled. A separate QEMU launch failure from a read-only/var/tmpwas corrected by providing a writableTMPDIR.The TCP follow-up adds capacity recovery, exact-incarnation/namespace isolation, validated socket closure and final-ACK queue-retry regressions. The futex follow-up deterministically inserts a waiter after the preparation snapshot and verifies that it remains asleep on the target. The original four focused hosted regressions failed before their fixes, and a four-CPU guest detected both the console authorization failure and missing heap-shrink flush. These demonstrate the affected code paths, not a complete deployed exploit. The Ring-3 oracle accepts that fixture's intentional page faults; its generic boot harness status 1 is not its verdict. Qualified runtime outcomes retain their WARN/DEFERRED limitations. The selective-wait failure did not recur in the final repeat; its cause is not established or claimed fixed by this PR, so the repeat is not a claim of complete runtime stability. Pre-merge comparison confirmed that both
wait_reap_coreand the selective-wait fixture are byte-identical to base7548e73. The existing code publishes an any-child filter before narrowing it to the selected PID, which permits a sibling wake during that interval; this is a possible explanation, not a proven trace of the observed failure. The failure did not report reaping the wrong child.Kernel fixes:
f843a30; syscall fixture:ab858fd; musl portability:dab3b67andbe48a18; musl fixture:760fc1d; validated TCP close and bounded empty-queue polling:8c70dc4; futex preparation revalidation:2787d0c. CI for2787d0cpassed all 14 jobs, including hosted debug/release, kernel build, quality checks, boot/SMP, musl on one and four CPUs, IOMMU, mitigation and QEMU fuzzing. Final pre-merge verification of this exact head found no additional merge-blocking findings; there are no unresolved review threads.Compatibility and limits
A replaced UDP stream must satisfy NEW-flow firewall policy again. Incoming FIN validation remains the socket layer's responsibility. Conntrack protects half-closed sessions and retires a socket-confirmed terminal flow only after any required final ACK reaches the device queue. Foreground TTY delegation is not implemented, so a separate userspace shell cannot inherit physical input authority from init.
The COW regression measures the actual shootdown path and peer-page preservation; it does not reproduce physical-hardware frame-reuse disclosure. Deployment input exposure, remote source spoofing, full constrained-memory OOM campaigns and cross-user-namespace init-death cascades are not established by these tests. Raw audit records and host-specific reproduction logs remain local under SECURITY.md. No full clean-audit or hardware qualification claim is made.
Checklist