Skip to content

verify inode in break_lock_file before unlinking a stale lock#561

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:break-file-inode-check
Jun 11, 2026
Merged

verify inode in break_lock_file before unlinking a stale lock#561
gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:break-file-inode-check

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

break_lock_file renames a lock it judged stale aside and then re-checks only the modification time before unlinking it, but on a filesystem with coarse mtime granularity like nfs or fat a peer can break and recreate the lock within the same second, so the live recreation carries the same mtime the waiter saw and gets unlinked, letting a second process acquire it. the sibling marker break in _soft_rw already re-verifies the marker token for exactly this reason, so this captures the inode at the stale decision and aborts the break when the renamed file's inode no longer matches. i added a regression test that recreates the lock with a fresh inode under an identical mtime, which unlinks the live file before this change and leaves it untouched after.

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaborbernat gaborbernat merged commit 406d0a2 into tox-dev:main Jun 11, 2026
33 checks passed
@dxbjavid

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge! Appreciated

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.

2 participants