Skip to content

Sign-out: an absent candidate behind a read-only mount is retired; a real survivor backs off - #245

Merged
GLinnik21 merged 1 commit into
mainfrom
fix/signout-candidate-absent-retires
Sep 25, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
fix/signout-candidate-absent-retires

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Observed (webOS 4.10.2, debug install of 676e5ce)

After signing out, the event log repeated this pair about once a second, with no end:

session: sign-out candidate retirement failed path=/media/internal/.com.beb.plxnative.debug-auth.json unlink_errno=30 neutralize_errno=2
session: queued clear incomplete; retaining revocation and retrying

The file does not exist. The DB8 record went to Cleared.

Root cause

session::clear() calls retire_session_candidate on every legacy candidate, whether or not it exists. The jail sees /media/internal as read-only, and Linux checks the parent mount for write access before it looks the child up, so unlink returns EROFS for a name that is not there. The neutralize fallback opens without O_CREAT and got ENOENT, which proves the name is absent. The function still returned failure. That made ClearOutcome::Durable { legacy_swept: false }, and SessionAdapter::take_erased re-ran the whole clear every STORAGE_RETRY_MS (1 s), forever. Every run rewrote and fsynced the revocation marker and logged two lines.

This had more consequences than log spam, because other work waits behind a pending erase:

  • A sign-in after that sign-out was never persisted. submit_commit returns early while erasures is non-empty. The old erase could not wipe or revoke the new sign-in, since it runs strictly before any queued commit and a completed erase is never retried. But the new credential was never written, so the next launch needed a new sign-in.
  • "Delete all local data" never ran its sweep. SessionCmd::EraseLocal (all_local = true) uses the same queue. delete_all_local_data and the LocalDataErased route back to sign-in only run from finish_erase, and the stuck clear never got there.

Telemetry's cleanup already handled this case through storage::remove_file_or_prove_absent. The session sweep had never been moved onto it.

Fix

  • Retired means no credential remains at the path. That covers removed (parent synced), neutralized, and proven absent. After a refused unlink, a no-follow lookup runs. The new storage::prove_absent_after_refused_unlink shares classify_remove_error with telemetry's helper. A neutralize open that answers ENOENT counts as the same proof. An unlink that itself answers ENOENT still syncs the parent, because that can be the retry of an earlier unlink whose sync failed. A name that exists, or that cannot be looked up, is still a failure.
  • Every caller of retire_session_candidate gets the rule: clear()'s sweep, persistence::cleanup_after_confirmed_clear, retire_marked_fallbacks_locked and retire_other_fallback_candidates_locked. It also covers the revocation-marker removal in retry_pending_revocation_removals_locked, which had the same EROFS-on-absent loop.
  • A real survivor is never given up on, but it backs off. A clear that leaves a credential keeps the erase queued and the revocation retained. Retries now come at 1 s, 2 s, 4 s … capped at 30 s (ERASE_RETRY_CAP_MS), instead of every second for the life of the process.
  • storage::unlink is now the single unlink for credential cleanup. It has a test-only errno seam scoped to one directory and applied process-wide, so the host suite can reproduce the device's EROFS, including on the storage worker.

Evidence

The same EROFS fault drives every test. These were watched RED with the retirement fix reverted, then GREEN with it back:

Test Before the fix
signout_counts_an_absent_candidate_behind_a_read_only_mount_as_retired (TV pair: unlink EROFS, neutralize ENOENT) failed: "an absent candidate is retired"
revocation_marker_absent_behind_a_read_only_mount_is_retired failed: retry_pending_revocation_removals_locked()
a_signin_after_signout_behind_a_read_only_mount_is_written (adapter) failed: "an absent candidate behind EROFS must not hold the sign-out open"
delete_all_local_data_behind_a_read_only_mount_reaches_its_sweep (adapter) failed: "the all-local erase completes"

These tests guard real failures:

  • signout_keeps_reporting_a_present_candidate_behind_a_read_only_mount: the file exists, unlink returns EROFS, neutralize is refused. The clear stays incomplete on every attempt, the credential bytes survive, the marker is retained, and the process stays revoked. A later retry retires it.
  • a_clear_that_leaves_a_credential_retries_with_capped_backoff_and_never_gives_up (adapter): observed waits are [1000, 2000, 4000, 8000, 16000, 30000, 30000] ms. The erase stays queued throughout and completes on the next due retry once the file can go.
  • erase_retry_delay_doubles_to_its_cap

Gates (committed tree ab86f4e, clean before and after)

  • make check: exit 0
    • test result: ok. 4413 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
    • test result: ok. 4469 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
    • test result: ok. 101 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • CARGO_INCREMENTAL=0 cargo +nightly check --manifest-path rust-modules/Cargo.toml --lib --no-default-features: exit 0
  • make (ARM): exit 0

Adversarial review: approve, no material findings.

Not device-verified. It needs a TV retest: sign out, then confirm the log shows neither line repeating.

🤖 Generated with Claude Code

…d a real survivor backs off

On webOS 4.10.2 every sign-out left the clear "incomplete" forever: the 0.6-era candidate
/media/internal/.<app>-auth.json does not exist, but the jail sees that mount read-only, and
Linux answers unlink with EROFS from the parent's mount before it looks the child up. The
neutralize fallback then said ENOENT, and retire_session_candidate still reported failure, so the
adapter re-ran the whole clear (marker rewrite, fsync, two log lines) every second. Because
credential commits wait behind a pending erase, a sign-in after that sign-out was never
persisted, and "Delete all local data" (same queue) never reached its sweep or its route back
to sign-in.

Retirement now means "no credential remains at the path": removed, neutralized, or proven absent.
A refused unlink is followed by a no-follow lookup (storage::prove_absent_after_refused_unlink,
the rule telemetry's remove_file_or_prove_absent already used), and a neutralize open answering
ENOENT is the same proof. The revocation-marker removal uses the same rule. A name that exists,
or cannot be looked at, stays a failure.

A clear that leaves a real credential is never abandoned — the erase stays queued and the
revocation is retained — but its retries now back off 1 s, 2 s, 4 s … capped at 30 s instead of
running every second for the life of the process.

storage::unlink is the one unlink for credential cleanup, with a test-only, directory-scoped
errno seam so the host suite can reproduce the device's EROFS on the storage worker too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T10:23:16.084980Z ab86f4e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@GLinnik21
GLinnik21 merged commit 8dcb7f7 into main Sep 25, 2026
5 checks passed
@GLinnik21
GLinnik21 deleted the fix/signout-candidate-absent-retires branch September 25, 2026 10:36
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
* v0.7.0 audit: fourth device pass verifies #245 and #246

The fourth device pass (2026-09-25, debug builds of 8dcb7f7 and 033746b, the
maintainer's own account with only the Guest profile seated) verified both fixes
for the read-only /media/internal mount: sign-out no longer retries an absent
legacy candidate forever and a sign-in after it persists (#245), and Delete all
local data no longer reports absent files as leftovers (#246).

The audit records the pass as a by-hand evidence row, closes the third pass's
"fix in flight" finding, drops the sign-out retry loop from Known issues, and
adds #245 and #246 to the landed-after section. Neither changes a persisted
format, which the diffs confirm: they change only when a file counts as removed
and how often a failed clear is retried.

The release note needed no change: neither defect shipped in a stable release,
and nothing it says about Sign out or Delete all local data became false.
Screenshots were regenerated with SHOT_CHECK=1; no figure changed beyond JPEG
re-encode noise, so none are committed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: scope the #241 docs-only claim; the ledger's sign-out finding is fixed

The host/static row's "every commit after b99e79f touches only docs" was true of
the #241 branch it was written on, not of main, where #245 and #246 later changed
shipped code; the row now says so and points at their own CI and the fourth pass.
The forward-port ledger's third-pass row still called the sign-out retry loop a
fix in flight; it now records #245 and the device verification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant