From: Matthew Wilcox <willy@infradead.org>
To: Sheng Yong <shengyong2021@gmail.com>
Cc: akpm@linux-foundation.org, vbabka@suse.cz,
linux-kernel@vger.kernel.org, linux-mm@archiver.kernel.org,
Sheng Yong <shengyong1@xiaomi.com>
Subject: Re: [PATCH] lib/iov_iter: fix to increase non slab folio refcount
Date: Tue, 1 Apr 2025 15:20:53 +0100 [thread overview]
Message-ID: <Z-v2ReHKyFIXQlKs@casper.infradead.org> (raw)
In-Reply-To: <20250401140255.1249264-1-shengyong1@xiaomi.com>
On Tue, Apr 01, 2025 at 10:02:55PM +0800, Sheng Yong wrote:
> When testing EROFS file-backed mount over v9fs on qemu, I encounter
> a folio UAF and page sanity check reports the following call trace.
> Fix it by increasing non slab folio refcount correctly.
This report needs to say what the problem _is_, which is that pages may
be coalesced across a folio boundary.
> +++ b/lib/iov_iter.c
> @@ -1191,8 +1191,7 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i,
> return -ENOMEM;
> p = *pages;
> for (int k = 0; k < n; k++) {
> - struct folio *folio = page_folio(page);
> - p[k] = page + k;
> + struct folio *folio = page_folio(p[k] = page + k);
Never write code this ugly.
- struct folio *folio = page_folio(page);
+ struct folio *folio = page_folio(page + k);
p[k] = page + k;
is much more readable.
next prev parent reply other threads:[~2025-04-01 14:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 14:02 [PATCH] lib/iov_iter: fix to increase non slab folio refcount Sheng Yong
2025-04-01 14:20 ` Matthew Wilcox [this message]
2025-04-04 8:40 ` Christoph Hellwig
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=Z-v2ReHKyFIXQlKs@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@archiver.kernel.org \
--cc=shengyong1@xiaomi.com \
--cc=shengyong2021@gmail.com \
--cc=vbabka@suse.cz \
/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