Skip to content

Commit 1e6907d

Browse files
committed
Merge tag 'io_uring-5.14-2021-08-20' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: "A few small fixes that should go into this release: - Fix never re-assigning an initial error value for io_uring_enter() for SQPOLL, if asked to do nothing - Fix xa_alloc_cycle() return value checking, for cases where we have wrapped around - Fix for a ctx pin issue introduced in this cycle (Pavel)" * tag 'io_uring-5.14-2021-08-20' of git://git.kernel.dk/linux-block: io_uring: fix xa_alloc_cycle() error return value check io_uring: pin ctx on fallback execution io_uring: only assign io_uring_enter() SQPOLL error in actual error case
2 parents fa54d36 + a30f895 commit 1e6907d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

fs/io_uring.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,8 +2477,10 @@ static void io_fallback_req_func(struct work_struct *work)
24772477
struct llist_node *node = llist_del_all(&ctx->fallback_llist);
24782478
struct io_kiocb *req, *tmp;
24792479

2480+
percpu_ref_get(&ctx->refs);
24802481
llist_for_each_entry_safe(req, tmp, node, io_task_work.fallback_node)
24812482
req->io_task_work.func(req);
2483+
percpu_ref_put(&ctx->refs);
24822484
}
24832485

24842486
static void __io_complete_rw(struct io_kiocb *req, long res, long res2,
@@ -9370,9 +9372,10 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
93709372
if (ctx->flags & IORING_SETUP_SQPOLL) {
93719373
io_cqring_overflow_flush(ctx, false);
93729374

9373-
ret = -EOWNERDEAD;
9374-
if (unlikely(ctx->sq_data->thread == NULL))
9375+
if (unlikely(ctx->sq_data->thread == NULL)) {
9376+
ret = -EOWNERDEAD;
93759377
goto out;
9378+
}
93769379
if (flags & IORING_ENTER_SQ_WAKEUP)
93779380
wake_up(&ctx->sq_data->wait);
93789381
if (flags & IORING_ENTER_SQ_WAIT) {
@@ -9840,10 +9843,11 @@ static int io_register_personality(struct io_ring_ctx *ctx)
98409843

98419844
ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,
98429845
XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
9843-
if (!ret)
9844-
return id;
9845-
put_cred(creds);
9846-
return ret;
9846+
if (ret < 0) {
9847+
put_cred(creds);
9848+
return ret;
9849+
}
9850+
return id;
98479851
}
98489852

98499853
static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,

0 commit comments

Comments
 (0)