diff -Nru e2fsprogs-1.44.1/debian/changelog e2fsprogs-1.44.1/debian/changelog --- e2fsprogs-1.44.1/debian/changelog 2018-12-11 18:39:48.000000000 +0000 +++ e2fsprogs-1.44.1/debian/changelog 2019-01-24 23:11:28.000000000 +0000 @@ -1,3 +1,12 @@ +e2fsprogs (1.44.1-1ubuntu1.1) bionic; urgency=medium + + * d/patches/0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch: + do the checksum update later in extent tree relocated block to denote the + inode number change, otherwise the checksum update might be done in the old + copy of the block. (LP: #1798562) + + -- Mathieu Trudel-Lapierre Thu, 24 Jan 2019 18:11:28 -0500 + e2fsprogs (1.44.1-1ubuntu1) bionic; urgency=medium * debian/patches/0001-libext2fs-fix-regression-so-we-are-correctly- diff -Nru e2fsprogs-1.44.1/debian/patches/0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch e2fsprogs-1.44.1/debian/patches/0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch --- e2fsprogs-1.44.1/debian/patches/0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch 1970-01-01 00:00:00.000000000 +0000 +++ e2fsprogs-1.44.1/debian/patches/0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch 2019-01-24 23:09:06.000000000 +0000 @@ -0,0 +1,100 @@ +From 4b3038134baf81c6f9bd36dbbf565ea66e46331f Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Sat, 20 Oct 2018 09:14:48 -0400 +Subject: [PATCH] resize2fs: update checksums in the extent tree's relocated + block + +When shrinking an file system, and we need to relocate an inode, the +checksums in its extent tree must get updated to reflect its new inode +number. When doing this, we need to do this *after* we update the +extent tree to reflect any blocks which need to be relocated due to +the file system shrink operation. + +Otherwise, in the case where only an interior node of the extent tree +needs to get relocated, and none of the entries in that node need to +be adjusted, the checksum for that interior node is updated in the old +copy of that block, and then after the extent tree is updated to use +the new copy of that interior node, the extent tree is left with an +invalid checksum. + +This is a relatively rare case, since it requires the following +conditions to be true: + +*) The metadata checksum feature must be enabled. +*) An inode needs to be relocated. +*) The inode needs to have an interior node. +*) The block for that interior node needs to be relocated. +*) None of blocks addressed by entries in that interior node needs + to be relocated. + +When all of these conditions are true, though, the file system is left +with corrupted with bad checksum for the extent tree block. + +Addresses-Launchpad-Bug: 1798562 + +Signed-off-by: Theodore Ts'o +Reported-by: Jean-Baptiste Lallement +--- + resize/resize2fs.c | 22 ++++++++++------------ + 1 file changed, 10 insertions(+), 12 deletions(-) + +Index: e2fsprogs-1.44.1/resize/resize2fs.c +=================================================================== +--- e2fsprogs-1.44.1.orig/resize/resize2fs.c ++++ e2fsprogs-1.44.1/resize/resize2fs.c +@@ -2242,31 +2242,20 @@ remap_blocks: + if (retval) + goto errout; + +- /* Rewrite extent block checksums with new inode number */ +- if (ext2fs_has_feature_metadata_csum(rfs->old_fs->super) && +- (inode->i_flags & EXT4_EXTENTS_FL)) { +- rfs->old_fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; +- retval = rewrite_extents(rfs->old_fs, new_inode); +- rfs->old_fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS; +- if (retval) +- goto errout; +- } +- + /* + * Update inodes to point to new blocks; schedule directory + * blocks for inode remapping. Need to write out dir blocks + * with new inode numbers if we have metadata_csum enabled. + */ ++ rfs->old_fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; + if (ext2fs_inode_has_valid_blocks2(rfs->old_fs, inode) && + (rfs->bmap || pb.is_dir)) { + pb.ino = new_inode; + pb.old_ino = ino; + pb.has_extents = inode->i_flags & EXT4_EXTENTS_FL; +- rfs->old_fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; + retval = ext2fs_block_iterate3(rfs->old_fs, + new_inode, 0, block_buf, + process_block, &pb); +- rfs->old_fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS; + if (retval) + goto errout; + if (pb.error) { +@@ -2281,6 +2270,14 @@ remap_blocks: + if (retval) + goto errout; + } ++ ++ /* Fix up extent block checksums with the new inode number */ ++ if (ext2fs_has_feature_metadata_csum(rfs->old_fs->super) && ++ (inode->i_flags & EXT4_EXTENTS_FL)) { ++ retval = rewrite_extents(rfs->old_fs, new_inode); ++ if (retval) ++ goto errout; ++ } + } + + if (update_ea_inode_refs && +@@ -2294,6 +2291,7 @@ remap_blocks: + + errout: + reset_com_err_hook(); ++ rfs->old_fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS; + if (rfs->bmap) { + ext2fs_free_extent_table(rfs->bmap); + rfs->bmap = 0; diff -Nru e2fsprogs-1.44.1/debian/patches/series e2fsprogs-1.44.1/debian/patches/series --- e2fsprogs-1.44.1/debian/patches/series 2018-12-11 18:39:38.000000000 +0000 +++ e2fsprogs-1.44.1/debian/patches/series 2019-01-24 23:08:59.000000000 +0000 @@ -1 +1,2 @@ 0001-libext2fs-fix-regression-so-we-are-correctly-transla.patch +0001-resize2fs-update-checksums-in-the-extent-tree-s-relo.patch