summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-09-05 12:18:17 +0200
committerJens Axboe <axboe@kernel.dk>2025-09-08 08:21:36 -0600
commit7b0604d77a41192316347618cce1d9c795613adb (patch)
tree8da5d6e14eba813acb1f5b965769515a66854d25
parent473efbc3ca29f725abfb7b323798df596ef41f3e (diff)
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. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/register.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/io_uring/register.c b/io_uring/register.c
index 9c31a8afb83d..f4c76db27683 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -47,13 +47,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;