public inbox for [email protected]
 help / color / mirror / Atom feed
From: Keith Busch <[email protected]>
To: Ming Lei <[email protected]>
Cc: Keith Busch <[email protected]>,
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected]
Subject: Re: [PATCHv2 4/6] ublk: zc register/unregister bvec
Date: Wed, 12 Feb 2025 07:59:44 -0700	[thread overview]
Message-ID: <Z6y3YNX4-Ln2tjyX@kbusch-mbp> (raw)
In-Reply-To: <Z6xo0mhJDRa0eaxv@fedora>

On Wed, Feb 12, 2025 at 05:24:34PM +0800, Ming Lei wrote:
> On Tue, Feb 11, 2025 at 09:11:10PM -0700, Keith Busch wrote:
> 
> However, it still may cause use-after-free on this request which has
> been failed from io_uring_try_cancel_uring_cmd(), and please see the
> following code path:
> 
> io_uring_try_cancel_requests
> 	io_uring_try_cancel_uring_cmd
> 		ublk_uring_cmd_cancel_fn
> 			ublk_abort_requests
> 				ublk_abort_queue
> 					__ublk_fail_req
> 						ublk_put_req_ref
> 
> The above race needs to be covered.

This race is covered. The ublk request has one reference taken when it
notifies userspace, then a second reference taken when user registers
the bvec.

The first reference is dropped from the abort, but the request won't be
completed because the second reference prevents that. That second
request reference can't be dropped until the ->release callback happens,
and that can't happen until two conditions are met:

  The bvec is unregistered
  All IO using the index completes

I think all the bases are covered here.

  reply	other threads:[~2025-02-12 14:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11  0:56 [PATCHv2 0/6] ublk zero-copy support Keith Busch
2025-02-11  0:56 ` [PATCHv2 1/6] io_uring: use node for import Keith Busch
2025-02-11  0:56 ` [PATCHv2 2/6] io_uring: create resource release callback Keith Busch
2025-02-13  1:31   ` Pavel Begunkov
2025-02-13  1:58     ` Keith Busch
2025-02-13 13:06       ` Pavel Begunkov
2025-02-11  0:56 ` [PATCHv2 3/6] io_uring: add support for kernel registered bvecs Keith Busch
2025-02-13  1:33   ` Pavel Begunkov
2025-02-14  3:30   ` Ming Lei
2025-02-14 15:26     ` Keith Busch
2025-02-15  1:34       ` Ming Lei
2025-02-18 20:34         ` Keith Busch
2025-02-11  0:56 ` [PATCHv2 4/6] ublk: zc register/unregister bvec Keith Busch
2025-02-12  2:49   ` Ming Lei
2025-02-12  4:11     ` Keith Busch
2025-02-12  9:24       ` Ming Lei
2025-02-12 14:59         ` Keith Busch [this message]
2025-02-13  2:12   ` Pavel Begunkov
2025-02-11  0:56 ` [PATCHv2 5/6] io_uring: add abstraction for buf_table rsrc data Keith Busch
2025-02-11  0:56 ` [PATCHv2 6/6] io_uring: cache nodes and mapped buffers Keith Busch
2025-02-11 16:47   ` Keith Busch
2025-02-12  2:29 ` [PATCHv2 0/6] ublk zero-copy support Ming Lei
2025-02-12 15:28   ` Keith Busch
2025-02-12 16:06     ` Pavel Begunkov
2025-02-13  1:52       ` Ming Lei
2025-02-13 15:12 ` lizetao
2025-02-13 16:06   ` Keith Busch
2025-02-14  3:39     ` lizetao
2025-02-14  2:41   ` Ming Lei
2025-02-14  4:21     ` lizetao

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=Z6y3YNX4-Ln2tjyX@kbusch-mbp \
    [email protected] \
    [email protected] \
    [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