Martin Pieuchot <m...@openbsd.org> wrote: > On 17/05/22(Tue) 10:44, David Gwynne wrote: > > this narrows the scope of the KERNEL_LOCK in kbind(2) so the syscall > > argument checks can be done without the kernel lock. > > > > care is taken to allow the pc/cookie checks to run without any lock by > > being careful with the order of the checks. all modifications to the > > pc/cookie state are serialised by the per process mutex. > > I don't understand why it is safe to do the following check without > holding a mutex: > > if (pr->ps_kbind_addr == pc) > ... > > Is there much differences when always grabbing the per-process mutex?
I think the theory is ps_kbind_addr is fixed to a shared address space in "pr", if you are threaded there is only one ps_kbind_addr for all the processes "p" sharing that address space. And execve() uses single_thread_set, which means you can't race?