Skip to content

🐛 fix(soft-rw): verify holder before refresh - #982

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/soft-rw-inode-reuse
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/soft-rw-inode-reuse

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

OsFiles.overwrite() trusted a device and inode pair after the holder-record descriptor had closed. On a filesystem that reuses the inode, another file could pass that check and receive the holder's heartbeat bytes. The refresh now verifies the record's token on the descriptor it will write, and reports the hold lost when the bytes differ. This addresses draft advisory ANT-2026-CC0VMGLC.

The inode could name a new file

The old identity and link-count check did not distinguish a later file that inherited a removed record's inode number. The new check reads the stable token prefix, accepting short reads until it has the full prefix, and writes only if it matches. Reading and writing through one descriptor keeps a name change between those operations from redirecting the write.

sequenceDiagram
    participant H as Holder
    participant F as Filesystem
    H->>F: Create record and close descriptor
    F-->>H: Device and inode identity
    Note over F: Record removed, later file reuses inode
    rect rgb(255, 214, 214)
    H->>+F: Old refresh checks identity and link count
    F-->>-H: Later file receives record bytes
    end
    rect rgb(216, 243, 220)
    H->>+F: New refresh also checks token prefix
    F-->>-H: Different bytes, no write
    end
Loading

Behavior changes

SoftReadWriteLock and AsyncSoftReadWriteLock report an evicted hold when the record path has the expected inode but lacks that participant's token. A holder record with its original prefix continues to refresh, including when its filesystem returns a short read. The check does not make a lock tree safe when another account can replace its directory; the directory boundary still applies.

Reported by OSS Scanner: ANT-2026-CC0VMGLC.

@gaborbernat gaborbernat added bug security Fixes a published or draft security advisory labels Nov 20, 2026
@gaborbernat
gaborbernat merged commit 184931a into tox-dev:main Nov 20, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a published or draft security advisory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant