public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring/rsrc: fix rogue rsrc node grabbing
@ 2023-03-29 14:03 Pavel Begunkov
  2023-03-29 15:24 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2023-03-29 14:03 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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: 5106dd6e74ab6 ("io_uring: propagate issue_flags state down to file assignment")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/rsrc.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 2b8743645efc..f27f4975217d 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -144,15 +144,13 @@ static inline void io_req_set_rsrc_node(struct io_kiocb *req,
 					unsigned int issue_flags)
 {
 	if (!req->rsrc_node) {
-		req->rsrc_node = ctx->rsrc_node;
+		io_ring_submit_lock(ctx, issue_flags);
 
-		if (!(issue_flags & IO_URING_F_UNLOCKED)) {
-			lockdep_assert_held(&ctx->uring_lock);
+		lockdep_assert_held(&ctx->uring_lock);
 
-			io_charge_rsrc_node(ctx);
-		} else {
-			percpu_ref_get(&req->rsrc_node->refs);
-		}
+		req->rsrc_node = ctx->rsrc_node;
+		io_charge_rsrc_node(ctx);
+		io_ring_submit_unlock(ctx, issue_flags);
 	}
 }
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] io_uring/rsrc: fix rogue rsrc node grabbing
  2023-03-29 14:03 [PATCH 1/1] io_uring/rsrc: fix rogue rsrc node grabbing Pavel Begunkov
@ 2023-03-29 15:24 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-03-29 15:24 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov


On Wed, 29 Mar 2023 15:03:43 +0100, Pavel Begunkov wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] io_uring/rsrc: fix rogue rsrc node grabbing
      commit: 4ff0b50de8cabba055efe50bbcb7506c41a69835

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-29 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 14:03 [PATCH 1/1] io_uring/rsrc: fix rogue rsrc node grabbing Pavel Begunkov
2023-03-29 15:24 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox