From: sashiko-bot@kernel.org
To: "Zhang Yi" <yi.zhang@huaweicloud.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v5 1/4] mm/truncate: align truncation boundaries to mapping minimum folio order
Date: Mon, 28 Sep 2026 12:31:35 +0000 [thread overview]
Message-ID: <20260928123136.2D6891F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928120833.3440834-2-yi.zhang@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] mm: integer overflow in round_up() during truncation causes complete file data loss
--
commit 583804d300760dcf60e3ec5aab6503a560ad3e7e
Author: Zhang Yi <yi.zhang@huawei.com>
mm/truncate: align truncation boundaries to mapping minimum folio order
When the mapping has a non-zero minimum folio order, this patch changes
folio_split() in truncate_inode_partial_folio() to stop at min_order instead
of order 0. It also aligns both start and end to the mapping minimum folio
order so they always fall on a folio boundary, preventing valid out-of-range
tails from being dropped.
Link: https://lore.kernel.org/linux-mm/CAJnrk1bQYUe6+1ryyJur5EEnZYrC+_5AYsy=OWzVRgD4202y1g@mail.gmail.com/
> diff --git a/mm/truncate.c b/mm/truncate.c
> index b58ba940be474..8a28f4a212677 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
[ ... ]
> @@ -395,6 +397,10 @@ void truncate_inode_pages_range(struct address_space *mapping,
> else
> end = (lend + 1) >> PAGE_SHIFT;
>
> + start = round_up(start, min_nrpages);
[Severity: Critical]
Could this round_up() result in an integer overflow that changes a very large
start index to 0 on 32-bit architectures?
When an unprivileged user issues fallocate(PUNCH_HOLE) or truncate at an offset
near ULONG_MAX << PAGE_SHIFT (e.g., 16TB on 32-bit systems) on a filesystem with
min_nrpages > 1 (like ext4 with large folio/iomap), start approaches
ULONG_MAX (e.g., 0xFFFFFFFF on 32-bit x86).
The macro round_up(start, min_nrpages) performs 32-bit arithmetic. With
start approaching 0xFFFFFFFF, start + min_nrpages - 1 can overflow to a value
less than min_nrpages, causing round_up to evaluate to 0.
This would corrupt the start index to 0 in truncate_inode_pages_range(), and
the subsequent loop would unintentionally truncate the entire page cache from
index 0 to end, causing complete data loss of unwritten data.
> + if (end != (pgoff_t)-1)
> + end = round_down(end, min_nrpages);
> +
> folio_batch_init(&fbatch);
> index = start;
> while (index < end && find_lock_entries(mapping, &index, end - 1,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928120833.3440834-1-yi.zhang@huaweicloud.com?part=1
next prev parent reply other threads:[~2026-09-28 12:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 12:08 [PATCH v5 0/4] mm/truncate: fix data loss when truncating straddling large folios Zhang Yi
2026-09-28 12:08 ` [PATCH v5 1/4] mm/truncate: align truncation boundaries to mapping minimum folio order Zhang Yi
2026-09-28 12:31 ` sashiko-bot [this message]
2026-09-28 12:46 ` Zhang Yi
2026-09-28 12:08 ` [PATCH v5 2/4] mm/truncate: look up the end-edge straddler by index Zhang Yi
2026-09-28 12:24 ` sashiko-bot
2026-09-28 12:08 ` [PATCH v5 3/4] mm/truncate: fix data loss when splitting straddling large folios fails Zhang Yi
2026-09-28 12:27 ` sashiko-bot
2026-09-28 12:08 ` [PATCH v5 4/4] mm/truncate: clarify return value of truncate_inode_partial_folio() Zhang Yi
2026-09-28 12:27 ` sashiko-bot
2026-09-28 21:49 ` [PATCH v5 0/4] mm/truncate: fix data loss when truncating straddling large folios Andrew Morton
2026-09-29 8:35 ` Zhang Yi
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=20260928123136.2D6891F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=yi.zhang@huaweicloud.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.