All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhang Yi" <yi.zhang@huaweicloud.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v4 1/4] mm/truncate: align truncation boundaries to mapping minimum folio order
Date: Tue, 22 Sep 2026 11:27:08 +0000	[thread overview]
Message-ID: <20260922112709.1319E1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260922110703.468389-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 truncate_inode_pages_range causing data loss
--

commit e346e0885d48b84feb918a7c5125a3b206d6bba7
Author: Zhang Yi <yi.zhang@huawei.com>

mm/truncate: align truncation boundaries to mapping minimum folio order

This commit aligns the start and end truncation boundaries to the minimum
folio order of the mapping. This prevents valid out-of-range tail sub-folios
from being incorrectly discarded when a mapping has a non-zero min_order.

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..f9625bb4916f9 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
[ ... ]
> @@ -374,14 +376,14 @@ void truncate_inode_pages_range(struct address_space *mapping,
[ ... ]
>  	start = (lstart + PAGE_SIZE - 1) >> PAGE_SHIFT;
[ ... ]
>  	else
>  		end = (lend + 1) >> PAGE_SHIFT;
>  
> +	start = round_up(start, min_nrpages);

[Severity: Critical]
Can this integer overflow on 32-bit architectures?

In truncate_inode_pages_range(), pgoff_t is a 32-bit integer on 32-bit
systems. If a hole punch or truncate operation occurs at an offset near
MAX_LFS_FILESIZE, the start page index will be close to 0xFFFFFFFF.

When min_nrpages > 1 (e.g., on filesystems supporting min_order > 0 like
Ext4 with bigalloc), rounding up this index wraps it to 0. 

Would this wrap-around cause the entire page cache for the file to be
truncated instead of just the intended tail, leading to data loss?

> +	if (end != (pgoff_t)-1)
> +		end = round_down(end, min_nrpages);
> +
>  	folio_batch_init(&fbatch);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922110703.468389-1-yi.zhang@huaweicloud.com?part=1

  reply	other threads:[~2026-09-22 11:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 11:06 [PATCH v4 0/4] mm/truncate: fix data loss when truncating straddling large folios Zhang Yi
2026-09-22 11:07 ` [PATCH v4 1/4] mm/truncate: align truncation boundaries to mapping minimum folio order Zhang Yi
2026-09-22 11:27   ` sashiko-bot [this message]
2026-09-22 11:32   ` Jan Kara
2026-09-22 15:29   ` Zi Yan
2026-09-23  8:26     ` Zhang Yi
2026-09-24  9:31   ` Zhang Yi
2026-09-24 10:31     ` Jan Kara
2026-09-22 11:07 ` [PATCH v4 2/4] mm/truncate: look up the end-edge straddler by index Zhang Yi
2026-09-22 11:23   ` sashiko-bot
2026-09-22 11:35   ` Jan Kara
2026-09-22 15:30   ` Zi Yan
2026-09-22 11:07 ` [PATCH v4 3/4] mm/truncate: fix data loss when splitting straddling large folios fails Zhang Yi
2026-09-22 11:23   ` sashiko-bot
2026-09-22 11:44   ` Jan Kara
2026-09-22 16:58   ` Zi Yan
2026-09-22 17:27   ` Zi Yan
2026-09-23  8:29     ` Zhang Yi
2026-09-22 11:07 ` [PATCH v4 4/4] mm/truncate: clarify return value of truncate_inode_partial_folio() Zhang Yi
2026-09-22 11:29   ` sashiko-bot
2026-09-22 11:58   ` Jan Kara
2026-09-23 13:29     ` Zhang Yi
2026-09-22 17:28   ` Zi Yan
2026-09-22 13:47 ` [PATCH v4 0/4] mm/truncate: fix data loss when truncating straddling large folios Brian Foster
2026-09-23 13:31   ` 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=20260922112709.1319E1F00898@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.