NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/60846: fork() disrupts futex



The following reply was made to PR kern/60846; it has been noted by GNATS.

From: D Benali <ebenali101%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: chs%netbsd.org@localhost
Subject: Re: kern/60846: fork() disrupts futex
Date: Fri, 4 Dec 2026 21:26:17 -0800

 I have hit the same mechanism from the native side and reported it (PR
 61128, now closed as duplicate), but it breaks down the sequence
 leading to this very same behavior.
 
 a futex key on MAP_SHARED anon memory makes the next write copy the
 page and lose other processes stores.
 
 Essentially it's because  uvm_noaddr_acquire names memory in an amap
 by its vm_anon which is NOT a stable identity, the anon in a slot is
 replaced when a COW fault promotes the page and keys taken on it go
 stale as soon as the copy is made.
 
 My PR also outlines a candidate fix in general terms:
 > - identify amap memory by (amap, slot), rather than the anon.
 > - give a COW entry its own amap first (amap_copy) before taking the key.
 >   otherwise a key taken would go stale as soon as the copy happens.
 > - use the private key, (vmspace,va) for a shared futex in private memory.
 >   except for minherit(MAP_INHERIT_SHARE) which ends up being handed to a child shared on a fork()
 



Home | Main Index | Thread Index | Old Index