On Wed, Oct 05, 2022 at 01:09:36PM -0300, Jorge Merlino wrote: > On 13/9/22 19:03, Kees Cook wrote: > > I'll want to spend some more time studying this race, but yes, it looks > > like it should get fixed. I'm curious, though, how did you find this > > problem? It seems quite unusual to have a high-load heavily threaded > > process decide to exec. > > I just got a response from our customer regarding the situation where this > race condition occurs: Thanks for getting back details! > Our application is a Rust-based CLI tool that acts as a frontend to > cloud-based testing infrastructure. In one mode of operation it uploads a > large number of test artifacts to cloud storage, spawns compute instances, > and then starts a VPN connection to those instances. The application creates > the VPN connection by executing another setuid-root tool as a subprocess. We > see that this subprocess sometimes fails to setuid. The "high-load heavily > threaded" aspect comes from the fact that we're using the Tokio runtime. > Each upload to cloud storage is a separate Tokio task (i.e. "green thread") > and these are scheduled onto "N" OS-level threads, where N = nproc. In a > large run we may upload a couple thousand artifacts but limit to 50 > concurrent uploads. Once these artifact uploads complete, we typically spawn > the setuid subprocess within 1-2 seconds. Interesting. Seems like the execve might be racing all the threads exiting? > Have you been able to look at this issue? I'll continue looking at this. Dave, this tracks back to commit a6f76f23d297 ("CRED: Make execve() take advantage of copy-on-write credentials") ... any ideas what's happening here? -- Kees Cook