From: "Darrick J. Wong" <djwong@kernel.org>
To: Marco Nelissen <marco.nelissen@gmail.com>
Cc: brauner@kernel.org, linux-xfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iomap: avoid avoid truncating 64-bit offset to 32 bits
Date: Wed, 8 Jan 2025 20:38:46 -0800 [thread overview]
Message-ID: <20250109043846.GJ1387004@frogsfrogsfrogs> (raw)
In-Reply-To: <20250109041253.2494374-1-marco.nelissen@gmail.com>
On Wed, Jan 08, 2025 at 08:11:50PM -0800, Marco Nelissen wrote:
> on 32-bit kernels, iomap_write_delalloc_scan() was inadvertently using a
> 32-bit position due to folio_next_index() returning an unsigned long.
> This could lead to an infinite loop when writing to an xfs filesystem.
>
> Signed-off-by: Marco Nelissen <marco.nelissen@gmail.com>
> ---
> fs/iomap/buffered-io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 54dc27d92781..d303e6c8900c 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1138,7 +1138,7 @@ static void iomap_write_delalloc_scan(struct inode *inode,
> start_byte, end_byte, iomap, punch);
>
> /* move offset to start of next folio in range */
> - start_byte = folio_next_index(folio) << PAGE_SHIFT;
> + start_byte = folio_pos(folio) + folio_size(folio);
eeek. Yeah, I guess that would happen towards the upper end of the 16T
range on 32-bit.
I wonder if perhaps pagemap.h should have:
static inline loff_t folio_next_pos(struct folio *folio)
{
return folio_pos(folio) + folio_size(folio);
}
But I think this is the only place in the kernel that uses this
construction? So maybe not worth the fuss.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> folio_unlock(folio);
> folio_put(folio);
> }
> --
> 2.39.5
>
next prev parent reply other threads:[~2025-01-09 4:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 4:11 [PATCH] iomap: avoid avoid truncating 64-bit offset to 32 bits Marco Nelissen
2025-01-09 4:38 ` Darrick J. Wong [this message]
2025-01-09 4:45 ` Marco Nelissen
2025-01-09 4:47 ` Darrick J. Wong
2025-01-09 6:10 ` Christoph Hellwig
2025-01-09 15:09 ` Christian Brauner
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=20250109043846.GJ1387004@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=marco.nelissen@gmail.com \
/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