From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Subject: [PATCH] io_uring/kbuf: ensure ring ctx is held locked over io_put_kbuf()
Date: Wed, 20 Aug 2025 17:16:47 -0600 [thread overview]
Message-ID: <e2f14b20-2ad4-4e59-9966-26dd6aa70f31@kernel.dk> (raw)
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
next reply other threads:[~2025-08-20 23:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 23:16 Jens Axboe [this message]
2025-08-21 0:31 ` [PATCH] io_uring/kbuf: ensure ring ctx is held locked over io_put_kbuf() Jens Axboe
2025-08-21 6:54 ` [syzbot ci] " syzbot ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2f14b20-2ad4-4e59-9966-26dd6aa70f31@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox