From: Jason Wang <jasowang@redhat.com>
To: gautam.dawar@xilinx.com
Cc: martinh@xilinx.com, hanand@xilinx.com, gdawar@xilinx.com,
"Michael S. Tsirkin" <mst@redhat.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] vhost-vdpa: mark vhost device invalid to reflect vdpa device unregistration
Date: Mon, 5 Jul 2021 11:48:36 +0800 [thread overview]
Message-ID: <3d02b8f5-0a6b-e8d1-533d-8503da3fcc4e@redhat.com> (raw)
In-Reply-To: <20210704205205.6132-1-gdawar@xilinx.com>
在 2021/7/5 上午4:52, gautam.dawar@xilinx.com 写道:
> vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> @@ -1091,11 +1122,13 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa)
> opened = atomic_cmpxchg(&v->opened, 0, 1);
> if (!opened)
> break;
> - wait_for_completion_timeout(&v->completion,
> - msecs_to_jiffies(1000));
> - dev_warn_once(&v->dev,
> - "%s waiting for/dev/%s to be closed\n",
> - __func__, dev_name(&v->dev));
> + if (!wait_for_completion_timeout(&v->completion,
> + msecs_to_jiffies(1000))) {
> + dev_warn(&v->dev,
> + "%s/dev/%s in use, continue..\n",
> + __func__, dev_name(&v->dev));
> + break;
> + }
> } while (1);
>
> put_device(&v->dev);
> + v->dev_invalid = true;
Besides the mapping handling mentioned by Michael. I think this can lead
use-after-free. put_device may release the memory.
Another fundamental issue, vDPA is the parent of vhost-vDPA device. I'm
not sure the device core can allow the parent to go away first.
Thanks
next prev parent reply other threads:[~2021-07-05 3:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-04 20:52 [RFC PATCH] vhost-vdpa: mark vhost device invalid to reflect vdpa device unregistration gautam.dawar
2021-07-04 21:50 ` Michael S. Tsirkin
2021-07-05 3:48 ` Jason Wang [this message]
2021-07-05 5:11 ` Jason Wang
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=3d02b8f5-0a6b-e8d1-533d-8503da3fcc4e@redhat.com \
--to=jasowang@redhat.com \
--cc=gautam.dawar@xilinx.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martinh@xilinx.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).