From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Cc: Andres Freund <andres@anarazel.de>
Subject: [PATCH] io_uring/rsrc: remove registered buffer 1GB limit
Date: Tue, 5 May 2026 01:39:01 -0600 [thread overview]
Message-ID: <6de5d329-9162-4992-85cb-f946f2d5c0b1@kernel.dk> (raw)
There's no real reason to have a limit, as the memory is accounted by
the lockmem limits anyway, if any exist. io_pin_pages() will still
restrict the maximum allowed limit per buffer, which is INT_MAX
number of pages. For a 4kb page size system, the limit is 8TB.
Reported-by: Andres Freund <andres@anarazel.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff --git a/io_uring/memmap.c b/io_uring/memmap.c
index 4f9b439319c4..74149b1cae5c 100644
--- a/io_uring/memmap.c
+++ b/io_uring/memmap.c
@@ -53,7 +53,7 @@ struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages)
nr_pages = end - start;
if (WARN_ON_ONCE(!nr_pages))
return ERR_PTR(-EINVAL);
- if (WARN_ON_ONCE(nr_pages > INT_MAX))
+ if (nr_pages > INT_MAX)
return ERR_PTR(-EOVERFLOW);
pages = kvmalloc_objs(struct page *, nr_pages, GFP_KERNEL_ACCOUNT);
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 650303626be6..0b85b35bfe08 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -88,8 +88,14 @@ int io_validate_user_buf_range(u64 uaddr, u64 ulen)
unsigned long tmp, base = (unsigned long)uaddr;
unsigned long acct_len = (unsigned long)PAGE_ALIGN(ulen);
- /* arbitrary limit, but we need something */
- if (ulen > SZ_1G || !ulen)
+ /*
+ * No specific buffer length limit outside of what io_pin_pages()
+ * limits us to.
+ */
+ if (!ulen)
+ return -EFAULT;
+ /* 32-bit sanity checking */
+ if (ulen > ULONG_MAX || uaddr > ULONG_MAX)
return -EFAULT;
if (check_add_overflow(base, acct_len, &tmp))
return -EOVERFLOW;
--
Jens Axboe
next reply other threads:[~2026-05-05 7:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 7:39 Jens Axboe [this message]
2026-05-05 10:09 ` [PATCH] io_uring/rsrc: remove registered buffer 1GB limit Jens Axboe
2026-05-05 13:23 ` Clément Léger
2026-05-05 13:26 ` Jens Axboe
2026-05-05 13:35 ` Clément Léger
2026-05-05 13:08 ` [syzbot ci] " syzbot ci
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=6de5d329-9162-4992-85cb-f946f2d5c0b1@kernel.dk \
--to=axboe@kernel.dk \
--cc=andres@anarazel.de \
--cc=io-uring@vger.kernel.org \
/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