]> Gentwo Git Trees - linux/.git/commitdiff
io_uring: convert params to pointer in ring reisze
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 12 Nov 2025 12:45:55 +0000 (12:45 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 14:27:34 +0000 (07:27 -0700)
The parameters in io_register_resize_rings() will be moved into another
structure in a later patch. In preparation to that, convert the params
variable it to a pointer, but still store the data on stack.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/register.c

index ec13ff876a389e9e1c6f47ed1628f87bd26ff73b..b5c2275d5cccaea1461cfa6d79de03d8d2b38090 100644 (file)
@@ -402,33 +402,33 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
        struct io_ring_ctx_rings o = { }, n = { }, *to_free = NULL;
        size_t size, sq_array_offset;
        unsigned i, tail, old_head;
-       struct io_uring_params p;
+       struct io_uring_params __p, *p = &__p;
        int ret;
 
        /* limited to DEFER_TASKRUN for now */
        if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
                return -EINVAL;
-       if (copy_from_user(&p, arg, sizeof(p)))
+       if (copy_from_user(p, arg, sizeof(*p)))
                return -EFAULT;
-       if (p.flags & ~RESIZE_FLAGS)
+       if (p->flags & ~RESIZE_FLAGS)
                return -EINVAL;
 
        /* properties that are always inherited */
-       p.flags |= (ctx->flags & COPY_FLAGS);
+       p->flags |= (ctx->flags & COPY_FLAGS);
 
-       ret = io_uring_fill_params(&p);
+       ret = io_uring_fill_params(p);
        if (unlikely(ret))
                return ret;
 
-       size = rings_size(p.flags, p.sq_entries, p.cq_entries,
+       size = rings_size(p->flags, p->sq_entries, p->cq_entries,
                                &sq_array_offset);
        if (size == SIZE_MAX)
                return -EOVERFLOW;
 
        memset(&rd, 0, sizeof(rd));
        rd.size = PAGE_ALIGN(size);
-       if (p.flags & IORING_SETUP_NO_MMAP) {
-               rd.user_addr = p.cq_off.user_addr;
+       if (p->flags & IORING_SETUP_NO_MMAP) {
+               rd.user_addr = p->cq_off.user_addr;
                rd.flags |= IORING_MEM_REGION_TYPE_USER;
        }
        ret = io_create_region(ctx, &n.ring_region, &rd, IORING_OFF_CQ_RING);
@@ -445,20 +445,20 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
         * intent... Use read/write once helpers from here on to indicate the
         * shared nature of it.
         */
-       WRITE_ONCE(n.rings->sq_ring_mask, p.sq_entries - 1);
-       WRITE_ONCE(n.rings->cq_ring_mask, p.cq_entries - 1);
-       WRITE_ONCE(n.rings->sq_ring_entries, p.sq_entries);
-       WRITE_ONCE(n.rings->cq_ring_entries, p.cq_entries);
+       WRITE_ONCE(n.rings->sq_ring_mask, p->sq_entries - 1);
+       WRITE_ONCE(n.rings->cq_ring_mask, p->cq_entries - 1);
+       WRITE_ONCE(n.rings->sq_ring_entries, p->sq_entries);
+       WRITE_ONCE(n.rings->cq_ring_entries, p->cq_entries);
 
-       if (copy_to_user(arg, &p, sizeof(p))) {
+       if (copy_to_user(arg, p, sizeof(*p))) {
                io_register_free_rings(ctx, &n);
                return -EFAULT;
        }
 
-       if (p.flags & IORING_SETUP_SQE128)
-               size = array_size(2 * sizeof(struct io_uring_sqe), p.sq_entries);
+       if (p->flags & IORING_SETUP_SQE128)
+               size = array_size(2 * sizeof(struct io_uring_sqe), p->sq_entries);
        else
-               size = array_size(sizeof(struct io_uring_sqe), p.sq_entries);
+               size = array_size(sizeof(struct io_uring_sqe), p->sq_entries);
        if (size == SIZE_MAX) {
                io_register_free_rings(ctx, &n);
                return -EOVERFLOW;
@@ -466,8 +466,8 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
 
        memset(&rd, 0, sizeof(rd));
        rd.size = PAGE_ALIGN(size);
-       if (p.flags & IORING_SETUP_NO_MMAP) {
-               rd.user_addr = p.sq_off.user_addr;
+       if (p->flags & IORING_SETUP_NO_MMAP) {
+               rd.user_addr = p->sq_off.user_addr;
                rd.flags |= IORING_MEM_REGION_TYPE_USER;
        }
        ret = io_create_region(ctx, &n.sq_region, &rd, IORING_OFF_SQES);
@@ -508,11 +508,11 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
         */
        tail = READ_ONCE(o.rings->sq.tail);
        old_head = READ_ONCE(o.rings->sq.head);
-       if (tail - old_head > p.sq_entries)
+       if (tail - old_head > p->sq_entries)
                goto overflow;
        for (i = old_head; i < tail; i++) {
                unsigned src_head = i & (ctx->sq_entries - 1);
-               unsigned dst_head = i & (p.sq_entries - 1);
+               unsigned dst_head = i & (p->sq_entries - 1);
 
                n.sq_sqes[dst_head] = o.sq_sqes[src_head];
        }
@@ -521,7 +521,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
 
        tail = READ_ONCE(o.rings->cq.tail);
        old_head = READ_ONCE(o.rings->cq.head);
-       if (tail - old_head > p.cq_entries) {
+       if (tail - old_head > p->cq_entries) {
 overflow:
                /* restore old rings, and return -EOVERFLOW via cleanup path */
                ctx->rings = o.rings;
@@ -532,7 +532,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
        }
        for (i = old_head; i < tail; i++) {
                unsigned src_head = i & (ctx->cq_entries - 1);
-               unsigned dst_head = i & (p.cq_entries - 1);
+               unsigned dst_head = i & (p->cq_entries - 1);
 
                n.rings->cqes[dst_head] = o.rings->cqes[src_head];
        }
@@ -550,8 +550,8 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
        if (!(ctx->flags & IORING_SETUP_NO_SQARRAY))
                ctx->sq_array = (u32 *)((char *)n.rings + sq_array_offset);
 
-       ctx->sq_entries = p.sq_entries;
-       ctx->cq_entries = p.cq_entries;
+       ctx->sq_entries = p->sq_entries;
+       ctx->cq_entries = p->cq_entries;
 
        ctx->rings = n.rings;
        ctx->sq_sqes = n.sq_sqes;