Skip to content

Fix race condition in CFPreferences #4903

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
Mar 12, 2024
Merged

Conversation

hristost
Copy link
Contributor

@hristost hristost commented Mar 4, 2024

In __CFWriteBytesToFileWithAtomicity(), we first write the contents of the plist to an auxiliary copy file, and then move that copy to where the original used to be. Because that file needs to have the same owner as the original, we would use chown() to change ownership as the last step. This allows a race condition where the new file is in its final location, but doesn't have the correct permissions. To fix this, call chown() on the file before moving.

rdar://121597642

In __CFWriteBytesToFileWithAtomicity(), we first write the contents of the plist
to an auxiliary copy file, and then move that copy to where the original used to
be. Because that file needs to have the same owner as the original, we would use
chown() to change ownership as the last step. This allows a race condition where
the new file is in its final location, but doesn't have the correct permissions.
To fix this, call chown() on the file before moving.

rdar://121597642
@hristost
Copy link
Contributor Author

hristost commented Mar 4, 2024

@swift-ci please test

@parkera parkera merged commit 41b71f9 into main Mar 12, 2024
@parkera parkera deleted the hs/fix-cfpreferences-race branch March 12, 2024 23:18
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