[SRU][B/X][CVE-2018-10322][PATCH v2 4/4] xfs: enhance dinode verifier
William Breathitt Gray
william.gray at canonical.com
Wed Sep 2 19:41:39 UTC 2020
From: Eric Sandeen <sandeen at sandeen.net>
Add several more validations to xfs_dinode_verify:
- For LOCAL data fork formats, di_nextents must be 0.
- For LOCAL attr fork formats, di_anextents must be 0.
- For inodes with no attr fork offset,
- format must be XFS_DINODE_FMT_EXTENTS if set at all
- di_anextents must be 0.
Thanks to dchinner for pointing out a couple related checks I had
forgotten to add.
Signed-off-by: Eric Sandeen <sandeen at redhat.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199377
Reviewed-by: Darrick J. Wong <darrick.wong at oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com>
CVE-2018-10322
(backported from commit b42db0860e13067fcc7cbfba3966c9e652668bbc)
[ vilhelmgray: context adjustments ]
Signed-off-by: William Breathitt Gray <william.gray at canonical.com>
---
fs/xfs/libxfs/xfs_inode_buf.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 936a72e420b1..a03b9c02d09c 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -349,6 +349,8 @@ xfs_dinode_verify(
return false;
if (di_size > XFS_DFORK_DSIZE(dip, mp))
return false;
+ if (dip->di_nextents)
+ return false;
/* fall through */
case XFS_DINODE_FMT_EXTENTS:
case XFS_DINODE_FMT_BTREE:
@@ -367,12 +369,31 @@ xfs_dinode_verify(
if (XFS_DFORK_Q(dip)) {
switch (dip->di_aformat) {
case XFS_DINODE_FMT_LOCAL:
+ if (dip->di_anextents)
+ return false;
+ /* fall through */
case XFS_DINODE_FMT_EXTENTS:
case XFS_DINODE_FMT_BTREE:
break;
default:
return false;
}
+ } else {
+ /*
+ * If there is no fork offset, this may be a freshly-made inode
+ * in a new disk cluster, in which case di_aformat is zeroed.
+ * Otherwise, such an inode must be in EXTENTS format; this goes
+ * for freed inodes as well.
+ */
+ switch (dip->di_aformat) {
+ case 0:
+ case XFS_DINODE_FMT_EXTENTS:
+ break;
+ default:
+ return false;
+ }
+ if (dip->di_anextents)
+ return false;
}
/* only version 3 or greater inodes are extensively verified here */
--
2.25.1
More information about the kernel-team
mailing list