Skip to content

Commit 4ff0b50

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: fix rogue rsrc node grabbing
We should not be looking at ctx->rsrc_node and anyhow modifying the node without holding uring_lock, grabbing references in such a way is not safe either. Cc: [email protected] Fixes: 5106dd6 ("io_uring: propagate issue_flags state down to file assignment") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/1202ede2d7bb90136e3482b2b84aad9ed483e5d6.1680098433.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 005308f commit 4ff0b50

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

io_uring/rsrc.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,13 @@ static inline void io_req_set_rsrc_node(struct io_kiocb *req,
144144
unsigned int issue_flags)
145145
{
146146
if (!req->rsrc_node) {
147-
req->rsrc_node = ctx->rsrc_node;
147+
io_ring_submit_lock(ctx, issue_flags);
148148

149-
if (!(issue_flags & IO_URING_F_UNLOCKED)) {
150-
lockdep_assert_held(&ctx->uring_lock);
149+
lockdep_assert_held(&ctx->uring_lock);
151150

152-
io_charge_rsrc_node(ctx);
153-
} else {
154-
percpu_ref_get(&req->rsrc_node->refs);
155-
}
151+
req->rsrc_node = ctx->rsrc_node;
152+
io_charge_rsrc_node(ctx);
153+
io_ring_submit_unlock(ctx, issue_flags);
156154
}
157155
}
158156

0 commit comments

Comments
 (0)