]> git.baikalelectronics.ru Git - kernel.git/commit
vfio/pci: Re-order vfio_pci_probe()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 30 Mar 2021 15:53:06 +0000 (09:53 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 6 Apr 2021 17:55:10 +0000 (11:55 -0600)
commita86bac41ffc3adcf1f5fb4eeef991d4218f9f37d
tree35f7662ca1a073c9567970bfe04ff0c9109fc850
parent8deedd59a9af4044bb22351e95f65e5bed896788
vfio/pci: Re-order vfio_pci_probe()

vfio_add_group_dev() must be called only after all of the private data in
vdev is fully setup and ready, otherwise there could be races with user
space instantiating a device file descriptor and starting to call ops.

For instance vfio_pci_reflck_attach() sets vdev->reflck and
vfio_pci_open(), called by fops open, unconditionally derefs it, which
will crash if things get out of order.

Fixes: 655bb22a6ace ("vfio/pci: Introduce VF token")
Fixes: 9cb4c9a30682 ("vfio/pci: Parallelize device open and release")
Fixes: 4682d0469d83 ("vfio-pci: Move idle devices to D3hot power state")
Fixes: c59055fe30f9 ("vfio-pci: Add VGA arbiter client")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <8-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/vfio_pci.c