Repository navigation
Conversation
Quick-tier test coverage
make coverage CTEST_ARGS="--output-on-failure"Coverage of this pull request's changes
Changed lines the quick-tier tests never executed: Executed by the quick-tier tests ( |
akamit91
force-pushed
the
vfs-claim-callback-lifetime
branch
from
November 13, 2026 13:16
8cd8590 to
3ff11c2
Compare
…d park A claim selected under file->lock is only safe to dereference again once the lock is dropped if something keeps its owner alive. Grant-bearing claims already have that in their refcounted grant; owner-managed claims (NFSv4 delegations and OPEN/LOCK state, FUSE coherence grants) did not, leaving a window between selection and dispatch where the owning object could be torn down and freed out from under the claim core. Introduce an owner-ops registration -- chimera_vfs_claim_owner_register() mapping (construct, proto) to try_get/put callbacks -- and route every break, revoke, and park path through chimera_vfs_claim_ref_take()/ chimera_vfs_claim_ref_drop() before touching a selected claim across an unlock: - chimera_vfs_claim_try_acquire()'s BREAKING loop re-admits and pins the conflict at the top of every iteration instead of carrying a stale pointer across the unlocked dispatch window (selection-to-pin race). - The courtesy-reclaim DENIED path pins the reclaimed holder before invoking its revoked_cb off-lock, since callbacks such as nfs_client_lease_revoked_cb dereference the owning nfs_client. - chimera_vfs_claim_drive_breaks() and chimera_vfs_claim_revoke_breaks() pin selected/collected victims before unlocking. - chimera_vfs_claim_revoke_ex() re-validates that a pinned claim is still a member of the expected file before mutating it, matching the membership check already done in begin_break_ex(); a mismatch means a concurrent teardown already finished with the claim. A refused pin means a concurrent teardown already won the race for that holder (e.g. DELEGRETURN/CLOSE, or the NFSv4 lease sweeper freeing a lock-owner's leases outright in lock_state_cleanup); callers back off onto the holder's own teardown path pumping the file, rather than dereferencing a claim that may already be gone. Owner-side reference counting is switched to nonzero-only CAS loops (nfs_delegation_try_get, chimera_fuse_grant_claim_try_get, nfs_client_claim_try_get) so a racing pin either wins against a still- live refcount or observes zero and backs off, never resurrecting an object mid-free. NFSv4 OPEN and LOCK claim callbacks now pin the owning nfs_client the same way delegations do. Unregistered (construct, proto) pairs default to caller-managed and are always pinnable, preserving the pre-existing lifetime assumption for every claim kind that predates this mechanism.
Carry SMB waiter wakeups through the final dispatch pin while preserving explicit shutdown suppression. Park expired-break waiters on refused owner pins and continue namespace recalls past tearing-down holders. Drain FUSE grants, dispatch pins, and notifier work before freeing mount state. Validate explicit CLONE ranges in the backend and use authoritative source size for clone-to-EOF, with a corrected specs revision and focused regression coverage.
Exclude the POSIX pwrite growth block from Windows builds while retaining memfs CLONE boundary and delegation checks. Register the Linux backend probe only when building on Linux.
akamit91
force-pushed
the
vfs-claim-callback-lifetime
branch
from
December 5, 2026 20:05
bbda053 to
889a5a4
Compare
This branch has not been deployed
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
The VFS claim core selects conflicting claims under
file->lock, but break, revoke, and callback processing may continue after the lock is released.For claims embedded in protocol-owned objects, such as NFSv4 delegations, OPEN/LOCK state, and FUSE coherence grants, the owning protocol can concurrently unlink and free the object. This creates a use-after-free window between claim selection and callback dispatch.
SMB cache grants already have reference-counted lifetime protection, but that protection does not extend to all claim types.
Solution
Introduce a lightweight owner-pinning mechanism that keeps selected claims and their required owner context alive across unlocked operations.
The changes:
chimera_vfs_claim_owner_register()to register protocol-specifictry_get/putoperations by claim construct and owner protocol.file->lock, before allowing a selected claim to be used outside the critical section.file->lockto avoid lock recursion and teardown deadlocks.Design considerations
The implementation intentionally reuses protocol-owned lifetime mechanisms and keeps the VFS claim core independent of protocol-specific object layouts.
It does not introduce a new claim ownership model, change backend claim arbitration, or redesign callback routing.
The additional reference operations are primarily limited to conflicting claim and callback paths rather than ordinary uncontended I/O.
Testing
vfs_claim_testwith owner-pin acquisition/release coverage.Scope
This change addresses memory safety during claim selection and unlocked dispatch.