# Inotify ownership controls

Hesela, 20 November 2026. Original code, data and prose: CC0.
Companion to https://hesela.com/analyses/inotify-change-detection/ and
https://hesela.dev/terms/inotify/. No new vulnerability or product failure claim.

## Scope and result

Eleven sequential controls, three repetitions on ext4 and tmpfs: 66 case
executions on one Linux 6.8.0-149-generic host. Every case changes exactly one
byte in a fresh 4096-byte hard-linked file and checks all bytes. Repetitions
agree but are not independent fleet samples.

Two aliases in one inotify instance share a watch. Mask replacement, mask union,
CREATE rejection, explicit removal and ONESHOT are separate controls. Duplicated
descriptors consume one queue, whereas independently initialized instances each
receive their own notification. A directory watch does not cover writes through
an outside hard link; a direct file watch does in the paired control.

These are documented API mechanisms, not measured backup failure prevalence.
No crash, power loss, remote filesystem, concurrent-client race or actual backup
implementation was tested. The pinned upstream source explains the mechanism;
it is not asserted byte-identical to the running Ubuntu kernel.

## Files and reproduction

Keep the following files together: probe.py, verify.py, test_probe.py,
results.json, summary.json and RESULTS.md. Sources and exact locators are in
sources.json. manifest.json records SHA-256 digests of the public files.

Requires Linux, Python 3 standard library, proc fdinfo, findmnt and writable
test directories. IN_MASK_CREATE requires kernel support. No root privileges,
package installation or system settings changes.

```sh
python3 -B verify.py --check-generated
python3 -B -m unittest -v test_probe
python3 -B -O -m unittest -v test_probe
python3 -B probe.py --directory /tmp --directory /dev/shm --repetitions 1 --output fresh.json
python3 -B verify.py --input fresh.json
```

Choose a NEW output filename: the probe writes its requested output path.
Fixture directories are private and removed by the probe; existing files are
not used as test payloads. Each nonblocking drain waits up to 20 ms for readiness
then reads through EAGAIN. Queued overflow rejects the observation. Synchronous
local writes and explicit reads separate configuration, write and close phases.

results.json is the full original capture; summary.json and RESULTS.md are
derived from it. A successful fresh replay is not expected to reproduce inode
numbers, timestamps or raw hashes of the complete capture. The verifier checks
event sequences, syscall outcomes, inode identity and payload hashes instead.

## Engineering inference

A shared watcher needs managed logical subscriber lifetimes, compatible event
masks and behavior flags, and deliberate fan-out from its queue reader.
IN_MASK_ADD does not create a reference-counted subscription. Separate instances
isolate these interests but retain inotify's coverage and overflow limits.
Event delivery, complete discovery and consistent backup capture are distinct
obligations. Reconcile state and test restoration separately.
