fsverity: don't allow setting DAX file attribute on fsverity files

When fsverity is enabled on the file, with FS_IOC_ENABLE_VERITY ioctl(),
it checks if file has DAX enabled and fails if that's true. However, the
opposite case is not checked.

Note, that the only other filesystem supporting DAX and fsverity is
ext4, and ext4 does check for this case.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Link: https://patch.msgid.link/20261002223705.2175542-6-aalbersh@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
Andrey Albershteyn 2026-10-03 00:36:46 +02:00 committed by Eric Biggers
parent 9e74c01463
commit 85cdd23fca

View File

@ -235,10 +235,15 @@ static int fileattr_set_prepare(struct inode *inode,
/*
* It is only valid to set the DAX flag on regular files and
* directories on filesystems.
*
* DAX and fsverity are incompatible.
*/
if ((fa->fsx_xflags & FS_XFLAG_DAX) &&
!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
return -EINVAL;
if (fa->fsx_xflags & FS_XFLAG_DAX) {
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
return -EINVAL;
if (old_ma->fsx_xflags & FS_XFLAG_VERITY)
return -EINVAL;
}
/* Extent size hints of zero turn off the flags. */
if (fa->fsx_extsize == 0)