Repository navigation
Use close-on-exec for extracted files - #7643
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: 518424ce-5e6d-4b17-893b-31452457209c
Co-authored-by: Copilot <[email protected]> Copilot-Session: 518424ce-5e6d-4b17-893b-31452457209c
Co-authored-by: Copilot <[email protected]> Copilot-Session: 023830e7-e6fb-49cf-a154-7e41f833fb08
Co-authored-by: Copilot <[email protected]> Copilot-Session: 023830e7-e6fb-49cf-a154-7e41f833fb08
|
Can we get some details in the PR description about the exact fix. I'd also love to see the details about the issue to be in the NuGet repo. |
|
@nkolev92 The fix is simple -- just use file.create instead of P/Invoke. All the other added code is tests. What else would you like to know? |
|
I appreciate the update in the description that part is helpful. I think generally just more details about the intent and a more self-contained description, since the linked issue is talking about something completely different until the analysis further down. That'd make it easier to review. |
Co-authored-by: Copilot <[email protected]> Copilot-Session: 023830e7-e6fb-49cf-a154-7e41f833fb08
Co-authored-by: Copilot <[email protected]> Copilot-Session: 023830e7-e6fb-49cf-a154-7e41f833fb08
|
@zivkan I think we need a backport of this fix to 10.0.1xx. This is killing many .NET 10 builds. |
Fixes dotnet/dotnet#8079
This changes nuget to use the managed File.Create API instead of P/Invoke on Unix systems.
The fundamental problem here is that NuGet opens potentially executable files on Unix without passing the O_CLOEXEC flag. This creates a problem when a new process is created, either in another thread or the same thread, while the file descriptor is opened. The new process will inherit the FD through fork/exec. That means that attempting to execute the target file will fail because there is an open FD to the executable file and executing files with open handles is prohibited by the Linux kernel (ETXTBSY).
The simpler framing of the issue is basically that NuGet is a library and opens FDs without O_CLOEXEC. The runtime maintains a contract that all FDs are opened with that flag to avoid problems like the above. All libraries that can't control their entire process environment should also set that flag to ensure there are no problems with FD inheritance.