-
Notifications
You must be signed in to change notification settings - Fork 377
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
Race condition in rpmioMkpath ("Unable to open temp file: File exists") #3508
Labels
Comments
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 8, 2025
Callers use the errno for error reporting. Currently it is set to ENOTDIR by accident bubbling up from rpmMkTempFile and rpmioMkpath. As we need to change rpmioMkpath set errno explicitly. Related: rpm-software-management#3508
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 8, 2025
The previous implementation did stat the directory and created it if not there. This allowed for a race condition where other rpm instances could create the directory inbetween. This was observed in the wild for %{_tmppath}. Do create the directory unconditionally and if that fails see if the directory is there already. Not adding a test case as rpmioMkpath is heavily used all over the the code base and tests for race conditions don't really fit in the test suite. Resolves: rpm-software-management#3508
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 8, 2025
Callers use the errno for error reporting. Currently it is set to ENOTDIR by accident bubbling up from rpmMkTempFile and rpmioMkpath. As we need to change rpmioMkpath set errno explicitly. Related: rpm-software-management#3508
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 8, 2025
The previous implementation did stat the directory and created it if not there. This allowed for a race condition where other rpm instances could create the directory inbetween. This was observed in the wild for %{_tmppath}. Do create the directory unconditionally and if that fails see if the directory is there already. Not adding a test case as rpmioMkpath is heavily used all over the the code base and tests for race conditions don't really fit in the test suite. Resolves: rpm-software-management#3508
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 10, 2025
Callers use the errno for error reporting. Currently it is set to ENOENT by accident bubbling up from rpmMkTempFile and rpmioMkpath. As we need to change rpmioMkpath set errno explicitly to keep the errno the same for the callers of urlOpen. Related: rpm-software-management#3508
ffesti
added a commit
to ffesti/rpm
that referenced
this issue
Jan 10, 2025
The previous implementation did stat the directory and created it if not there. This allowed for a race condition where other rpm instances could create the directory inbetween. This was observed in the wild for %{_tmppath}. Do create the directory unconditionally and if that fails see if the directory is there already. Not adding a test case as rpmioMkpath is heavily used all over the the code base and tests for race conditions don't really fit in the test suite. Resolves: rpm-software-management#3508
ffesti
added a commit
that referenced
this issue
Jan 10, 2025
Callers use the errno for error reporting. Currently it is set to ENOENT by accident bubbling up from rpmMkTempFile and rpmioMkpath. As we need to change rpmioMkpath set errno explicitly to keep the errno the same for the callers of urlOpen. Related: #3508
ffesti
added a commit
that referenced
this issue
Jan 10, 2025
The previous implementation did stat the directory and created it if not there. This allowed for a race condition where other rpm instances could create the directory inbetween. This was observed in the wild for %{_tmppath}. Do create the directory unconditionally and if that fails see if the directory is there already. Not adding a test case as rpmioMkpath is heavily used all over the the code base and tests for race conditions don't really fit in the test suite. Resolves: #3508
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When running multiple
rpmbuild
in parallel with a non existing%{_tmppath}
,if you are lucky enough you will get an error
Unable to open temp file: File exists
To Reproduce
Race condition are always a pain to reproduce
-> Code review
Expected behavior
multiple rpmioMkpath in // do not fail
Output
Environment
EL9.5
rpm-4.16.1.3-34.el9.x86_64
Additional context
rpm/build/build.cc
Lines 200 to 202 in cae8ef5
rpm/rpmio/rpmfileutil.cc
Lines 75 to 108 in cae8ef5
I don't get
error creating temporary file
error, onlyUnable to open temp file: File exists
error, so the error is fromrpmioMkpath
when trying to create%{_tmppath}
rpm/rpmio/rpmfileutil.cc
Lines 125 to 131 in cae8ef5
If another process create the folder between
stat
andmkdir
we get the errorThe text was updated successfully, but these errors were encountered: