From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Yi Xie <xieyi@kylinos.cn>, axboe@kernel.dk
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
Yi Xie <xieyi@kylinos.cn>
Subject: Re: [PATCH] io_uring/rsrc: bound io_coalesce_buffer() page array allocation
Date: Wed, 01 Jul 2026 06:32:34 -0400 [thread overview]
Message-ID: <87cxx757b1.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260630071017.100436-1-xieyi@kylinos.cn>
Yi Xie <xieyi@kylinos.cn> writes:
> kvmalloc_objs() in io_coalesce_buffer() does not check for size overflow
> when nr_folios is large. Mirror the check used in memmap.c before
> allocating the page pointer array.
>
> Signed-off-by: Yi Xie <xieyi@kylinos.cn>
Resending from yesterday as changing MUA is never harmless...
I don't think this can happen.
nr_folios comes from nr_pages in io_check_coalesce_buffer, and must be
less or equal to it. But nr_pages is already checked in io_pin_pages,
introduced by:
https://lore.kernel.org/io-uring/178216289049.99876.2987989144128669864.b4-ty@b4/T/#t
> ---
> io_uring/rsrc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index 8d0f2ee24e0c..f1f8d6dd102c 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -776,6 +776,8 @@ static bool io_coalesce_buffer(struct page ***pages, int *nr_pages,
> unsigned i, j;
>
> /* Store head pages only*/
> + if (nr_folios > INT_MAX / sizeof(struct page *))
> + return false;
> new_array = kvmalloc_objs(struct page *, nr_folios);
> if (!new_array)
> return false;
> --
> 2.25.1
>
--
Gabriel Krisman Bertazi
prev parent reply other threads:[~2026-07-01 10:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 7:10 [PATCH] io_uring/rsrc: bound io_coalesce_buffer() page array allocation Yi Xie
2026-07-01 10:32 ` Gabriel Krisman Bertazi [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=87cxx757b1.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xieyi@kylinos.cn \
/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