Skip to content

Commit 255da9b

Browse files
committed
Merge tag 'io_uring-6.16-20250619' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe: - Two fixes for error injection failures. One fixes a task leak issue introduced in this merge window, the other an older issue with handling allocation of a mapped buffer. - Fix for a syzbot issue that triggers a kmalloc warning on attempting an allocation that's too large - Fix for an error injection failure causing a double put of a task, introduced in this merge window * tag 'io_uring-6.16-20250619' of git://git.kernel.dk/linux: io_uring: fix potential page leak in io_sqe_buffer_register() io_uring/sqpoll: don't put task_struct on tctx setup failure io_uring: remove duplicate io_uring_alloc_task_context() definition io_uring: fix task leak issue in io_wq_create() io_uring/rsrc: validate buffer count with offset for cloning
2 parents 5f2b6c5 + e1c7583 commit 255da9b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

io_uring/io-wq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,10 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
12591259
atomic_set(&wq->worker_refs, 1);
12601260
init_completion(&wq->worker_done);
12611261
ret = cpuhp_state_add_instance_nocalls(io_wq_online, &wq->cpuhp_node);
1262-
if (ret)
1262+
if (ret) {
1263+
put_task_struct(wq->task);
12631264
goto err;
1265+
}
12641266

12651267
return wq;
12661268
err:

io_uring/io_uring.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ struct llist_node *io_handle_tw_list(struct llist_node *node, unsigned int *coun
9898
struct llist_node *tctx_task_work_run(struct io_uring_task *tctx, unsigned int max_entries, unsigned int *count);
9999
void tctx_task_work(struct callback_head *cb);
100100
__cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd);
101-
int io_uring_alloc_task_context(struct task_struct *task,
102-
struct io_ring_ctx *ctx);
103101

104102
int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file,
105103
int start, int end);

io_uring/rsrc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,10 +809,8 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
809809

810810
imu->nr_bvecs = nr_pages;
811811
ret = io_buffer_account_pin(ctx, pages, nr_pages, imu, last_hpage);
812-
if (ret) {
813-
unpin_user_pages(pages, nr_pages);
812+
if (ret)
814813
goto done;
815-
}
816814

817815
size = iov->iov_len;
818816
/* store original address for later verification */
@@ -842,6 +840,8 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
842840
if (ret) {
843841
if (imu)
844842
io_free_imu(ctx, imu);
843+
if (pages)
844+
unpin_user_pages(pages, nr_pages);
845845
io_cache_free(&ctx->node_cache, node);
846846
node = ERR_PTR(ret);
847847
}
@@ -1177,6 +1177,8 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
11771177
return -EINVAL;
11781178
if (check_add_overflow(arg->nr, arg->dst_off, &nbufs))
11791179
return -EOVERFLOW;
1180+
if (nbufs > IORING_MAX_REG_BUFFERS)
1181+
return -EINVAL;
11801182

11811183
ret = io_rsrc_data_alloc(&data, max(nbufs, ctx->buf_table.nr));
11821184
if (ret)

io_uring/sqpoll.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <uapi/linux/io_uring.h>
1717

1818
#include "io_uring.h"
19+
#include "tctx.h"
1920
#include "napi.h"
2021
#include "sqpoll.h"
2122

@@ -419,7 +420,6 @@ void io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
419420
__cold int io_sq_offload_create(struct io_ring_ctx *ctx,
420421
struct io_uring_params *p)
421422
{
422-
struct task_struct *task_to_put = NULL;
423423
int ret;
424424

425425
/* Retain compatibility with failing for an invalid attach attempt */
@@ -498,7 +498,7 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
498498
rcu_assign_pointer(sqd->thread, tsk);
499499
mutex_unlock(&sqd->lock);
500500

501-
task_to_put = get_task_struct(tsk);
501+
get_task_struct(tsk);
502502
ret = io_uring_alloc_task_context(tsk, ctx);
503503
wake_up_new_task(tsk);
504504
if (ret)
@@ -513,8 +513,6 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
513513
complete(&ctx->sq_data->exited);
514514
err:
515515
io_sq_thread_finish(ctx);
516-
if (task_to_put)
517-
put_task_struct(task_to_put);
518516
return ret;
519517
}
520518

0 commit comments

Comments
 (0)