lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB527684F9BD1B906B930E4A468CD09@BN9PR11MB5276.namprd11.prod.outlook.com>
Date:   Thu, 19 May 2022 06:43:06 +0000
From:   "Tian, Kevin" <kevin.tian@...el.com>
To:     Matthew Rosato <mjrosato@...ux.ibm.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>
CC:     "jjherne@...ux.ibm.com" <jjherne@...ux.ibm.com>,
        "akrowiak@...ux.ibm.com" <akrowiak@...ux.ibm.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "hch@...radead.org" <hch@...radead.org>,
        "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
        "intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
        "cohuck@...hat.com" <cohuck@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "zhenyuw@...ux.intel.com" <zhenyuw@...ux.intel.com>,
        "pasic@...ux.ibm.com" <pasic@...ux.ibm.com>,
        "borntraeger@...ux.ibm.com" <borntraeger@...ux.ibm.com>,
        "intel-gvt-dev@...ts.freedesktop.org" 
        <intel-gvt-dev@...ts.freedesktop.org>,
        "Wang, Zhi A" <zhi.a.wang@...el.com>
Subject: RE: [PATCH v2 1/1] vfio: remove VFIO_GROUP_NOTIFY_SET_KVM

> From: Matthew Rosato
> Sent: Thursday, May 19, 2022 5:26 AM
> 
> Rather than relying on a notifier for associating the KVM with
> the group, let's assume that the association has already been
> made prior to device_open.  The first time a device is opened
> associate the group KVM with the device.
> 
> This fixes a user-triggerable oops in GVT.

No changelog.

> 
> Signed-off-by: Jason Gunthorpe <jgg@...dia.com>
> Signed-off-by: Matthew Rosato <mjrosato@...ux.ibm.com>

Not sure whether Christoph wants a s-o-b here when he wrote
the snippet to remove the release work of gvt...

> @@ -1083,11 +1083,22 @@ static struct file *vfio_device_open(struct
> vfio_device *device)
> 
>  	mutex_lock(&device->dev_set->lock);
>  	device->open_count++;
> +	down_read(&device->group->group_rwsem);
> +	if (device->open_count == 1 && device->group->kvm) {
> +		/*
> +		 * Here we pass the KVM pointer with the group under the
> read
> +		 * lock.  If the device driver will use it, it must obtain a
> +		 * reference and release it during close_device.
> +		 */
> +		device->kvm = device->group->kvm;
> +	}
> +
>  	if (device->open_count == 1 && device->ops->open_device) {

Merge the two branches so both are under if (device->open_count == 1) {}
(and group_rwsem can be also moved inside)

> @@ -1315,9 +1330,13 @@ static int vfio_device_fops_release(struct inode
> *inode, struct file *filep)
> 
>  	mutex_lock(&device->dev_set->lock);
>  	vfio_assert_device_open(device);
> +	down_read(&device->group->group_rwsem);
>  	if (device->open_count == 1 && device->ops->close_device)
>  		device->ops->close_device(device);
>  	device->open_count--;
> +	if (device->open_count == 0 && device->kvm)
> +		device->kvm = NULL;

This can be moved out of group_rwsem as there is no reference to
vfio_group.

> +	up_read(&device->group->group_rwsem);

otherwise,

Reviewed-by: Kevin Tian <kevin.tian@...el.com>

Thanks
Kevin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ