]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vfio: Fix NULL pointer dereference caused by uninitialized group->iommufd
authorYan Zhao <yan.y.zhao@intel.com>
Wed, 22 Feb 2023 07:49:38 +0000 (15:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:29:49 +0000 (09:29 +0100)
commit d649c34cb916b015fdcb487e51409fcc5caeca8d upstream.

group->iommufd is not initialized for the iommufd_ctx_put()

[20018.331541] BUG: kernel NULL pointer dereference, address: 0000000000000000
[20018.377508] RIP: 0010:iommufd_ctx_put+0x5/0x10 [iommufd]
...
[20018.476483] Call Trace:
[20018.479214]  <TASK>
[20018.481555]  vfio_group_fops_unl_ioctl+0x506/0x690 [vfio]
[20018.487586]  __x64_sys_ioctl+0x6a/0xb0
[20018.491773]  ? trace_hardirqs_on+0xc5/0xe0
[20018.496347]  do_syscall_64+0x67/0x90
[20018.500340]  entry_SYSCALL_64_after_hwframe+0x4b/0xb5

Fixes: 9eefba8002c2 ("vfio: Move vfio group specific code into group.c")
Cc: stable@vger.kernel.org
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230222074938.13681-1-yan.y.zhao@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vfio/group.c

index bb24b2f0271e03c3b1a027b0ef8e717951f157ab..855db15477813334427fe0c0be7284a87d0a1d00 100644 (file)
@@ -137,7 +137,7 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group,
 
                ret = iommufd_vfio_compat_ioas_id(iommufd, &ioas_id);
                if (ret) {
-                       iommufd_ctx_put(group->iommufd);
+                       iommufd_ctx_put(iommufd);
                        goto out_unlock;
                }