Public bug reported: Topline request: update the version of libblkid1 in 26.04LTS to at least v2.42 or backport fix dc47ed2f5f6a.
See: https://github.com/util-linux/util-linux/issues/4078 A recent interaction of multiple bugs led to filesystem corruption on Ubuntu upgrade. Background: About 20 years ago I created a small Ubuntu LTS server instance for home use. After much trial-and-error I settled on using mdadm RAID1 for the file systems. Over the years, I would rotate new equipment in with the same image remaining, including a x86->x86_64 in-place upgrade. When I bought new hard drives I would add them to the pool as another mirrored drive, stabilize and validate, and then safely remove the older device. Due to the improvements in technology the backing drives continued to grow in size. Not wanting to "waste" storage space, my storage upgrade cycle started to involve resizing the array in order to leverage the hardware I'd purchased. This meant that the upgrade cycle looked like: * Install new drive to the RAID array. Wait for mirror sync to complete. And then stabilize and verify. * Remove (typically) the smallest device from the RAID array. Stabilize and verify. * Online grow the RAID array to reflect the partition on the smallest device. Stabilize and verify. * Online grow the ext3 file system to reflect the new md device size. Stabilize and verify. * Enjoy the new hardware. Proximate Events: My server sat running 22.04 LTS for a while. Noting the huge number of CVEs coming out and assuming that newer versions of Ubuntu were more likely to be secure or fixed faster, I elected to upgrade. The upgrade from 22.04LTS to 24.04LTS went smoothly, modulo a few minor config changes and similar issues. Everything seemed fine. I then performed the upgrade to Ubuntu 26.04LTS. This ran into more issues to fix. Ultimately I rebooted. I then discovered I was at the initramfs console and my root filesystem was considered corrupt. I attempted e2fsck but after a few minor warnings/fixes I got major corruption warnings. I spent a lot of time trying to diagnose the issue. Ultimately, I threw a lot of AI power at the issue and was able to recover the system. This is one of many bug reports I am filing over the issues which were uncovered. Forensic Findings: The following is an AI-generated report. I normally wouldn't provide AI output, but the same session which generated these findings also generated a comprehensive playbook which managed to recover the file system to a working state with only a trivial amount of lost data so I have some confidence in it. I've trimmed a large amount of contents such as the playbook, binary block data, and details about intervening steps which aren't related to any bug reporting. These can be provided privately if needed. # Forensic findings: ext3 on md127 corruption (host 192.168.0.176) Working log. All commands run on the target were read-only. **Times are UTC (Z).** The rescue host runs in UTC, so `mdadm --examine`, `dumpe2fs` and `dmesg` on it print UTC. Log extracts taken from the old root fs (apt history, release-upgrade logs, syslog/journal) are in the site's local time, EST (UTC−5). Where a time comes from those logs, both are given. --- ## Executive summary (read this first) 1. **Trigger (Nov 22, first boot of 26.04).** A libblkid regression in util-linux 2.41.3 made the *whole disk* `/dev/sdc` look like an md 0.90 member. - The regression is upstream issue #4078. It was introduced by 8a534253bc52 ("libblkid: (probe) read data in chunks", 2023-09-30, first released in v2.40) and fixed upstream by **dc47ed2f5f6a** on 2026-03-01. The fix was first released in v2.42 (2026-04-01) and is in no v2.41.x release. Ubuntu 24.04's 2.39.3 predates the bug. The fix is **not** in Ubuntu 26.04's `2.41.3-3ubuntu2.2`. - sdc had a single partition `sdc1` running from sector 2048 to the end of the disk. In that layout, the 0.90 superblock of `sdc1` sits on the very sector where a whole-disk 0.90 superblock would sit. - udev called `mdadm --incremental /dev/sdc`. mdadm deleted `sdc1` (BLKPG) and assembled md127 from `sdb2 + sdc(whole) + sda2`. - **The sdc mirror leg was therefore shifted 256 fs blocks (1 MiB)** relative to the other two legs. Every RAID1 read served by sdc returned the wrong block. 2. **The initramfs `fsck -a` (21:46:16Z) read through the misaligned leg and then wrote the result back.** - It read meta_bg descriptor block 16777216 from sdc, and got data block 16776960 instead. - It printed *"Block bitmap for group 512 is not in group (block 2736812015)"*. - On its way out (`preenhalt`), it flushed that garbage to **all three** MG4 descriptor copies on **all three** disks. It also wrote fs metadata to the wrong places on sdc. 3. **A latent 2016 kernel bug then made e2fsck's "trying backup blocks" fallback poisonous.** - An online resize in March 2016 overwrote group 1's backup GDT block 32769 with GDT block #3. That is the kernel's `update_backups()` meta_bg bug, fixed upstream by a6b3bfe176e8 in 2024. - As a result, e2fsck's backup "group 0..127" descriptors are really groups 384..511. That explains *"Block bitmap for group 0 is not in group (block 12582912) … Inode table … (block 12582919) SEVERE DATA LOSS"*. 4. **e2fsck history, proven by offline replay of the same blocks with e2fsprogs.** - **The user's interactive run was cancelled and wrote nothing.** It ran while sdc was still in the array. This is simulation-supported, not directly provable. - The user then removed sdc from the array deliberately (`mdadm` fail/remove, on another AI agent's advice, to keep it as a "backup"; §4.5). After that, **two more read-write runs** on sda2+sdb2 each: - replaced the primary superblock and GDT (fs blocks 0–4) with the 2016 backup; - bumped the journal sequence; - wrote a fabricated journal inode over **inode 6291464** (a 2009 Maildir file) in block 12582919; - died with *"unable to set superblock flags"*. - Every further rw `e2fsck` run would repeat this loop. 5. **Damage is small and fully recoverable. The repair has been validated on the real disks without writing to them.** - On sda2/sdb2 only 10 metadata blocks are wrong, plus 3 benign ones (free counts only). No file data was overwritten on sda2/sdb2. - Correct pre-incident copies of all 13 exist on sdc, 256 blocks (1 MiB) further in. - Read-only validation on the target on 2026-12-01 (§8.8): - A read-only device-mapper view of md127, with those 13 blocks taken from sdc, has the pre-incident superblock (clean, last mount 2026-11-22 20:13:20Z). - The target's own `e2fsck -fn` (1.47.2) passes all five passes without a single message: `RootFileSystem: 331739/14155776 files (13.9% non-contiguous), 21698394/28311552 blocks`. - The view is byte-identical, over all 108 GiB, to sdc's copy repaired the other way round (Route B). 6. **sdc as the "backup".** - Removing sdc before the read-write runs was the right call: it is why intact copies of the 13 blocks still exist. - On its own, however, sdc is **not** a usable backup. Its MBR is gone, and 8 blocks of its filesystem were overwritten through the misaligned leg (§6.2): - 7 of them are data blocks of six video files and `/boot/initrd.img-6.8.0-151-generic`, and no fsck can detect that; - the eighth is block 276 (inode table of the unused inodes 8609–8640). - Its only unique content is those 13 blocks (52 KiB), which the playbook saves first. 7. **Do not:** - run `e2fsck` read-write on md127 or any member, other than through the playbook (§8); - use the `safe_root` dm device (it is the misaligned view plus hand edits in RAM; playbook p0 removes it); - run `e2fsck -b <backup>`. **Every** backup group's GDT is wrong (§4.1, §8.0): group 1 is poisoned by the 2016 bug, and groups 3…343 are stale for groups 440–511; - boot the installed system with sdc attached before playbook p6b has passed, or otherwise let `/dev/sdc` (whole disk) be assembled again; - use `mdadm --force` with sdc present. 8. **Code fixes and tests (§9, §10).** - Two of the e2fsprogs defects are general and are still present in upstream e2fsprogs (tree 76b5934, 1.47.4): - **E3:** `e2fsck -fy -b <backup>` on *any* online-grown ext3/ext4 dies with "unable to set superblock flags" (exit 12). The kernel leaves needs_recovery set in the backup superblocks, and e2fsck re-opens the same backup after journal recovery. - **E7:** since v1.47.1 (f7ef5f3e356d) the relocate hint always says `-b 8193`. On a 4 KiB-block fs that is not a superblock at all. - An unprivileged invariant suite (`tmp/mini/invariants.sh`) encodes the desired behaviour. Results: distro 1.47.0 and upstream: `2 passed, 9 failed`; prototype patch (`tmp/mini/e2fsprogs-prototype.patch`): `9 passed, 2 failed`. Upstream `make check` with the patch changes only expected outputs. - **Fixing E3 alone is dangerous.** The fatal error is what stopped the rw runs from relocating every group. An E3-only build on the post-preen miniature carried on and destroyed it (264 relocations, `12/4800 files`). E1 (validate backup descriptors) must land with or before E3. - The libblkid fix needs a backport to 2.40.x/2.41.x (Ubuntu 26.04 SRU). Its upstream test never ran (root-only, `TS_KNOWN_FAIL`); an unprivileged replacement is in `tmp/blkidtest/`. ** Affects: util-linux (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2190910 Title: libblkid version results in file system corruption To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2190910/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
