vkback selfread: a test that freed memory a parallel test could take #45

Manually merged
github merged 1 commit from github-bot/gh-45 into gh-pr/45/base 2026-12-01 08:16:18 +00:00 AGit
Owner

@⁠Mhyster on GitHub · 2026-12-01 03:59 UTC · original
Mhyster:fix-selfread-race → main · +6 −3 · 1 files · 1 commits · merged 2026-12-01 08:12 UTC

What

selfread::tests::a_peek_that_ends_in_unmapped_memory_leaves_the_pipe_empty unmapped the second half of its mapping to make it unreadable. The test harness runs tests in parallel, and another test's mmap can land in the freed range, so the peek then succeeds and the test fails: 3 of 20 runs on main. The test now makes that half PROT_NONE (still unreadable, still reserved) and unmaps the whole mapping at the end.

Verification (rule 27)

cargo test -p vkback --lib 30 times: 0 failures (main: 3 of 20). Test-only change, so no validation run (rule 30).

🤖 Generated with Claude Code

**@⁠Mhyster** on GitHub · 2026-12-01 03:59 UTC · [original](https://github.com/vktory6/VKtory/pull/45) `Mhyster:fix-selfread-race` → `main` · +6 −3 · 1 files · 1 commits · merged 2026-12-01 08:12 UTC ## What `selfread::tests::a_peek_that_ends_in_unmapped_memory_leaves_the_pipe_empty` unmapped the second half of its mapping to make it unreadable. The test harness runs tests in parallel, and another test's `mmap` can land in the freed range, so the peek then succeeds and the test fails: 3 of 20 runs on main. The test now makes that half `PROT_NONE` (still unreadable, still reserved) and unmaps the whole mapping at the end. ## Verification (rule 27) `cargo test -p vkback --lib` 30 times: 0 failures (main: 3 of 20). Test-only change, so no validation run (rule 30). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
a_peek_that_ends_in_unmapped_memory_leaves_the_pipe_empty unmapped the second
half of its mapping, then expected reads there to fail. Tests run on parallel
threads: another test's mmap could land in the freed range first, the read
succeeded and the test failed (3 of 20 runs of upstream main, 1 of 5 here).
The half is now PROT_NONE: still unreadable to the kernel's copy (EFAULT as
for an unmapped page; peek's write(2) from our memory), but reserved, so
nothing else can map there. 0 failures in 30 runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 04:00:22 +00:00
github-bot changed target branch from main to gh-pr/45/base 2026-12-01 08:16:17 +00:00
github manually merged commit 9094d4546c into gh-pr/45/base 2026-12-01 08:16:18 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 08:12 UTC · original

Merged, thanks! PROT_NONE keeps the range reserved, so another test can no longer take it. Tests pass on the reference system.

**@⁠vktory6** on GitHub · 2026-12-01 08:12 UTC · [original](https://github.com/vktory6/VKtory/pull/45#issuecomment-7305005157) Merged, thanks! `PROT_NONE` keeps the range reserved, so another test can no longer take it. Tests pass on the reference system.
This discussion has been locked. Commenting is limited to contributors.
No description provided.