summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Albershteyn <aalbersh@kernel.org>2026-10-03 00:36:46 +0200
committerEric Biggers <ebiggers@kernel.org>2026-10-04 19:47:47 +0200
commit85cdd23fcae7fb71f4832b2a6f89db0ed121db28 (patch)
treee40a23461d3502fe27b95ac9d92527389dc960ed
parent9e74c01463f608d72f2da55d0ffe870f03edd124 (diff)
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>
-rw-r--r--fs/file_attr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/file_attr.c b/fs/file_attr.c
index bfb00d256dd5..391edd1d0ce3 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -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)