[PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()

Thorsten Blum posted 1 patch 4 days, 6 hours ago
io_uring/register.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
[PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
Posted by Thorsten Blum 4 days, 6 hours ago
Replace kzalloc() followed by copy_from_user() with memdup_user() to
improve and simplify io_probe().

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 io_uring/register.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/io_uring/register.c b/io_uring/register.c
index a59589249fce..306252f11475 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -46,13 +46,9 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,
 		nr_args = IORING_OP_LAST;
 
 	size = struct_size(p, ops, nr_args);
-	p = kzalloc(size, GFP_KERNEL);
-	if (!p)
-		return -ENOMEM;
-
-	ret = -EFAULT;
-	if (copy_from_user(p, arg, size))
-		goto out;
+	p = memdup_user(arg, size);
+	if (IS_ERR(p))
+		return PTR_ERR(p);
 	ret = -EINVAL;
 	if (memchr_inv(p, 0, size))
 		goto out;
-- 
2.51.0
Re: [PATCH] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
Posted by Jens Axboe 1 day, 2 hours ago
On Fri, 05 Sep 2025 12:18:17 +0200, Thorsten Blum wrote:
> Replace kzalloc() followed by copy_from_user() with memdup_user() to
> improve and simplify io_probe().
> 
> No functional changes intended.
> 
> 

Applied, thanks!

[1/1] io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
      commit: 7b0604d77a41192316347618cce1d9c795613adb

Best regards,
-- 
Jens Axboe