From: Jens Axboe <[email protected]>
To: Xiaoguang Wang <[email protected]>,
[email protected]
Cc: [email protected], [email protected]
Subject: Re: [PATCH] io_uring: fix possible race condition against REQ_F_NEED_CLEANUP
Date: Thu, 18 Jun 2020 08:32:42 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 6/18/20 1:01 AM, Xiaoguang Wang wrote:
> In io_read() or io_write(), when io request is submitted successfully,
> it'll go through below codes:
> kfree(iovec);
> req->flags &= ~REQ_F_NEED_CLEANUP;
> return ret;
>
> But indeed the "req->flags &= ~REQ_F_NEED_CLEANUP;" maybe dangerous,
> io request may already have been completed, then io_complete_rw_iopoll()
> and io_complete_rw() will be called, both of them will also modify
> req->flags if needed, race condition will occur, concurrent modifaction
> will happen, which is neither protected by locks nor atomic operations.
>
> To eliminate this race, in io_read() or io_write(), if io request is
> submitted successfully, we don't remove REQ_F_NEED_CLEANUP flag. If
> REQ_F_NEED_CLEANUP is set, we'll leave __io_req_aux_free() to the
> iovec cleanup work correspondingly.
Thanks, good catch!
--
Jens Axboe
prev parent reply other threads:[~2020-06-18 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 7:01 [PATCH] io_uring: fix possible race condition against REQ_F_NEED_CLEANUP Xiaoguang Wang
2020-06-18 14:32 ` Jens Axboe [this message]
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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