From: sashiko-bot@kernel.org
To: "Andrey Albershteyn" <aalbersh@kernel.org>,
linux-ext4 <linux-ext4@vger.kernel.org>,
"Eric Biggers" <ebiggers@kernel.org>,
"Christoph Hellwig" <hch@lst.de>,
"Carlos Maiolino" <cem@kernel.org>,
fsverity <fsverity@lists.linux.dev>
Cc: "Christian Brauner" <brauner@kernel.org>,
david@fromorbit.com, dsterba@suse.cz, tytso@mit.edu
Subject: Re: [PATCH v20 13/23] xfs: handle fsverity I/O in write/read path
Date: Wed, 02 Dec 2026 17:28:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-246325@kernel.org> (raw)
In-Reply-To: <20261202165653.767961-14-aalbersh@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] xfs: signed loff_t overflow in xfs_fsverity_metadata_offset()
--
commit 4a03a70110386ebb0ec2056edfff5268071a3316
Author: Andrey Albershteyn <aalbersh@kernel.org>
xfs: handle fsverity I/O in write/read path
This commit passes the mapping offset to xfs_bmbt_to_iomap() and sets
IOMAP_F_FSVERITY when the offset falls within the inode's fs-verity
metadata region.
> diff --git a/fs/xfs/libxfs/xfs_verity.c b/fs/xfs/libxfs/xfs_verity.c
> new file mode 100644
> index 0000000000000..c1731b89a5a12
> --- /dev/null
> +++ b/fs/xfs/libxfs/xfs_verity.c
> @@ -0,0 +1,20 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2026 Red Hat, Inc.
> + */
> +#include "xfs_platform.h"
> +#include "xfs_fs.h"
> +#include "xfs_shared.h"
> +#include "xfs_format.h"
> +#include "xfs_log_format.h"
> +#include "xfs_trans_resv.h"
> +#include "xfs_mount.h"
> +#include "xfs_inode.h"
> +#include "xfs_verity.h"
> +
> +loff_t
> +xfs_fsverity_metadata_offset(
> + const struct xfs_inode *ip)
> +{
> + return round_up(i_size_read(VFS_IC(ip)), XFS_FSVERITY_START_ALIGN);
> +}
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 50eae7ff61453..5117704530f69 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
[ ... ]
> @@ -54,6 +56,15 @@ xfs_alert_fsblock_zero(
> return -EFSCORRUPTED;
> }
>
> +static bool
> +xfs_iomap_is_fsverity_metadata(
> + struct xfs_inode *ip,
> + loff_t offset)
> +{
> + return offset >= xfs_fsverity_metadata_offset(ip) &&
> + (fsverity_is_building(VFS_I(ip)) || fsverity_active(VFS_I(ip)));
> +}
[Severity: Medium]
Can round_up() in xfs_fsverity_metadata_offset() overflow a signed 64-bit
loff_t and wrap to LLONG_MIN when i_size > LLONG_MAX -
(XFS_FSVERITY_START_ALIGN - 1)?
Because xfs_iomap_is_fsverity_metadata() calls
xfs_fsverity_metadata_offset() before checking fsverity_is_building() or
fsverity_active(), every non-xattr xfs_bmbt_to_iomap() call executes this
calculation even on non-verity files (which can be truncated up to
s_maxbytes == LLONG_MAX) and when CONFIG_FS_VERITY is disabled. In
addition, on a crafted or corrupted on-disk image where an
XFS_DIFLAG2_VERITY inode has di_size > 0x7fffffffffff0000, the wrap to
LLONG_MIN causes xfs_iomap_is_fsverity_metadata() to return true and set
IOMAP_F_FSVERITY for every non-negative file offset.
Checking fsverity_is_building() || fsverity_active() before calling
xfs_fsverity_metadata_offset(), and validating di_size against the maximum
fs-verity file size for XFS_DIFLAG2_VERITY inodes in xfs_dinode_verify(),
would avoid both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202165653.767961-1-aalbersh@kernel.org?part=13
next prev parent reply other threads:[~2026-12-02 17:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 16:56 [PATCH v20 00/23] fs-verity support for XFS with post EOF merkle tree Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 01/23] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 02/23] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 03/23] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 04/23] fs,fsverity: reject S_APPEND on fsverity inodes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 05/23] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
2026-12-02 17:09 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 06/23] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 07/23] ext4: " Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 08/23] f2fs: " Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 09/23] xfs: introduce fsverity on-disk changes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 10/23] xfs: don't allow to enable DAX on fs-verity sealed inode Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 11/23] xfs: disable direct read path for fs-verity files Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 12/23] xfs: don't report dio_mem_align and dio_offset_align for fsverity files Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 13/23] xfs: handle fsverity I/O in write/read path Andrey Albershteyn
2026-12-02 17:28 ` sashiko-bot [this message]
2026-12-02 16:56 ` [PATCH v20 14/23] xfs: use read ioend for fsverity data verification Andrey Albershteyn
2026-12-02 17:15 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 15/23] xfs: add XFS_BMAPI_UNWRITTEN to unmap unwritten extents in __xfs_bunmapi() Andrey Albershteyn
2026-12-02 17:09 ` sashiko-bot
2026-12-02 16:56 ` [PATCH v20 16/23] xfs: don't remove written extents past EOF on fsverity inodes Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 17/23] xfs: add fs-verity support Andrey Albershteyn
2026-12-02 17:49 ` [f2fs-dev] " sashiko-bot
2026-12-02 16:56 ` [PATCH v20 18/23] xfs: initialize fs-verity on file open Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 19/23] xfs: add fs-verity ioctls Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 20/23] xfs: advertise fs-verity being available on filesystem Andrey Albershteyn
2026-12-02 16:56 ` [PATCH v20 21/23] xfs: check and repair the verity inode flag state Andrey Albershteyn
2026-12-02 17:35 ` [f2fs-dev] " sashiko-bot
2026-12-02 16:56 ` [PATCH v20 22/23] xfs: introduce health state for corrupted fsverity metadata Andrey Albershteyn
2026-12-02 17:17 ` [f2fs-dev] " sashiko-bot
2026-12-02 16:56 ` [PATCH v20 23/23] xfs: enable ro-compat fs-verity flag Andrey Albershteyn
2026-12-02 17:17 ` [f2fs-dev] " sashiko-bot
2026-12-02 17:49 ` [PATCH v20 00/23] fs-verity support for XFS with post EOF merkle tree sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-246325@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aalbersh@kernel.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=david@fromorbit.com \
--cc=dsterba@suse.cz \
--cc=ebiggers@kernel.org \
--cc=fsverity@lists.linux.dev \
--cc=hch@lst.de \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox