public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Anthony DeRossi <ajderossi@gmail.com>
Cc: kvm@vger.kernel.org, alex.williamson@redhat.com,
	cohuck@redhat.com, kevin.tian@intel.com, abhsahu@nvidia.com,
	yishaih@nvidia.com
Subject: Re: [PATCH v5 1/3] vfio: Fix container device registration life cycle
Date: Tue, 8 Nov 2022 20:43:31 -0400	[thread overview]
Message-ID: <Y2r3syYBbIdb8dr4@ziepe.ca> (raw)
In-Reply-To: <20221105224458.8180-2-ajderossi@gmail.com>

On Sat, Nov 05, 2022 at 03:44:56PM -0700, Anthony DeRossi wrote:
> In vfio_device_open(), vfio_container_device_register() is always called
> when open_count == 1. On error, vfio_device_container_unregister() is
> only called when open_count == 1 and close_device is set. This leaks a
> registration for devices without a close_device implementation.
> 
> In vfio_device_fops_release(), vfio_device_container_unregister() is
> called unconditionally. This can cause a device to be unregistered
> multiple times.
> 
> Treating container device registration/unregistration uniformly (always
> when open_count == 1) fixes both issues.
> 
> Fixes: ce4b4657ff18 ("vfio: Replace the DMA unmapping notifier with a callback")
> Signed-off-by: Anthony DeRossi <ajderossi@gmail.com>
> ---
>  drivers/vfio/vfio_main.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

This seems to only effect the mbochs sample, but it looks OK

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

This will generate conflicts with the iommufd treee, so please lets
think about how to avoid them..

Jason

  reply	other threads:[~2022-11-09  0:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 22:44 [PATCH v5 0/3] vfio/pci: Check the device set open count on reset Anthony DeRossi
2022-11-05 22:44 ` [PATCH v5 1/3] vfio: Fix container device registration life cycle Anthony DeRossi
2022-11-09  0:43   ` Jason Gunthorpe [this message]
2022-11-09  3:36   ` Tian, Kevin
2022-11-05 22:44 ` [PATCH v5 2/3] vfio: Export the device set open count Anthony DeRossi
2022-11-08 23:52   ` Alex Williamson
2022-11-09  0:48   ` Jason Gunthorpe
2022-11-09 16:04     ` Alex Williamson
2022-11-09  3:37   ` Tian, Kevin
2022-11-05 22:44 ` [PATCH v5 3/3] vfio/pci: Check the device set open count on reset Anthony DeRossi
2022-11-09  0:53   ` Jason Gunthorpe
2022-11-09  3:38   ` Tian, Kevin

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=Y2r3syYBbIdb8dr4@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=abhsahu@nvidia.com \
    --cc=ajderossi@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=yishaih@nvidia.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