Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Zhiling Zou <zhilinz@nebusec.ai>
Cc: linux-mm@kvack.org, baolin.wang@linux.alibaba.com,
	hughd@google.com, vega@nebusec.ai
Subject: Re: [PATCH v2 1/1] mm: shmem: reject page-aligned fallocate end overflow
Date: Wed, 29 Jul 2026 14:58:19 -0700	[thread overview]
Message-ID: <20260729145819.dfa35a91cd3d04b8f401d43a@linux-foundation.org> (raw)
In-Reply-To: <87a63846fe9873b1e26e8a7dcafcb21aa8d709fa.1785309651.git.zhilinz@nebusec.ai>

On Wed, 29 Jul 2026 22:07:30 +0800 Zhiling Zou <zhilinz@nebusec.ai> wrote:

> shmem_fallocate() validates offset + len with inode_newsize_ok(), but
> then rounds that end offset up to a page boundary before entering the
> preallocation loop.
> 
> For a valid request ending at MAX_LFS_FILESIZE, such as offset = 0 and
> len = LLONG_MAX, adding PAGE_SIZE - 1 to the validated end can overflow
> the signed loff_t used for the rounded end calculation. If that wrapped
> value is then converted into a page index, shmem_fallocate() can enter
> the folio allocation loop with an invalid range.
> 
> Cache the already validated end position, use check_add_overflow() when
> rounding it up to a page-aligned byte offset, and reuse the cached end
> for the later seal, shmem_get_folio(), and i_size checks.

Thanks.

AI review:
	https://sashiko.dev/#/patchset/87a63846fe9873b1e26e8a7dcafcb21aa8d709fa.1785309651.git.zhilinz@nebusec.ai

Suggests there's a flaw in your change.  And it does appear to have
found a significant pre-existing bug in there.  Can you please take a
look?



      reply	other threads:[~2026-07-29 21:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 14:07 [PATCH v2 1/1] mm: shmem: reject page-aligned fallocate end overflow Zhiling Zou
2026-07-29 21:58 ` Andrew Morton [this message]

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=20260729145819.dfa35a91cd3d04b8f401d43a@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=vega@nebusec.ai \
    --cc=zhilinz@nebusec.ai \
    /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