Skip to content

Conversation

@hbirth
Copy link
Collaborator

@hbirth hbirth commented Jan 14, 2026

No description provided.

There is a race condition where fuse_reverse_inval_inode() can be called
while fuse_iget() is still initializing an inode. This can lead to the
inode's attributes being invalidated before they are properly set up,
causing inconsistent state.

The race occurs when:
1. Thread A calls fuse_iget() and starts initializing an inode
2. Thread B calls fuse_reverse_inval_inode() for the same inode
3. Thread B updates attr_version, invalidating the inode
4. Thread A completes initialization with stale attributes

This patch fixes the race by introducing a delayed invalidation mechanism:

- Use attr_version == 1 as a sentinel value to indicate that an
  invalidation occurred during fuse_iget() initialization

- In fuse_change_attributes_common(), skip updating attr_version if
  it equals 1, allowing fuse_iget() to detect the pending invalidation

- In fuse_reverse_inval_inode_common(), if attr_version <= 1, set it
  to 1 and return early, deferring the invalidation

- In fuse_iget(), after calling fuse_change_attributes(), check if
  attr_version == 1 and perform the delayed invalidation

The function fuse_reverse_inval_inode() is refactored to extract the
common invalidation logic into fuse_reverse_inval_inode_common()

Since fc->attr_version is initialized to 1, normal inode attr_version
values will be 0 (for new inodes before first update) or >= 2, making
the value 1 safe to use as a sentinel.

Signed-off-by: Guang Yuan Wu <gwu@ddn.com>
Applied-by: Horst Birthelmer <hbirthelmer@ddn.com>
Copy link
Collaborator

@bsbernd bsbernd left a comment

Choose a reason for hiding this comment

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

Sorry no, we cannot fix an issue between clients and cause another issue on the local client.

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