]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: complain about unwritten extents when they're not appropriate
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 28 Sep 2020 21:35:37 +0000 (17:35 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 28 Sep 2020 21:35:37 +0000 (17:35 -0400)
We don't allow unwritten extents in the attr fork, and we don't allow
them in the data fork except for regular files.  Check that this is the
case.

Found by manually fuzzing the extentflag field of an attr fork to one.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/dinode.c

index 716a77466ee438b38f92de7e17bf2009aa0db919..f25ff18596cd35e74775feb220775f96767c8852 100644 (file)
@@ -347,6 +347,28 @@ _("bmap rec out of order, inode %" PRIu64" entry %d "
                cp = irec.br_blockcount;
                sp = irec.br_startblock;
 
+               if (irec.br_state != XFS_EXT_NORM) {
+                       /* No unwritten extents in the attr fork */
+                       if (whichfork == XFS_ATTR_FORK) {
+                               do_warn(
+_("unwritten extent (off = %" PRIu64 ", fsbno = %" PRIu64 ") in ino %" PRIu64 " attr fork\n"),
+                                       irec.br_startoff,
+                                       irec.br_startblock,
+                                       ino);
+                               goto done;
+                       }
+
+                       /* No unwritten extents in non-regular files */
+                       if (type != XR_INO_DATA && type != XR_INO_RTDATA) {
+                               do_warn(
+_("unwritten extent (off = %" PRIu64 ", fsbno = %" PRIu64 ") in non-regular file ino %" PRIu64 "\n"),
+                                       irec.br_startoff,
+                                       irec.br_startblock,
+                                       ino);
+                               goto done;
+                       }
+               }
+
                /*
                 * check numeric validity of the extent
                 */