Skip to contentSkip to conversation

io_uring: Replace kzalloc() + copy_from_user() with memdup_user()

PATCH Applied Thorsten Blum 2 participants 2 messages Sep 5, 2025 – Sep 8, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: Replace kzalloc() + copy_from_user() with memdup_user()

Replace kzalloc() followed by copy_from_user() with memdup_user() to improve and simplify io_probe().

No functional changes intended.

---
 io_uring/register.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
io_uring/register.c +3 -7
index a59589249fce..306252f11475 100644
@@ -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;
Signature · 1 line
2.51.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Thorsten Blum

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,

Signature · 1 line
Jens Axboe