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: <CA+CK2bDbOQ=aGPZVP4L-eYobUyR0bQA0Ro6Q7pwQ_84UxVHnEw@mail.gmail.com>
Date: Wed, 3 Dec 2025 10:45:58 -0500
From: Pasha Tatashin <pasha.tatashin@...een.com>
To: Alex Mastro <amastro@...com>
Cc: David Matlack <dmatlack@...gle.com>, Alex Williamson <alex@...zbot.org>, 
	Adithya Jayachandran <ajayachandra@...dia.com>, Alistair Popple <apopple@...dia.com>, 
	Andrew Morton <akpm@...ux-foundation.org>, Bjorn Helgaas <bhelgaas@...gle.com>, 
	Chris Li <chrisl@...nel.org>, David Rientjes <rientjes@...gle.com>, 
	Jacob Pan <jacob.pan@...ux.microsoft.com>, Jason Gunthorpe <jgg@...dia.com>, 
	Jason Gunthorpe <jgg@...pe.ca>, Josh Hilke <jrhilke@...gle.com>, Kevin Tian <kevin.tian@...el.com>, 
	kvm@...r.kernel.org, Leon Romanovsky <leonro@...dia.com>, linux-kernel@...r.kernel.org, 
	linux-kselftest@...r.kernel.org, linux-pci@...r.kernel.org, 
	Lukas Wunner <lukas@...ner.de>, Mike Rapoport <rppt@...nel.org>, Parav Pandit <parav@...dia.com>, 
	Philipp Stanner <pstanner@...hat.com>, Pratyush Yadav <pratyush@...nel.org>, 
	Saeed Mahameed <saeedm@...dia.com>, Samiullah Khawaja <skhawaja@...gle.com>, Shuah Khan <shuah@...nel.org>, 
	Tomita Moeko <tomitamoeko@...il.com>, Vipin Sharma <vipinsh@...gle.com>, William Tu <witu@...dia.com>, 
	Yi Liu <yi.l.liu@...el.com>, Yunxiang Li <Yunxiang.Li@....com>, 
	Zhu Yanjun <yanjun.zhu@...ux.dev>
Subject: Re: [PATCH 06/21] vfio/pci: Retrieve preserved device files after
 Live Update

On Wed, Dec 3, 2025 at 7:55 AM Alex Mastro <amastro@...com> wrote:
>
> On Wed, Nov 26, 2025 at 07:35:53PM +0000, David Matlack wrote:
> > From: Vipin Sharma <vipinsh@...gle.com>
> >  static int vfio_pci_liveupdate_retrieve(struct liveupdate_file_op_args *args)
> >  {
> > -     return -EOPNOTSUPP;
> > +     struct vfio_pci_core_device_ser *ser;
> > +     struct vfio_device *device;
> > +     struct folio *folio;
> > +     struct file *file;
> > +     int ret;
> > +
> > +     folio = kho_restore_folio(args->serialized_data);
> > +     if (!folio)
> > +             return -ENOENT;
>
> Should this be consistent with the behavior of pci_flb_retrieve() which panics
> on failure? The short circuit failure paths which follow leak the folio,
> which seems like a hygiene issue, but the practical significance is moot if
> vfio_pci_liveupdate_retrieve() failure is catastrophic anyways?

pci_flb_retrieve() is used during boot. If it fails, we risk DMA
corrupting any memory region, so a panic makes sense. In contrast,
this retrieval happens once we are already in userspace, allowing the
user to decide how to handle the failure to recover the preserved
cdev.

Pasha

>
> > +
> > +     ser = folio_address(folio);
> > +
> > +     device = vfio_find_device(ser, match_device);
> > +     if (!device)
> > +             return -ENODEV;
> > +
> > +     /*
> > +      * During a Live Update userspace retrieves preserved VFIO cdev files by
> > +      * issuing an ioctl on /dev/liveupdate rather than by opening VFIO
> > +      * character devices.
> > +      *
> > +      * To handle that scenario, this routine simulates opening the VFIO
> > +      * character device for userspace with an anonymous inode. The returned
> > +      * file has the same properties as a cdev file (e.g. operations are
> > +      * blocked until BIND_IOMMUFD is called), aside from the inode
> > +      * association.
> > +      */
> > +     file = anon_inode_getfile_fmode("[vfio-device-liveupdate]",
> > +                                     &vfio_device_fops, NULL,
> > +                                     O_RDWR, FMODE_PREAD | FMODE_PWRITE);
> > +
> > +     if (IS_ERR(file)) {
> > +             ret = PTR_ERR(file);
> > +             goto out;
> > +     }
> > +
> > +     ret = __vfio_device_fops_cdev_open(device, file);
> > +     if (ret) {
> > +             fput(file);
> > +             goto out;
> > +     }
> > +
> > +     args->file = file;
> > +
> > +out:
> > +     /* Drop the reference from vfio_find_device() */
> > +     put_device(&device->device);
> > +
> > +     return ret;
> > +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ