• Darrick J. Wong's avatar
    xfs: validate extsz hints against rt extent size when rtinherit is set · 603f000b
    Darrick J. Wong authored
    The RTINHERIT bit can be set on a directory so that newly created
    regular files will have the REALTIME bit set to store their data on the
    realtime volume.  If an extent size hint (and EXTSZINHERIT) are set on
    the directory, the hint will also be copied into the new file.
    
    As pointed out in previous patches, for realtime files we require the
    extent size hint be an integer multiple of the realtime extent, but we
    don't perform the same validation on a directory with both RTINHERIT and
    EXTSZINHERIT set, even though the only use-case of that combination is
    to propagate extent size hints into new realtime files.  This leads to
    inode corruption errors when the bad values are propagated.
    
    Because there may be existing filesystems with such a configuration, we
    cannot simply amend the inode verifier to trip on these directories and
    call it a day because that will cause previously "working" filesystems
    to start throwing errors abruptly.  Note that it's valid to have
    directories with rtinherit set even if there is no realtime volume, in
    which case the problem does not manifest because rtinherit is ignored if
    there's no realtime device; and it's possible that someone set the flag,
    crashed, repaired the filesystem (which clears the hint on the realtime
    file) and continued.
    
    Therefore, mitigate this issue in several ways: First, if we try to
    write out an inode with both rtinherit/extszinherit set and an unaligned
    extent size hint, turn off the hint to correct the error.  Second, if
    someone tries to misconfigure a directory via the fssetxattr ioctl, fail
    the ioctl.  Third, reverify both extent size hint values when we
    propagate heritable inode attributes from parent to child, to prevent
    misconfigurations from spreading.
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    603f000b
xfs_trans_inode.c 6.7 KB