[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-v2ReHKyFIXQlKs@casper.infradead.org>
Date: Tue, 1 Apr 2025 15:20:53 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Sheng Yong <shengyong2021@...il.com>
Cc: akpm@...ux-foundation.org, vbabka@...e.cz, linux-kernel@...r.kernel.org,
linux-mm@...hiver.kernel.org, Sheng Yong <shengyong1@...omi.com>
Subject: Re: [PATCH] lib/iov_iter: fix to increase non slab folio refcount
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.
Powered by blists - more mailing lists