# Error observation without counter wrap

Controlled userspace replay of Linux v6.12 lib/errseq.c, not a running-kernel
or storage-failure test. The original C file is unmodified.
Discovery: Shashank Mohan Jain, LKML, 27 September 2026:
https://lists.openwall.net/linux-kernel/2026/09/27/146
Follow-up review: https://lists.openwall.net/linux-kernel/2026/09/27/704

Hesela did not discover this bug. Our contribution is a pinned replay and three
omitted-condition controls alongside the existing sequential teaching model.
No fix or release/backport status is asserted.

## Reproduce

Keep this directory and upstream together. Requires Python 3 and a C compiler
with UndefinedBehaviorSanitizer. No packages, storage devices or privileges.

    python3 run.py
    python3 -m unittest -v test_replay.py

The runner checks input hashes, compiles with -O0 and -O2 plus UBSan, and compares
all outputs to results.json. Temporary binaries/headers are removed. --record
explicitly replaces the capture; ordinary replay does not.

## Interpret

compat.h supplies sequential replacements for kernel primitives.
The cmpxchg hook executes one errseq_set(-ENOSPC) before A's attempted seen-bit
update; compare/store behavior is preserved. A and B have distinct cursors.
The later EIO is recorded after A's first call returns. B's observation recreates
A's saved value. A next returns zero, with no counter increment in this case.
Negative errno values are internal helper results, not the userspace convention.

Controls omit the competing update, omit B, or use EIO for the competing update.
Each reports the later EIO to A. These are selected schedules, not exhaustive
concurrency exploration or independent statistical samples. Real callbacks,
external locking, weak memory, storage I/O and error incidence are not tested.
Neither a zero result nor preservation of a report proves repair.

The ATC 2020 study separately examined targeted write faults in Linux 5.2.11
and application recovery with CuttleFS. Those results do not supply a frequency
for this helper schedule or establish current-release behavior:
https://www.usenix.org/system/files/atc20-rebello.pdf

## Sources and rights

Pinned commit: adc218676eef25575469234709c2d87185ca223a (v6.12).
Upstream source, err.h and GPL-2.0 text were fetched from that immutable commit
on 2026-10-25; run.py checks their hashes. err.h verifies MAX_ERRNO, not a
userspace header. Original SPDX notices are retained. New replay code is
GPL-2.0-only. No paper, email or figure is redistributed.
See https://hesela.com/analyses/fsync-failure-retry-durability/#error-cursor-race
