diff options
author | Darrick J. Wong <djwong@kernel.org> | 2024-11-04 07:18:51 +0300 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2024-11-06 00:38:31 +0300 |
commit | 7297fd0bebbd70efd12f72632a0f3ac49a8f59fe (patch) | |
tree | 946cb411a3ef830bfb2145569288c00ba6ec7507 /fs/xfs/xfs_icache.c | |
parent | c555dd9b8c2d8f09ee31b17fc3ce059bacb4e359 (diff) | |
download | linux-7297fd0bebbd70efd12f72632a0f3ac49a8f59fe.tar.xz |
xfs: enforce metadata inode flag
Add checks for the metadata inode flag so that we don't ever leak
metadata inodes out to userspace, and we don't ever try to read a
regular inode as metadata.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_icache.c')
-rw-r--r-- | fs/xfs/xfs_icache.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index aa645e357812..48543bf0f5ce 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -834,7 +834,8 @@ out_error_or_again: /* * Get a metadata inode. * - * The metafile type must match the file mode exactly. + * The metafile type must match the file mode exactly, and for files in the + * metadata directory tree, it must match the inode's metatype exactly. */ int xfs_trans_metafile_iget( @@ -863,13 +864,20 @@ xfs_trans_metafile_iget( mode = S_IFREG; if (inode_wrong_type(VFS_I(ip), mode)) goto bad_rele; + if (xfs_has_metadir(mp)) { + if (!xfs_is_metadir_inode(ip)) + goto bad_rele; + if (metafile_type != ip->i_metatype) + goto bad_rele; + } *ipp = ip; return 0; bad_rele: xfs_irele(ip); whine: - xfs_err(mp, "metadata inode 0x%llx is corrupt", ino); + xfs_err(mp, "metadata inode 0x%llx type %u is corrupt", ino, + metafile_type); return -EFSCORRUPTED; } |