]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 5 Sep 2025 10:18:17 +0000 (12:18 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Sep 2025 14:21:36 +0000 (08:21 -0600)
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>
io_uring/register.c

index 9c31a8afb83d2317ff525eadff60a0846c10709d..f4c76db276836b5fed5664de40e1065ff8fbe795 100644 (file)
@@ -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;