2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-29 23:53:55 +08:00

xfs: correct the narrative around misaligned rtinherit/extszinherit dirs

While auditing the realtime growfs code, I realized that the GROWFSRT
ioctl (and by extension xfs_growfs) has always allowed sysadmins to
change the realtime extent size when adding a realtime section to the
filesystem.  Since we also have always allowed sysadmins to set
RTINHERIT and EXTSZINHERIT on directories even if there is no realtime
device, this invalidates the premise laid out in the comments added in
commit 603f000b15.

In other words, this is not a case of inadequate metadata validation.
This is a case of nearly forgotten (and apparently untested) but
supported functionality.  Update the comments to reflect what we've
learned, and remove the log message about correcting the misalignment.

Fixes: 603f000b15 ("xfs: validate extsz hints against rt extent size when rtinherit is set")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Darrick J. Wong 2021-07-12 12:58:50 -07:00
parent 5838d0356b
commit 83193e5ebb
3 changed files with 24 additions and 22 deletions

View File

@ -592,23 +592,27 @@ xfs_inode_validate_extsize(
/* /*
* This comment describes a historic gap in this verifier function. * This comment describes a historic gap in this verifier function.
* *
* On older kernels, the extent size hint verifier doesn't check that * For a directory with both RTINHERIT and EXTSZINHERIT flags set, this
* the extent size hint is an integer multiple of the realtime extent * function has never checked that the extent size hint is an integer
* size on a directory with both RTINHERIT and EXTSZINHERIT flags set. * multiple of the realtime extent size. Since we allow users to set
* The verifier has always enforced the alignment rule for regular * this combination on non-rt filesystems /and/ to change the rt
* files with the REALTIME flag set. * extent size when adding a rt device to a filesystem, the net effect
* is that users can configure a filesystem anticipating one rt
* geometry and change their minds later. Directories do not use the
* extent size hint, so this is harmless for them.
* *
* If a directory with a misaligned extent size hint is allowed to * If a directory with a misaligned extent size hint is allowed to
* propagate that hint into a new regular realtime file, the result * propagate that hint into a new regular realtime file, the result
* is that the inode cluster buffer verifier will trigger a corruption * is that the inode cluster buffer verifier will trigger a corruption
* shutdown the next time it is run. * shutdown the next time it is run, because the verifier has always
* enforced the alignment rule for regular files.
* *
* Unfortunately, there could be filesystems with these misconfigured * Because we allow administrators to set a new rt extent size when
* directories in the wild, so we cannot add a check to this verifier * adding a rt section, we cannot add a check to this verifier because
* at this time because that will result a new source of directory * that will result a new source of directory corruption errors when
* corruption errors when reading an existing filesystem. Instead, we * reading an existing filesystem. Instead, we rely on callers to
* permit the misconfiguration to pass through the verifiers so that * decide when alignment checks are appropriate, and fix things up as
* callers of this function can correct and mitigate externally. * needed.
*/ */
if (rt_flag) if (rt_flag)

View File

@ -143,16 +143,14 @@ xfs_trans_log_inode(
} }
/* /*
* Inode verifiers on older kernels don't check that the extent size * Inode verifiers do not check that the extent size hint is an integer
* hint is an integer multiple of the rt extent size on a directory * multiple of the rt extent size on a directory with both rtinherit
* with both rtinherit and extszinherit flags set. If we're logging a * and extszinherit flags set. If we're logging a directory that is
* directory that is misconfigured in this way, clear the hint. * misconfigured in this way, clear the hint.
*/ */
if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) && if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
(ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) && (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) &&
(ip->i_extsize % ip->i_mount->m_sb.sb_rextsize) > 0) { (ip->i_extsize % ip->i_mount->m_sb.sb_rextsize) > 0) {
xfs_info_once(ip->i_mount,
"Correcting misaligned extent size hint in inode 0x%llx.", ip->i_ino);
ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |
XFS_DIFLAG_EXTSZINHERIT); XFS_DIFLAG_EXTSZINHERIT);
ip->i_extsize = 0; ip->i_extsize = 0;

View File

@ -1292,10 +1292,10 @@ xfs_ioctl_setattr_check_extsize(
new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags);
/* /*
* Inode verifiers on older kernels don't check that the extent size * Inode verifiers do not check that the extent size hint is an integer
* hint is an integer multiple of the rt extent size on a directory * multiple of the rt extent size on a directory with both rtinherit
* with both rtinherit and extszinherit flags set. Don't let sysadmins * and extszinherit flags set. Don't let sysadmins misconfigure
* misconfigure directories. * directories.
*/ */
if ((new_diflags & XFS_DIFLAG_RTINHERIT) && if ((new_diflags & XFS_DIFLAG_RTINHERIT) &&
(new_diflags & XFS_DIFLAG_EXTSZINHERIT)) { (new_diflags & XFS_DIFLAG_EXTSZINHERIT)) {