Sorry about that. Please give me 5 min to fix it.
> On 11 Aug 2024, at 23:46, Theo Buehler <t...@theobuehler.org> wrote:
>
> On Sun, Aug 11, 2024 at 09:10:53AM -0600, Vitaliy Makkoveev wrote:
>> CVSROOT: /cvs
>> Module name: src
>> Changes by: m...@cvs.openbsd.org 2024/08/11 09:10:53
>>
>> Modified files:
>> sys/kern : kern_exit.c kern_fork.c kern_sysctl.c
>> sys/sys : proc.h
>>
>> Log message:
>> Make exit1() wait sysctl(2) `allprocess' loops.
>>
>> Regardless on wired userland memory, KERN_FILE_BYPID and KERN_FILE_BYUID
>> `allprocess' loops have netlock provided sleep points, so concurrent
>> process exit(1) could crash kernel.
>>
>> The main exit1() problem is that process teardown begins while process
>> is still linked to `allprocess' list, and current code doesn't allow to
>> unlink it first. Wait for concurrent sysctl(2) `allprocess' loops
>> between PS_EXITING bit setting and list unlinking. Both KERN_FILE_BYPID
>> and KERN_FILE_BYUID loops do PS_EXITING check and won't deal with dying
>> process. Concurrent exit1() thread will wait loops keeping process
>> linked to `allprocess' list.
>>
>> Tested with i386 dpb(1) run.
>> Stress tests and ok bluhm.
>>
>
> libkvm fails to build with this diff because userland doesn't know about
> struct refcount:
>
> cc -O2 -pipe -g -D_LIBKVM -MD -MP -c /usr/src/lib/libkvm/kvm_proc.c -o
> kvm_proc.o
> In file included from /usr/src/lib/libkvm/kvm_proc.c:76:
> /usr/include/sys/proc.h:145:16: error: field has incomplete type 'struct
> refcnt'
> struct refcnt ps_refcnt;
> ^