A failed lock upgrade can discard earlier protection

A stable coordination file does not guarantee continuous ownership while changing lock mode. On local Linux, a conflicting nonblocking flock() shared-to-exclusive conversion can remove the earlier shared lock. The original descriptor can remain open throughout. flock(2), NOTES

Hesela tested three independent native processes using the same API within each case. A and B acquired shared locks; A tried an exclusive conversion; B then unlocked. C tried an exclusive lock and wrote a new value only when admitted. A finally reacquired shared protection and reread the same file.

Conflict scenario only. Six executions per API on one Linux 6.8.0-147-generic system: three repetitions at each of two compiler settings. These are reproduction counts, not estimated failure rates.
API Upgrade refused C admitted after B left Changed data after A reacquired
flock 6 / 6 6 / 6 6 / 6
F_SETLK 6 / 6 0 / 6 0 / 6
F_OFD_SETLK 6 / 6 0 / 6 0 / 6

Controls without an upgrade, with a successful uncontended upgrade, and with shared reacquisition before B unlocked all excluded C. After the final explicit unlock, C succeeded in every case. The full experiment contains 72 executions and preserves ordered calls, process and file identity, return codes, errno and payload reads.

The reviewed generic Linux implementation removes the old flock record before testing competing locks. The fcntl path checks conflicts before modifying the caller's records. Similar ownership terminology therefore does not imply identical conversion behavior. Linux v6.8 source; v6.17 source comparison.

Design implication: after protection is lost, reacquiring a lock does not validate the earlier read. Recheck state under the required lock before acting; acquire exclusive authority before mutation. The shared reacquisition here is a read witness, not permission to write.

This is a local ext4 observation and source synthesis, not a newly found kernel defect, crash test, database-corruption reproduction or NFS/SMB result. Traditional and OFD record locks also retain their other ownership and deadlock distinctions. fcntl_locking(2).