Skip to content

overlayfs: Do not SetStat() UID/GID for newly created file. #11796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025

Conversation

copybara-service[bot]
Copy link

overlayfs: Do not SetStat() UID/GID for newly created file.

Instead, use a credentials object which has the target UID/GID set as the
EffectiveKUID/EffectiveKGID. This will ensure that the file is created with the
right owners. This is consistent with what Linux does. This avoids making
unnecessary SetStatAt() calls to the VFS, which may incur additional RPCs.

This commit additionally fixes the following bugs:

  • When parent directory has the SGID bit set, newly created symlinks should
    inherit the GID from the parent directory. This was not happening earlier.
  • There was a bug in newChildOwnerStat() where it was checking an uninitialized
    stat.Mode to check if the newly created file is a directory or not. That
    would always evaluate to false, so child directories would not have the SGID
    bit set.

@copybara-service copybara-service bot added the exported Issue was exported automatically label Jun 5, 2025
Instead, use a credentials object which has the target UID/GID set as the
EffectiveKUID/EffectiveKGID. This will ensure that the file is created with the
right owners. This is consistent with what Linux does. This avoids making
unnecessary SetStatAt() calls to the VFS, which may incur additional RPCs.

This commit additionally fixes the following bugs:
- When parent directory has the SGID bit set, newly created symlinks should
  inherit the GID from the parent directory. This was not happening earlier.
- There was a bug in newChildOwnerStat() where it was checking an uninitialized
  `stat.Mode` to check if the newly created file is a directory or not. That
  would always evaluate to false, so child directories would not have the SGID
  bit set.

PiperOrigin-RevId: 768239284
@copybara-service copybara-service bot merged commit f3f2ea7 into master Jun 6, 2025
@copybara-service copybara-service bot deleted the test/cl767693990 branch June 6, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant