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]
Date:   Thu, 3 Mar 2022 09:04:11 -0400
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>
Cc:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "cohuck@...hat.com" <cohuck@...hat.com>,
        "mgurtovoy@...dia.com" <mgurtovoy@...dia.com>,
        "yishaih@...dia.com" <yishaih@...dia.com>,
        Linuxarm <linuxarm@...wei.com>,
        liulongfang <liulongfang@...wei.com>,
        "Zengtao (B)" <prime.zeng@...ilicon.com>,
        Jonathan Cameron <jonathan.cameron@...wei.com>,
        "Wangzhou (B)" <wangzhou1@...ilicon.com>
Subject: Re: [PATCH v7 09/10] hisi_acc_vfio_pci: Add support for VFIO live
 migration

On Thu, Mar 03, 2022 at 12:57:29PM +0000, Shameerali Kolothum Thodi wrote:
> 
> 
> > From: Jason Gunthorpe [mailto:jgg@...dia.com]
> > Sent: 03 March 2022 00:22
> > To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>
> > Cc: kvm@...r.kernel.org; linux-kernel@...r.kernel.org;
> > linux-crypto@...r.kernel.org; linux-pci@...r.kernel.org;
> > alex.williamson@...hat.com; cohuck@...hat.com; mgurtovoy@...dia.com;
> > yishaih@...dia.com; Linuxarm <linuxarm@...wei.com>; liulongfang
> > <liulongfang@...wei.com>; Zengtao (B) <prime.zeng@...ilicon.com>;
> > Jonathan Cameron <jonathan.cameron@...wei.com>; Wangzhou (B)
> > <wangzhou1@...ilicon.com>
> > Subject: Re: [PATCH v7 09/10] hisi_acc_vfio_pci: Add support for VFIO live
> > migration
> > 
> > On Wed, Mar 02, 2022 at 05:29:02PM +0000, Shameer Kolothum wrote:
> > > +static long hisi_acc_vf_save_unl_ioctl(struct file *filp,
> > > +				       unsigned int cmd, unsigned long arg)
> > > +{
> > > +	struct hisi_acc_vf_migration_file *migf = filp->private_data;
> > > +	struct hisi_acc_vf_core_device *hisi_acc_vdev = container_of(migf,
> > > +			struct hisi_acc_vf_core_device, saving_migf);
> > > +	loff_t *pos = &filp->f_pos;
> > > +	struct vfio_precopy_info info;
> > > +	unsigned long minsz;
> > > +	int ret;
> > > +
> > > +	if (cmd != VFIO_MIG_GET_PRECOPY_INFO)
> > > +		return -ENOTTY;
> > > +
> > > +	minsz = offsetofend(struct vfio_precopy_info, dirty_bytes);
> > > +
> > > +	if (copy_from_user(&info, (void __user *)arg, minsz))
> > > +		return -EFAULT;
> > > +	if (info.argsz < minsz)
> > > +		return -EINVAL;
> > > +
> > > +	mutex_lock(&hisi_acc_vdev->state_mutex);
> > > +	if (hisi_acc_vdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY) {
> > > +		mutex_unlock(&hisi_acc_vdev->state_mutex);
> > > +		return -EINVAL;
> > > +	}
> > 
> > IMHO it is easier just to check the total_length and not grab this
> > other lock
> 
> The problem with checking the total_length here is that it is possible that
> in STOP_COPY the dev is not ready and there are no more data to be transferred 
> and the total_length remains at QM_MATCH_SIZE.

Tthere is a scenario that transfers only QM_MATCH_SIZE in stop_copy?
This doesn't seem like a good idea, I think you should transfer a
positive indication 'this device is not ready' instead of truncating
the stream. A truncated stream should not be a valid stream.

ie always transfer the whole struct.

> Looks like setting the total_length = 0 in STOP_COPY is a better solution(If there are
> no other issues with that) as it will avoid grabbing the state_mutex as you
> mentioned above.

That seems really weird, I wouldn't recommend doing that..
 
Kaspm

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ