Skip to content

Commit ac3cb72

Browse files
committed
Merge tag 'io_uring-6.10-20240614' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe: "Two fixes from Pavel headed to stable: - Ensure that the task state is correct before attempting to grab a mutex - Split cancel sequence flag into a separate variable, as it can get set by someone not owning the request (but holding the ctx lock)" * tag 'io_uring-6.10-20240614' of git://git.kernel.dk/linux: io_uring: fix cancellation overwriting req->flags io_uring/rsrc: don't lock while !TASK_RUNNING
2 parents 0b320c8 + f4a1254 commit ac3cb72

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

include/linux/io_uring_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ struct io_kiocb {
648648
struct io_rsrc_node *rsrc_node;
649649

650650
atomic_t refs;
651-
atomic_t poll_refs;
651+
bool cancel_seq_set;
652652
struct io_task_work io_task_work;
653653
/* for polled requests, i.e. IORING_OP_POLL_ADD and async armed poll */
654654
struct hlist_node hash_node;
@@ -657,6 +657,7 @@ struct io_kiocb {
657657
/* opcode allocated if it needs to store data for async defer */
658658
void *async_data;
659659
/* linked requests, IFF REQ_F_HARDLINK or REQ_F_LINK are set */
660+
atomic_t poll_refs;
660661
struct io_kiocb *link;
661662
/* custom credentials, valid IFF REQ_F_CREDS is set */
662663
const struct cred *creds;

io_uring/cancel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd);
2727

2828
static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
2929
{
30-
if ((req->flags & REQ_F_CANCEL_SEQ) && sequence == req->work.cancel_seq)
30+
if (req->cancel_seq_set && sequence == req->work.cancel_seq)
3131
return true;
3232

33-
req->flags |= REQ_F_CANCEL_SEQ;
33+
req->cancel_seq_set = true;
3434
req->work.cancel_seq = sequence;
3535
return false;
3636
}

io_uring/io_uring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
20582058
req->file = NULL;
20592059
req->rsrc_node = NULL;
20602060
req->task = current;
2061+
req->cancel_seq_set = false;
20612062

20622063
if (unlikely(opcode >= IORING_OP_LAST)) {
20632064
req->opcode = 0;

io_uring/rsrc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
249249

250250
ret = io_run_task_work_sig(ctx);
251251
if (ret < 0) {
252+
__set_current_state(TASK_RUNNING);
252253
mutex_lock(&ctx->uring_lock);
253254
if (list_empty(&ctx->rsrc_ref_list))
254255
ret = 0;

0 commit comments

Comments
 (0)