The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] io_uring/rsrc: bound io_coalesce_buffer() page array allocation
@ 2026-06-30  7:10 Yi Xie
  2026-07-01 10:32 ` Gabriel Krisman Bertazi
  0 siblings, 1 reply; 2+ messages in thread
From: Yi Xie @ 2026-06-30  7:10 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, linux-kernel, Yi Xie

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>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-01 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox