On 12/19/24 18:32, Keith Busch wrote:
This appears to be causing a user space regression. The library "minijail" is used by virtual machine manager "crossvm". crossvm uses minijail to fork processes, but the library requires the process be single threaded. Prior to this patch, the process was single threaded, but this change creates a relationship from the kvm thread to the user process that fails minijail's test.
Thanks for the report. The minijail code has a flag that's documented like this: /// Disables the check that prevents forking in a multithreaded environment. /// This is only safe if the child process calls exec immediately after /// forking. The state of locks, and whether or not they will unlock /// is undefined. Additionally, objects allocated on other threads that /// expect to be dropped when those threads cease execution will not be /// dropped. /// Thus, nothing should be called that relies on shared synchronization /// primitives referenced outside of the current thread. The safest /// way to use this is to immediately exec in the child. Is crosvm trying to do anything but exec? If not, it should probably use the flag.
Fwiw, I think the single threaded check may be misguided, but just doing my due diligence to report the user space interaction.
I don't think the check itself is misguided, but if it can be improved to only look at usermode threads somehow, that would be better. In general Linux is moving towards properly tracking the parent-child relationship of kernel processes (for vhost and io_uring, and now for KVM). Paolo