From: Darrick J. Wong Date: Tue, 25 Oct 2016 01:46:51 +0000 (+1100) Subject: xfs: check for invalid inode reflink flags X-Git-Tag: v4.9.0-rc1~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=183537ed6ee2e2ca9fc8f364a213fd775edb1501;p=thirdparty%2Fxfsprogs-dev.git xfs: check for invalid inode reflink flags Source kernel commit: c8e156ac336d82f67d7adc014404a2251e9dad09 We don't support sharing blocks on the realtime device. Flag inodes with the reflink or cowextsize flags set when the reflink feature is disabled. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index beaa5299e..ed34eceba 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -384,6 +384,9 @@ xfs_dinode_verify( xfs_ino_t ino, struct xfs_dinode *dip) { + uint16_t flags; + uint64_t flags2; + if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) return false; @@ -400,6 +403,19 @@ xfs_dinode_verify( return false; if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid)) return false; + + flags = be16_to_cpu(dip->di_flags); + flags2 = be64_to_cpu(dip->di_flags2); + + /* don't allow reflink/cowextsize if we don't have reflink */ + if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) && + !xfs_sb_version_hasreflink(&mp->m_sb)) + return false; + + /* don't let reflink and realtime mix */ + if ((flags2 & XFS_DIFLAG2_REFLINK) && (flags & XFS_DIFLAG_REALTIME)) + return false; + return true; }