aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-10-03 12:11:31 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2016-10-04 21:06:40 -0400
commit11715a21bc3035440b853a0334685f1a55ca8c3c (patch)
tree36e8e8f19aaa7fc813cb243509c625fd73027621
parentf0ec1b8ef11df0a51954df7e3ff3ca4aadb0d34b (diff)
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>
-rw-r--r--fs/xfs/libxfs/xfs_inode_fork.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index bbcc8c7a44b3..7699a033dd3c 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -121,6 +121,26 @@ xfs_iformat_fork(
121 return -EFSCORRUPTED; 121 return -EFSCORRUPTED;
122 } 122 }
123 123
124 if (unlikely(xfs_is_reflink_inode(ip) &&
125 (VFS_I(ip)->i_mode & S_IFMT) != S_IFREG)) {
126 xfs_warn(ip->i_mount,
127 "corrupt dinode %llu, wrong file type for reflink.",
128 ip->i_ino);
129 XFS_CORRUPTION_ERROR("xfs_iformat(reflink)",
130 XFS_ERRLEVEL_LOW, ip->i_mount, dip);
131 return -EFSCORRUPTED;
132 }
133
134 if (unlikely(xfs_is_reflink_inode(ip) &&
135 (ip->i_d.di_flags & XFS_DIFLAG_REALTIME))) {
136 xfs_warn(ip->i_mount,
137 "corrupt dinode %llu, has reflink+realtime flag set.",
138 ip->i_ino);
139 XFS_CORRUPTION_ERROR("xfs_iformat(reflink)",
140 XFS_ERRLEVEL_LOW, ip->i_mount, dip);
141 return -EFSCORRUPTED;
142 }
143
124 switch (VFS_I(ip)->i_mode & S_IFMT) { 144 switch (VFS_I(ip)->i_mode & S_IFMT) {
125 case S_IFIFO: 145 case S_IFIFO:
126 case S_IFCHR: 146 case S_IFCHR:
@@ -208,7 +228,8 @@ xfs_iformat_fork(
208 XFS_CORRUPTION_ERROR("xfs_iformat(8)", 228 XFS_CORRUPTION_ERROR("xfs_iformat(8)",
209 XFS_ERRLEVEL_LOW, 229 XFS_ERRLEVEL_LOW,
210 ip->i_mount, dip); 230 ip->i_mount, dip);
211 return -EFSCORRUPTED; 231 error = -EFSCORRUPTED;
232 break;
212 } 233 }
213 234
214 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); 235 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);