# ffsck: matching address sums do not identify the scanned blocks

**A matching sum is weaker than matching the address set, even when block counts agree.**
This packet makes that distinction executable. It is a teaching model, not a
filesystem checker, corruption injector, benchmark replication or incident-rate estimate.

## Source boundary

The FAST 2013 prototype compares address sums for each file and indirect-tree
layer. A mismatch triggers pointer traversal; a match accepts the scan for this
check. The authors explicitly acknowledge collision risk. See section 4.3.2,
Figure 6 and section 6 of [Ma et al., ffsck](https://www.usenix.org/system/files/fast13-final52_0-v2_1.pdf).

## An exact counterexample

Treat these as distinct positive addresses in one file's one indirect-tree layer.
They are invented, not extracted from a disk image.

| Check | Expected | Observed | Agrees? |
| --- | --- | --- | --- |
| Addresses | {100, 103} | {101, 102} | No |
| Address sum | 203 | 203 | Yes |
| Block count | 2 | 2 | Yes |

None of the expected addresses is observed. Nevertheless, both a sum-only test
and a sum-plus-count test accept this pair. Increasing the accumulator width does
not separate these sums: they are equal before any overflow. The same equality
therefore survives reduction modulo any positive integer.

A single substitution, {100, 103} to {100, 104}, changes the sum. The interesting
case is a balanced substitution: one address increases while another decreases.
For integers a and d, the pairs {a, a+3d} and {a+d, a+2d} have equal sums and
equal counts. Choose positive a and d to keep all four addresses distinct.

This is a statement about a lossy summary, not proof that the full checker would
accept a damaged image. Other consistency rules, allocation constraints and
metadata may reject an example that passes this isolated comparison.

## Reproduce and inspect

Use Python 3 from this directory, with no third-party packages:

```sh
python3 -B model.py --check
python3 -B -m unittest discover -s . -p test_model.py
python3 -B -O -m unittest discover -s . -p test_model.py
```

[results.json](./results.json) contains six cases and an exhaustive enumeration
of every unordered comparison between distinct two-address subsets of 1 through
16. The total comparison count is a finite combinatorial denominator, not a
population of disk faults. No percentage is presented as a field failure rate.
An independent test groups pairs by their sum and checks the collision count
against the pairwise enumeration.

[model.py](./model.py) uses unbounded integers. [test_model.py](./test_model.py)
also checks empty layers, reordered addresses, a changed count, large integers,
invalid inputs and duplicate rejection. Run `model.py --write` only when
intentionally regenerating the deterministic output.

## What this model excludes

- It does not combine files or indirect-tree layers.
- It models sets, not duplicate pointer multiplicities or address-to-offset mappings.
- It does not parse ext2/ext3 images, inode backpointers, allocation bitmaps or journals.
- It does not implement the prototype's other validation and repair steps.
- It makes no claim about current e2fsck, ext4, FreeBSD or hardware error frequencies.
- It does not establish that substituting a cryptographic hash alone solves scanning, encoding or recovery correctness.

The practical review question is: **what does the comparison establish, and which
independent checks establish the facts it discards?** Naming those obligations
is more useful than treating one matching summary as an identity certificate.

[Source map](./evidence.json) | [Corpus record](https://hesela.dev/terms/ffsck/)
| [Filesystem-integrity analysis](https://hesela.com/analyses/filesystem-checksum-error-detection/)

Original Hesela example and code, reviewed 2026-12-04. No source paper or figure is
redistributed. Downloaded source identity is recorded separately from model output.
