xfs: scrub inode nsec fields
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:41:35 +0000 (10:41 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:41:35 +0000 (10:41 -0800)
Check that the nanosecond fields in each timestamp aren't larger
than a billion.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/scrub/inode.c

index f120fb20452f493ecd6fd29bfa09732770f28015..2be4b259477aa89d110a2bb8cb0a4f44fb898553 100644 (file)
@@ -392,6 +392,14 @@ xfs_scrub_dinode(
                break;
        }
 
+       /* di_[amc]time.nsec */
+       if (be32_to_cpu(dip->di_atime.t_nsec) >= NSEC_PER_SEC)
+               xfs_scrub_ino_set_corrupt(sc, ino, bp);
+       if (be32_to_cpu(dip->di_mtime.t_nsec) >= NSEC_PER_SEC)
+               xfs_scrub_ino_set_corrupt(sc, ino, bp);
+       if (be32_to_cpu(dip->di_ctime.t_nsec) >= NSEC_PER_SEC)
+               xfs_scrub_ino_set_corrupt(sc, ino, bp);
+
        /*
         * di_size.  xfs_dinode_verify checks for things that screw up
         * the VFS such as the upper bit being set and zero-length
@@ -495,6 +503,8 @@ xfs_scrub_dinode(
        }
 
        if (dip->di_version >= 3) {
+               if (be32_to_cpu(dip->di_crtime.t_nsec) >= NSEC_PER_SEC)
+                       xfs_scrub_ino_set_corrupt(sc, ino, bp);
                xfs_scrub_inode_flags2(sc, bp, dip, ino, mode, flags, flags2);
                xfs_scrub_inode_cowextsize(sc, bp, dip, ino, mode, flags,
                                flags2);