io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring/kbuf: ensure ring ctx is held locked over io_put_kbuf()
@ 2025-08-20 23:16 Jens Axboe
  2025-08-21  0:31 ` Jens Axboe
  2025-08-21  6:54 ` [syzbot ci] " syzbot ci
  0 siblings, 2 replies; 3+ messages in thread
From: Jens Axboe @ 2025-08-20 23:16 UTC (permalink / raw)
  To: io-uring; +Cc: Pavel Begunkov

The issue_flags will tell us if this is needed or not, however a
previous commit was a bit too eager with the cleanups and removed the
required locking in case IO_URING_F_UNLOCKED is set in the issue_flags.

Cc: stable@vger.kernel.org
Fixes: e150e70fce42 ("io_uring/kbuf: open code __io_put_kbuf()")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/io_uring/kbuf.h b/io_uring/kbuf.h
index 723d0361898e..7f17e87d8617 100644
--- a/io_uring/kbuf.h
+++ b/io_uring/kbuf.h
@@ -4,6 +4,7 @@
 
 #include <uapi/linux/io_uring.h>
 #include <linux/io_uring_types.h>
+#include "io_uring.h"
 
 enum {
 	/* ring mapped provided buffers */
@@ -124,9 +125,14 @@ static inline bool io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
 static inline unsigned int io_put_kbuf(struct io_kiocb *req, int len,
 				       unsigned issue_flags)
 {
+	int ret;
+
 	if (!(req->flags & (REQ_F_BUFFER_RING | REQ_F_BUFFER_SELECTED)))
 		return 0;
-	return __io_put_kbufs(req, len, 1);
+	io_ring_submit_lock(req->ctx, issue_flags);
+	ret = __io_put_kbufs(req, len, 1);
+	io_ring_submit_unlock(req->ctx, issue_flags);
+	return ret;
 }
 
 static inline unsigned int io_put_kbufs(struct io_kiocb *req, int len,

-- 
Jens Axboe


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

end of thread, other threads:[~2025-08-21  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 23:16 [PATCH] io_uring/kbuf: ensure ring ctx is held locked over io_put_kbuf() Jens Axboe
2025-08-21  0:31 ` Jens Axboe
2025-08-21  6:54 ` [syzbot ci] " syzbot ci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).