mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-19 05:24:11 +00:00
xfs: don't allow reflinked dir/dev/fifo/socket/pipe files
Only non-rt files can be reflinked, so check that when we load an inode. Also, don't leak the attr fork if there's a failure. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
f0ec1b8ef1
commit
11715a21bc
1 changed files with 22 additions and 1 deletions
|
@ -121,6 +121,26 @@ xfs_iformat_fork(
|
||||||
return -EFSCORRUPTED;
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unlikely(xfs_is_reflink_inode(ip) &&
|
||||||
|
(VFS_I(ip)->i_mode & S_IFMT) != S_IFREG)) {
|
||||||
|
xfs_warn(ip->i_mount,
|
||||||
|
"corrupt dinode %llu, wrong file type for reflink.",
|
||||||
|
ip->i_ino);
|
||||||
|
XFS_CORRUPTION_ERROR("xfs_iformat(reflink)",
|
||||||
|
XFS_ERRLEVEL_LOW, ip->i_mount, dip);
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(xfs_is_reflink_inode(ip) &&
|
||||||
|
(ip->i_d.di_flags & XFS_DIFLAG_REALTIME))) {
|
||||||
|
xfs_warn(ip->i_mount,
|
||||||
|
"corrupt dinode %llu, has reflink+realtime flag set.",
|
||||||
|
ip->i_ino);
|
||||||
|
XFS_CORRUPTION_ERROR("xfs_iformat(reflink)",
|
||||||
|
XFS_ERRLEVEL_LOW, ip->i_mount, dip);
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
switch (VFS_I(ip)->i_mode & S_IFMT) {
|
switch (VFS_I(ip)->i_mode & S_IFMT) {
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
|
@ -208,7 +228,8 @@ xfs_iformat_fork(
|
||||||
XFS_CORRUPTION_ERROR("xfs_iformat(8)",
|
XFS_CORRUPTION_ERROR("xfs_iformat(8)",
|
||||||
XFS_ERRLEVEL_LOW,
|
XFS_ERRLEVEL_LOW,
|
||||||
ip->i_mount, dip);
|
ip->i_mount, dip);
|
||||||
return -EFSCORRUPTED;
|
error = -EFSCORRUPTED;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
|
error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
|
||||||
|
|
Loading…
Add table
Reference in a new issue