HomeFreeBSD

vfs offset: fix assertion failure in face of racing ffofset and setfl locking

Description

vfs offset: fix assertion failure in face of racing ffofset and setfl locking

Both use the same 16 bit var to store their locked and waiters bits,
then this in file_v_unlock:

state = atomic_load_16(flagsp);
if ((state & lock_wait_bit) == 0 &&
    atomic_cmpset_rel_16(flagsp, state, state & ~lock_bit))
        return;

can fail if for example foffset is being unlocked while setfl is getting
locked.

Afterwards the code assumes there are blocked waiters on foffset.

Approved by: re (cperciva)
Reviewed by: kib, markj
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D52915

(cherry picked from commit f43e19db6cea0a7dd7bf51f3fe2227d466ea5a80)

Details

Provenance
mjgAuthored on Oct 5 2025, 5:03 PM
cpercivaCommitted on Oct 15 2025, 6:08 AM
Reviewer
kib
Differential Revision
D52915: fix file_v_unlock
Parents
rGbf591ddc87aa: blocklist: Add an UPDATING entry
Branches
Unknown
Tags
Unknown