On Fri, 12 Mar 2021 20:55:57 -0400 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > 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_fsl_mc_reflck_attach() sets vdev->reflck and > vfio_fsl_mc_open(), called by fops open, unconditionally derefs it, which > will crash if things get out of order. > > This driver started life with the right sequence, but three commits added > stuff after vfio_add_group_dev(). > > Fixes: 2e0d29561f59 ("vfio/fsl-mc: Add irq infrastructure for fsl-mc devices") > Fixes: f2ba7e8c947b ("vfio/fsl-mc: Added lock support in preparation for interrupt handling") > Fixes: 704f5082d845 ("vfio/fsl-mc: Scan DPRC objects on vfio-fsl-mc driver bind") > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > --- > drivers/vfio/fsl-mc/vfio_fsl_mc.c | 43 ++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 21 deletions(-) Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>