From: Dmitry Antipov <dmantipov@yandex.ru>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
lvc-project@linuxtesting.org,
Fedor Pchelkin <pchelkin@ispras.ru>
Subject: Re: [PATCH] lib: free pagelist on error in iov_iter_extract_pages()
Date: Tue, 12 May 2026 11:12:49 +0300 [thread overview]
Message-ID: <89db3b52508cfb345317feec8fe066849abccc14.camel@yandex.ru> (raw)
In-Reply-To: <CADUfDZpC5WOBY4_xvAy6ORtgQsxwFYj3Px81RdN7NKQZBFdJSQ@mail.gmail.com>
On Fri, 2026-05-08 at 11:33 -0700, Caleb Sander Mateos wrote:
> Indeed, it looks like *all* callers of iov_iter_extract_pages()
> pass a non-NULL struct page **.
This is not true for 6.12.x at least (where this issue was initially discovered)
where bio_map_user_iov() do the following:
...
while (iov_iter_count(iter)) {
struct page *stack_pages[UIO_FASTIOV];
struct page **pages = stack_pages;
ssize_t bytes;
size_t offs;
int npages;
if (nr_vecs > ARRAY_SIZE(stack_pages))
/* Stack pages aren't enough, so set 'pages' to NULL
and force allocation by want_pages_array(). */
pages = NULL;
bytes = iov_iter_extract_pages(iter, &pages, LONG_MAX,
nr_vecs, extraction_flags, &offs);
if (unlikely(bytes <= 0)) {
/* If 'pages' was allocated (and so pages != stack_pages), memory leak here */
ret = bytes ? bytes : -EFAULT;
goto out_unmap;
}
For 6.12.x and may be other stables, the simplest possible fix is
https://lore.kernel.org/stable/20260505094529.406783-1-dmantipov@yandex.ru/T/#u.
For upstream, it may be better to tweak iov_iter_extract_pages() itself, but
it may be required to adjust all of the callers.
Dmitry
next prev parent reply other threads:[~2026-05-12 8:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 11:13 [PATCH] lib: free pagelist on error in iov_iter_extract_pages() Dmitry Antipov
2026-05-08 18:33 ` Caleb Sander Mateos
2026-05-11 6:35 ` Christoph Hellwig
2026-05-12 8:12 ` Dmitry Antipov [this message]
2026-05-12 9:07 ` Fedor Pchelkin
2026-05-12 11:23 ` Dmitry Antipov
2026-05-08 21:48 ` Andrew Morton
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=89db3b52508cfb345317feec8fe066849abccc14.camel@yandex.ru \
--to=dmantipov@yandex.ru \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=pchelkin@ispras.ru \
/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