summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_format.h
diff options
context:
space:
mode:
authorDave Chinner2018-06-22 08:25:57 +0200
committerDarrick J. Wong2018-06-22 08:25:57 +0200
commit23fcb3340d033d9f081e21e6c12c2db7eaa541d3 (patch)
tree169cc8eaec84806931df8382491cad85d57de876 /fs/xfs/libxfs/xfs_format.h
parentxfs: simplify xfs_bmap_punch_delalloc_range (diff)
downloadkernel-qcow2-linux-23fcb3340d033d9f081e21e6c12c2db7eaa541d3.tar.gz
kernel-qcow2-linux-23fcb3340d033d9f081e21e6c12c2db7eaa541d3.tar.xz
kernel-qcow2-linux-23fcb3340d033d9f081e21e6c12c2db7eaa541d3.zip
xfs: More robust inode extent count validation
When the inode is in extent format, it can't have more extents that fit in the inode fork. We don't currenty check this, and so this corruption goes unnoticed by the inode verifiers. This can lead to crashes operating on invalid in-memory structures. Attempts to access such a inode will now error out in the verifier rather than allowing modification operations to proceed. Reported-by: Wen Xu <wen.xu@gatech.edu> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> [darrick: fix a typedef, add some braces and breaks to shut up compiler warnings] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_format.h')
-rw-r--r--fs/xfs/libxfs/xfs_format.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 1c5a8aaf2bfc..7b4a43deb83e 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -962,6 +962,9 @@ typedef enum xfs_dinode_fmt {
XFS_DFORK_DSIZE(dip, mp) : \
XFS_DFORK_ASIZE(dip, mp))
+#define XFS_DFORK_MAXEXT(dip, mp, w) \
+ (XFS_DFORK_SIZE(dip, mp, w) / sizeof(struct xfs_bmbt_rec))
+
/*
* Return pointers to the data or attribute forks.
*/