From: Hao Xu <haoxu@linux.alibaba.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, Pavel Begunkov <asml.silence@gmail.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: [PATCH for-5.15] io_uring: fix lacking of protection for compl_nr
Date: Sat, 21 Aug 2021 02:40:13 +0800 [thread overview]
Message-ID: <20210820184013.195812-1-haoxu@linux.alibaba.com> (raw)
coml_nr in ctx_flush_and_put() is not protected by uring_lock, this
may cause problems when accessing it parallelly.
Fixes: d10299e14aae ("io_uring: inline struct io_comp_state")
Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
---
fs/io_uring.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c755efdac71f..420f8dfa5327 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2003,11 +2003,10 @@ static void ctx_flush_and_put(struct io_ring_ctx *ctx)
{
if (!ctx)
return;
- if (ctx->submit_state.compl_nr) {
- mutex_lock(&ctx->uring_lock);
+ mutex_lock(&ctx->uring_lock);
+ if (ctx->submit_state.compl_nr)
io_submit_flush_completions(ctx);
- mutex_unlock(&ctx->uring_lock);
- }
+ mutex_unlock(&ctx->uring_lock);
percpu_ref_put(&ctx->refs);
}
--
2.24.4
next reply other threads:[~2021-08-20 18:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 18:40 Hao Xu [this message]
2021-08-20 18:59 ` [PATCH for-5.15] io_uring: fix lacking of protection for compl_nr Pavel Begunkov
2021-08-20 20:39 ` Hao Xu
2021-08-20 21:32 ` Pavel Begunkov
2021-08-20 22:07 ` Hao Xu
2021-08-20 22:09 ` Jens Axboe
2021-08-20 22:21 ` Hao Xu
2021-08-20 22:28 ` Pavel Begunkov
2021-08-20 22:30 ` Jens Axboe
2021-08-20 22:41 ` Pavel Begunkov
2021-08-20 22:46 ` Jens Axboe
2021-08-20 22:59 ` Pavel Begunkov
2021-08-21 3:10 ` Jens Axboe
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=20210820184013.195812-1-haoxu@linux.alibaba.com \
--to=haoxu@linux.alibaba.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=joseph.qi@linux.alibaba.com \
/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