Undoing ext4's fixes, one at a time: which tests notice?

The idea, for anyone: when someone fixes a bug and adds a test, that test should fail if you undo the fix. If it still passes, it is not guarding that fix. So I took the 48 bug fixes in one big Linux pull, undid each one, and ran the tests.

What came back: 41 of the 48 could be undone on their own. For 6 of those, some test failed (the test is doing its job). For 1, the test kernel crashed part way through, which is also the tests noticing. For 34, every test still passed. 7 could not be undone alone, because later fixes changed the same lines.

The interesting one: a fix whose test claims to cover it, yet the test passed with the fix removed. It looked like a missing test. It was not: a later fix in the same pull prevents the same damage. Undo both, and the test fails at the exact line I predicted, in writing, before the run.

Credit first. Ted Ts'o, the ext4 maintainer, had already fixed both problems this page runs into: the two tests that fail at Linus's merge (ext4 dev commit 97f29574e12e, dated 19:13 UTC on 2026-11-25, two and a half hours before my first run) and a crash of the new tests when the kernel is built with CONFIG_USER_NS=y (ad592b92d677). Nothing here is a new bug report. The kernel code was right in both cases; what was missing was a test stub and a field in a test's fake superblock.

Words used on this page

ext4
A Linux filesystem, the default on many distributions: the code that lays files out on a disk.
KUnit
The Linux kernel's built-in unit test framework. Each test calls a small piece of kernel code directly and checks the answer, with no real disk. EXTERNAL · official docs ↗
kunit.py
KUnit's runner: it builds a test kernel, boots it, and reports each test as passed or failed. EXTERNAL · official docs ↗
UML (User Mode Linux)
The kernel built as an ordinary program, so the tests run on a laptop without a virtual machine. Every run here is 64-bit x86 UML.
A Fixes: tag
The line in a kernel commit message that names the commit whose bug it fixes. EXTERNAL · official docs ↗
Undoing (reverting) a fix
Here, always: at the pull's last commit, reverse the fix's changes outside the test files (fs/ext4/*-test.c) and keep the tests as they are. A plain git revert would also delete a test that arrived in the same commit as its fix.
Witnessed
Some test fails with the fix undone and passes with it in place. That test is a witness for the fix.
Passes both ways
Every test passes with the fix undone too. This does not mean the fix is untested: ext4's main regression suite is xfstests, which tests a real mounted filesystem and was not run here (EXTERNAL · project docs ↗). It means the KUnit tests did not catch that fix being undone, under this one configuration.
KASAN
The kernel's memory-error detector, a build option that turns an out-of-bounds access or a use after free into a report. EXTERNAL · official docs ↗
jbd2
The journaling layer ext4 sits on, in fs/jbd2/, a separate directory from fs/ext4/.
Kernel configuration
The list of options a kernel is built with. CONFIG_USER_NS turns on user namespaces (separate user id ranges, the thing containers use); kunit.py's --kconfig_add adds an option on top of the suite's own list, fs/ext4/.kunitconfig.

Why this pull

On 2026-11-24 Ted sent the ext4 pull for 7.4-rc5 (base 7475ea8b5861, which is v7.4-rc2, tip bae28a1b11f4, 94 commits, 41,197 added lines). Most of the new lines are KUnit tests; his message says they make it "safer to validate AI generated patches" (EXTERNAL · mailing list ↗). Linus merged it as 4dce97c6c265 and, replying to Ted, wrote that the test conflict resolutions looked right to him "but I didn't *run* any of them" (EXTERNAL · mailing list ↗).

That raises a question you can answer with a computer: do the new tests notice when the fixes they ship with are taken away?

1. The merge, under two kernel configurations

The whole ext4 KUnit suite (562 tests), run with kunit.py run --arch=um --kunitconfig=fs/ext4, with and without CONFIG_USER_NS=y added.

TreeThe suite's own config (CONFIG_USER_NS off)Plus CONFIG_USER_NS=y
The pull's tip bae28a1b11f4562 of 562 pass277 pass, then the kernel panics in the new xattr test; the other 285 never run
Linus's merge 4dce97c6c265560 pass, 2 fail (the same 2 in each of three runs)275 pass, the same 2 fail, then the same panic
Ted's ext4 dev tip ad592b92d677 (the merge plus his two fixes)562 of 562 pass562 of 562 pass

The 2 failures at the merge are ext4_inode_test.inode_test_get_inode_loc_variants and ext4_inode_test.inode_test_write_and_sync_metadata. Linus's side of the merge had switched ext4_get_inode_loc_noio() to a non-atomic block lookup (d25c14b2d79e), and the merge kept that through a new wrapper, ext4_sb_find_get_block_nonatomic(). The pull's test replaces only the old lookup, ext4_sb_find_get_block(), with its fake buffer cache, so the fake is never asked and the function returns "try again" (-EAGAIN). Putting that one call back to the old lookup makes all 41 inode tests pass, which located the cause; Ted's actual fix adds the missing stub to the test instead (2 lines in fs/ext4/inode-test.c), which is the right fix: the code was correct.

# inode_test_get_inode_loc_variants: ASSERTION FAILED at fs/ext4/inode-test.c:1846
Expected err == 0, but
    err == -11 (0xfffffffffffffff5)
# inode_test_write_and_sync_metadata: EXPECTATION FAILED at fs/ext4/inode-test.c:3335
Expected err == -5, but
    err == 0 (0x0)

The panic with CONFIG_USER_NS=y is the one Ted's second fix describes: the xattr test's fake superblock has no user namespace, and creating an extended-attribute inode reads the owner through it. On UML a fault in kernel code with no memory map stops the whole kernel, not one test:

RIP: 0033:map_id_range_up+0xa/0xd0
Kernel panic - not syncing: Segfault with no mm
 [<602aa9b5>] ? ext4_xattr_inode_lookup_create+0x375/0xbd0
 [<602ad589>] ? ext4_xattr_set+0x99/0x180
 [<602f65b7>] ? test_xattr_external_block_and_check+0x677/0x10e0

Every run before this check used the suite's own configuration, so every count below holds for that configuration: fs/ext4/.kunitconfig does not set CONFIG_USER_NS and the kernel's default is off. The configuration check's outcome for each tree (fails or passes) was written down and committed before it ran (prediction, cases; committed 01:10 UTC on 2026-11-26, first job 01:17 UTC); each came out as written. Raw results: merge log, tip log, the repeat and the one-line check, the tip's kernel log with CONFIG_USER_NS=y, and every case's result, kunit.py output, kernel log and generated .config in results/config/.

2. Undoing each of the 48 fixes

The pull has 50 commits with a Fixes: line; one touches only test files and one changes only a comment, which leaves 48 that change code. For each, at the tip:

git diff FIX^ FIX -- . ':!fs/ext4/*-test.c' | git apply -R --3way
python3 tools/testing/kunit/kunit.py run --arch=um --kunitconfig=fs/ext4
Witnessed: 6 of 48 Stopped part way: 1 of 48 Passes both ways: 34 of 48 Reversal conflicts: 7 of 48 6 witnessed1 34 pass both ways 7 conflict
  • witnessed (6)
  • stopped part way (1)
  • passes both ways (34)
  • reversal conflicts (7)

Every job took about 7 seconds (an incremental rebuild plus the whole suite) on a 16-CPU cloud sandbox. The tool's verdicts are derived from each job's raw result file, which lists every test's status with and without the fix: all 48 result files and this table as JSON. One correction to the tool, made after this run: it labeled the crash "cannot run", the same words as a conflict; it now reports such a job as stopped part way, and the table says what happened.

FixTitleOutcomeWhy, or which tests
3b6aee59883cext4: clear journal restart indication after inserting extentwitnessed1 test fails without the fix and passes with it: ext4_migrate_test.test_ext_migrate_survives_handle_restart A test claims it: bae28a1b11f4's migration tests.
9627baed418bext4: check multi-block overlap on left traversal in add_system_zone()witnessed4 tests fail without the fix and pass with it: ext4_block_validity_test.test_journal_extent_left_overlap_rejected, ext4_block_validity_test.test_setup_corrupt_group_metadata_overlaps.itable_starts_before_and_encloses_ibitmap, ext4_block_validity_test.test_setup_corrupt_group_metadata_overlaps.itable_starts_before_and_overlaps_bbitmap, ext4_block_validity_test.test_setup_corrupt_group_metadata_overlaps.itable_u64_wrap_around_overflow A test claims it: its own test, in the same commit.
b0a3f2c102e8ext4: cap migration extent length at EXT_INIT_MAX_LENwitnessed1 test fails without the fix and passes with it: ext4_migrate_test.test_ext_migrate_caps_long_run_at_init_max_len A test claims it: bae28a1b11f4's migration tests.
bfb8f5ce8815ext4: drop tmp inode ownership before migration cleanupwitnessed1 test fails without the fix and passes with it: ext4_migrate_test.test_ext_migrate_credit_or_dirty_failure_keeps_live_blocks A test claims it: bae28a1b11f4's migration tests.
daa099ec5ce3ext4: Fix maximum orphan file size checkwitnessed1 test fails without the fix and passes with it: ext4_orphan_test.test_init_orphan_info_max_blocks_boundary
ff06f373c1d7ext4: don't fail journal recovery on an incomplete fast commitwitnessed1 test fails without the fix and passes with it: ext4_fast_commit_test.test_fc_replay_regions_and_scan
f62b22b69aefext4: free fast commit replay state on failed mountsstopped part waywithout the fix the kernel panics part way through the suite, in ext4_fast_commit_test: 342 tests pass and 220 are never reached (the laptop rerun's log shows the panic: BUG at fs/ext4/ext4_jbd2.c:36). The tool that ran this job labeled it "cannot run"; it was fixed afterwards to say stopped part way
0a10fca0f154ext4: fix folio reference leak in mpage_submit_partial_folio()passes both waysall 562 tests pass with the fix reverted and at the tip; a memory-safety fix: rerun with KASAN on a laptop, still 562 of 562 and no KASAN report
0bc15784860ejbd2: fix shrinker scan budget accounting in jbd2_journal_shrink_scan()passes both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
180354ab292fext4: drop extra ea_inode ref in cached-block reuse pathpasses both waysall 562 tests pass with the fix reverted and at the tip; a memory-safety fix: rerun with KASAN on a laptop, still 562 of 562 and no KASAN report
1ea9e6b3bd31ext4: return 0 instead of stale ret in ext4_iomap_writepages()passes both waysall 562 tests pass with the fix reverted and at the tip
2c1c8c412bb8ext4: propagate errors from fast commit bitmap rebuildpasses both waysall 562 tests pass with the fix reverted and at the tip
2cfcd9fa8734ext4: return an error when a journal block is not mappedpasses both waysall 562 tests pass with the fix reverted and at the tip
337c173f966cext4: don't free the tmp_inode tree after a partial migration swappasses both waysall 562 tests pass with the fix reverted and at the tip; masked by the later fix 6bda1a98b7ce: see the masking check A test claims it: bae28a1b11f4's migration tests (cited there by its pre-rebase hash 047061e6a6da).
356c92606175ext4: clear in-inode xattr space before adding the first xattrpasses both waysall 562 tests pass with the fix reverted and at the tip
390d69dd5c82ext4: add inode to orphan list before extent conversionpasses both waysall 562 tests pass with the fix reverted and at the tip
3b9f870a7549ext4: add bounds check for e_value_offs in ext4_read_inline_datapasses both waysall 562 tests pass with the fix reverted and at the tip; a memory-safety fix: rerun with KASAN on a laptop, still 562 of 562 and no KASAN report
40b2a37f9a7ejbd2: check return value of blkdev_issue_flush() when checkpointingpasses both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
40e53dad45a9jbd2: set JBD2_LOADED under j_state_lockpasses both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
44d3b834bef8ext4: skip holes when shrinking the extent tree in fast commit replaypasses both waysall 562 tests pass with the fix reverted and at the tip
474b6405c0f6ext4: do not accept rec_len 0 for block sizes below 64kpasses both waysall 562 tests pass with the fix reverted and at the tip
489b444770b1ext4: propagate errors from fast commit create replaypasses both waysall 562 tests pass with the fix reverted and at the tip
4a5cc4d1a7f0ext4: propagate errors from fast commit block cleanuppasses both waysall 562 tests pass with the fix reverted and at the tip
4e04e3962070ext4: fix the logical block counter overflow in indirect migrationpasses both waysall 562 tests pass with the fix reverted and at the tip
543341eba8f4jbd2: don't start a fast commit while the journal is marked emptypasses both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
58b186b5bbd2ext4: validate inode block references during fast commit replaypasses both waysall 562 tests pass with the fix reverted and at the tip
7d7c94601664ext4: fix discard work use-after-free on failed mountpasses both waysall 562 tests pass with the fix reverted and at the tip; a memory-safety fix: rerun with KASAN on a laptop, still 562 of 562 and no KASAN report
7d7c9c83c822ext4: complete dropbehind writeback in task contextpasses both waysall 562 tests pass with the fix reverted and at the tip
8d90b9ab0875ext4: save converted extent before mergingpasses both waysall 562 tests pass with the fix reverted and at the tip
8eb922c5c467ext4: record writeback error when discarding pages on failed delallocpasses both waysall 562 tests pass with the fix reverted and at the tip
9e3cb03d3933jbd2: check return value of blkdev_issue_flush() for async commitspasses both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
b28443aa879bext4: propagate errors from fast commit i_blocks replaypasses both waysall 562 tests pass with the fix reverted and at the tip
b8e62a68c59fjbd2: check return value of blkdev_issue_flush() when committingpasses both waysall 562 tests pass with the fix reverted and at the tip; a jbd2 fix (fs/jbd2/ only, the journaling layer under ext4)
bbae5e26222eext4: do not report inline conversion allocation failures as fs errorspasses both waysall 562 tests pass with the fix reverted and at the tip
c966757ff80fext4: fix readdir position truncation on 32-bit kernelspasses both waysall 562 tests pass with the fix reverted and at the tip; a 32-bit-only bug, which a 64-bit build cannot show
cdecc68d94a7ext4: preserve force-fsck requests across unmountpasses both waysall 562 tests pass with the fix reverted and at the tip
d0877f8eb3c0ext4: initialize map->m_pblk in ext4_da_map_blocks()passes both waysall 562 tests pass with the fix reverted and at the tip
d5fd7d0564d8ext4: fix extent status cache clearing when truncating inline datapasses both waysall 562 tests pass with the fix reverted and at the tip
e290c77088e6ext4: fix OOB memmove in ext4_xattr_set_entrypasses both waysall 562 tests pass with the fix reverted and at the tip; a memory-safety fix: rerun with KASAN on a laptop, still 562 of 562 and no KASAN report
e5db68ec43e9ext4: do not advance i_size on a buffered write that copied nothingpasses both waysall 562 tests pass with the fix reverted and at the tip
f0872c44eda1ext4: skip eof zeroing when the zero range covers the eof blockpasses both waysall 562 tests pass with the fix reverted and at the tip
020035ee8feaext4: fix shrinker scan budget accounting in ext4_es_scan()reversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/extents_status.c)
6025f9d156cfext4: check return value of blkdev_issue_flush() when starting a fast commitreversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/fast_commit.c)
79906e00636eext4: don't cache unzeroed blocks as written after a failed zerooutreversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/extents.c)
82e2a5743b6aext4: don't clobber the migration error in ext4_ext_migrate()reversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/migrate.c) A test claims it: bae28a1b11f4's migration tests.
8a72b083d8bcext4: check return value of blkdev_issue_flush() when initializing inode tablesreversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/ialloc.c)
a7fd013d368aext4: reject atomic writes on inodes that can't do direct I/Oreversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/ext4.h)
cd169c27f0abext4: track zeroed out blocks of unwritten extents for fast commitreversal conflictsthe reverse of its changes does not apply at the tip: a later commit of the pull changed the same lines (git reports a conflict in fs/ext4/ext4.h, fs/ext4/ext4_extents.h)

3. Masked, not missing: 337c173f

The pull's last commit, bae28a1b11f4, adds migration tests and says in its message that they cover several fixes, among them "ext4: don't free the tmp_inode tree after a partial migration swap". That is 337c173f966c; the message cites it by its pre-rebase hash, 047061e6a6da, so searching the message for 337c173f finds nothing. Undo it, and all 11 migration tests still pass.

Reading the code first, without running anything: the test does check the outcome that fix protects. Line 1351 of fs/ext4/migrate-test.c, KUNIT_EXPECT_FALSE(test, migrate_was_freed(ctx, ext_idx_pblk)), asks whether the migrated inode's extent index block was freed after a failed swap, which is the bug in 337c173f's own message. But a later fix in the same pull, 6bda1a98b7ce (another author's; it carries no Fixes: line, so it is not one of the 48), empties the temporary inode's extent tree before anything can fail. With it in place, the call 337c173f skips frees nothing anyway. A belt where the braces are already on.

So the guess was masked: line 1351 should fail only when both are undone. The other guess, that no test reaches this bug, says line 1351 never fails. I wrote down, for each of five cases, which way line 1351 would go, and committed that before the run (prediction, cases; committed 23:02 UTC on 2026-11-25, first job 23:07 UTC, per the run's own log). Those commit times are from my private repository, so for the order you have my word, not a public timestamp; the laptop rerun below reproduces the outcome either way.

Undone at the tipPredicted at line 1351Line 1351Expectations that failed
nothing (the tip)holdsholdsnone; 11 of 11, and the whole suite 562 of 562
337c173f aloneholdsholdsnone
6bda1a98 aloneholdsholds1327, 1328
bfb8f5ce aloneholdsholds1325, 1329
337c173f and 6bda1a98failsfails1327, 1328, 1351
337c173f and bfb8f5ceholdsholds1325, 1329
# test_ext_migrate_credit_or_dirty_failure_keeps_live_blocks: EXPECTATION FAILED at fs/ext4/migrate-test.c:1351
Expected migrate_was_freed(ctx, ext_idx_pblk) to be false, but is true

(that run's log; every case's result and log are in results/masking/.) The pull's claim holds in the sense that matters: the test checks what 337c173f protects. What no test at the tip can do is fail for 337c173f's absence alone, because 6bda1a98 makes it redundant there. Not run, so a reading only: on a tree that takes 337c173f without 6bda1a98 (a stable backport picked one at a time, say; both carry Cc: stable), 337c173f alone would decide line 1351.

The general lesson for anyone checking tests this way: "passes both ways" can mean a later fix is doing the same job. Undoing fixes that touch the same code in pairs, and watching the one line that names the bug, told the two apart in one run.

4. Rerun it on your laptop

You need Docker, Python 3 and about 3 GB of disk. The first run fetches the kernel history since 2026-11-01 from GitHub (633 MB) and two commits of Ted's tree from git.kernel.org, and builds the test kernel; later runs reuse both. On my laptop the first masking run, fetch and build included, took about 4 minutes.

curl -sLO https://plimsollmark.github.io/plimsoll/case-studies/ext4-witness/scripts/reproduce.sh
for f in setup.sh witness.py queues.py fixes.json; do
  curl -sLO https://plimsollmark.github.io/plimsoll/case-studies/ext4-witness/scripts/$f
done
sh reproduce.sh masking     # section 3: six jobs
sh reproduce.sh merge       # section 1, the suite's own config
sh reproduce.sh config      # section 1, both configs and Ted's dev tip
sh reproduce.sh fixes       # section 2: all 48

Each prints one line per job and leaves every result file and kunit.py log in ext4-witness-out/. These exact scripts were run that way before this page went up (sh reproduce.sh masking, on a laptop, 2026-11-26): line 1351 failed only with 337c173f and 6bda1a98 both undone, every other failed expectation matched the table in section 3, and the tip passed 562 of 562 (its summary, its result files).

The runs on this page were made in a 16-CPU cloud sandbox, driven by a small script of mine that creates the sandbox, copies witness.py and a queue in, and copies the results out. That script is specific to the cloud service and its billing and is left out; nothing in it changes a result. witness.py here is the version that ran last, changed only so its paths can be moved and ccache is optional.

Already rerun once, on a different machine. A second check, written separately from witness.py (its own undo and run commands), ran on a laptop: Debian bookworm's gcc 12, no ccache, a fresh clone. The tip passed 562 of 562 three times; the same 6 fixes were caught by the same tests; f62b22b69aef stopped at the same 342 with BUG: failure at fs/ext4/ext4_jbd2.c:36; 82e2a5743b6a conflicted the same way; undoing 6bda1a98 and 337c173f together failed lines 1327, 1328 and 1351 and nothing else. After the first build each run took 4 to 6 seconds; the whole rerun took under two minutes (summary, test-for-test comparison, every log, its .config).

What this shows, and what it does not