Re: [PATCH 17/29] xfs: only allow the verity iflag for regular files

Andrey Albershteyn
2024-04-02T12:52:08Z

On 2024-03-29 17:40:30, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Only regular files can have fsverity enabled on them, so check this in
> the inode verifier.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
>
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index adc457da52ef0..dae0f27d3961b 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -695,6 +695,14 @@ xfs_dinode_verify(
> !xfs_has_rtreflink(mp))
> return __this_address;
>
> + /* only regular files can have fsverity */
> + if (flags2 & XFS_DIFLAG2_VERITY) {
> + if (!xfs_has_verity(mp))
> + return __this_address;
> + if ((mode & S_IFMT) != S_IFREG)
> + return __this_address;
> + }
> +
> /* COW extent size hint validation */
> fa = xfs_inode_validate_cowextsize(mp, be32_to_cpu(dip->di_cowextsize),
> mode, flags, flags2);
>

Looks good to me:
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>

--
- Andrey