Skip to content

Commit 3853b5e

Browse files
author
Darrick J. Wong
committed
xfs: don't move nondir/nonreg temporary repair files to the metadir namespace
Only directories or regular files are allowed in the metadata directory tree. Don't move the repair tempfile to the metadir namespace if this is not true; this will cause the inode verifiers to trip. xrep_tempfile_adjust_directory_tree opportunistically moves sc->tempip from the regular directory tree to the metadata directory tree if sc->ip is part of the metadata directory tree. However, the scrub setup functions grab sc->ip and create sc->tempip before we actually get around to checking if the file mode is the right type for the scrubber. IOWs, you can invoke the symlink scrubber with the file handle of a subdirectory in the metadir. xrep_setup_symlink will create a temporary symlink file, xrep_tempfile_adjust_directory_tree will foolishly try to set the METADATA flag on the temp symlink, which trips the inode verifier in the inode item precommit, which shuts down the filesystem when expensive checks are turned on. If they're /not/ turned on, then xchk_symlink will return ENOENT when it sees that it's been passed a symlink, but the invalid inode could still get flushed to disk. We don't want that. Cc: <[email protected]> # v6.13-rc1 Fixes: 9dc31ac ("xfs: move repair temporary files to the metadata directory tree") Signed-off-by: "Darrick J. Wong" <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 7f8a44f commit 3853b5e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

fs/xfs/scrub/tempfile.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,18 @@ xrep_tempfile_create(
184184
}
185185

186186
/*
187+
* Move sc->tempip from the regular directory tree to the metadata directory
188+
* tree if sc->ip is part of the metadata directory tree and tempip has an
189+
* eligible file mode.
190+
*
187191
* Temporary files have to be created before we even know which inode we're
188192
* going to scrub, so we assume that they will be part of the regular directory
189193
* tree. If it turns out that we're actually scrubbing a file from the
190194
* metadata directory tree, we have to subtract the temp file from the root
191-
* dquots and detach the dquots.
195+
* dquots and detach the dquots prior to setting the METADATA iflag. However,
196+
* the scrub setup functions grab sc->ip and create sc->tempip before we
197+
* actually get around to checking if the file mode is the right type for the
198+
* scrubber.
192199
*/
193200
int
194201
xrep_tempfile_adjust_directory_tree(
@@ -204,6 +211,9 @@ xrep_tempfile_adjust_directory_tree(
204211

205212
if (!sc->ip || !xfs_is_metadir_inode(sc->ip))
206213
return 0;
214+
if (!S_ISDIR(VFS_I(sc->tempip)->i_mode) &&
215+
!S_ISREG(VFS_I(sc->tempip)->i_mode))
216+
return 0;
207217

208218
xfs_ilock(sc->tempip, XFS_IOLOCK_EXCL);
209219
sc->temp_ilock_flags |= XFS_IOLOCK_EXCL;

0 commit comments

Comments
 (0)