Repository navigation
fix(core): refuse a nonregular session record without blocking - #432
Merged
Merged
Conversation
getSession read the record with a blocking readFile, so a FIFO at the record path stalled the agent permit gate and the owned display check past their deadlines. Refuse a record that is not a regular file and open it with O_NONBLOCK. Closes #410
getSession opens the record once with O_NONBLOCK and checks that descriptor before reading, so a FIFO swapped in after a path check is refused.
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.
getSessionread the session record with a plainreadFile. A FIFO at the record path blocked that read with no limit, so the owned display check (#219) and the permit gate before it could hang past the 3 s input budget. The sessions directory is private to the user, so only a process of the same user could plant one.getSessionnow opens the record once withO_RDONLY | O_NONBLOCK, checks the opened descriptor, and refuses anything that is not a regular file withSession record at <path> is not a regular file, before any read. It reads through the same descriptor, so a FIFO swapped in after any earlier check of the path is refused too. A missing record and invalid JSON give the same results as before. The fix sits ingetSessionand not only in the ownership check, becausewithAgentPermitreads the record before the ownership check runs. Every caller now gets an error instead of a hang for a FIFO record, andlistSessionsalready skips records that throw.Closes #410
getSession, the typing check,verifyOwnedDisplayTarget,typeText,clickandpressKey; a record swapped for a FIFO holding valid JSON after a path check410/before.log,410/before-swap.log,410/after.logdesktop typeanddesktop click410/qa/410/full/QA ran with a temporary
PICKFORGE_HOMEand a CLI-created session on its own Xvfb; the record was swapped for a FIFO and restored before teardown.Sol review, 2 rounds: round 1 4/10 (blocker: the path was checked with
statand read again, so a FIFO swapped in between was read; should: no deadline around the read under libuv threadpool starvation). Round 2 9/10: the single-descriptor read resolves the blocker, with a swap test that fails on the first version; the should is settled, becausevalidateOwnedTargetrefuses a read that returns after the 3 s budget, and Sol found no late input path.Checks on 153b2a4 (before the merge of main, which only brought the test fixes from #430): oxlint, typecheck, build; full vitest coverage run with the desktop, window, wait, browser and viewer requirements on (191 files, 3425 passed, 4 skipped);
PICKFORGE_REQUIRE_XVFB=1 cargo test --workspace --locked(328 passed). PickCheck 0.4.0 against main is clean.