This is a note to let you know that I've just added the patch titled iommufd: Do not add the same hwpt to the ioas->hwpt_list twice to the 6.2-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: iommufd-do-not-add-the-same-hwpt-to-the-ioas-hwpt_list-twice.patch and it can be found in the queue-6.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From b4ff830eca097df51af10a9be29e8cc817327919 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe <jgg@xxxxxxxxxx> Date: Mon, 13 Feb 2023 14:02:42 -0400 Subject: iommufd: Do not add the same hwpt to the ioas->hwpt_list twice From: Jason Gunthorpe <jgg@xxxxxxxxxx> commit b4ff830eca097df51af10a9be29e8cc817327919 upstream. The hwpt is added to the hwpt_list only during its creation, it is never added again. This hunk is some missed leftover from rework. Adding it twice will corrupt the linked list in some cases. It effects HWPT specific attachment, which is something the test suite cannot cover until we can create a legitimate struct device with a non-system iommu "driver" (ie we need the bus removed from the iommu code) Cc: stable@xxxxxxxxxxxxxxx Fixes: e8d57210035b ("iommufd: Add kAPI toward external drivers for physical devices") Link: https://lore.kernel.org/r/1-v1-4336b5cb2fe4+1d7-iommufd_hwpt_jgg@xxxxxxxxxx Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> Reported-by: Kevin Tian <kevin.tian@xxxxxxxxx> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/iommu/iommufd/device.c | 4 ---- 1 file changed, 4 deletions(-) --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -346,10 +346,6 @@ int iommufd_device_attach(struct iommufd rc = iommufd_device_do_attach(idev, hwpt); if (rc) goto out_put_pt_obj; - - mutex_lock(&hwpt->ioas->mutex); - list_add_tail(&hwpt->hwpt_item, &hwpt->ioas->hwpt_list); - mutex_unlock(&hwpt->ioas->mutex); break; } case IOMMUFD_OBJ_IOAS: { Patches currently in stable-queue which might be from jgg@xxxxxxxxxx are queue-6.2/rdma-rxe-replace-rxe_map-and-rxe_phys_buf-by-xarray.patch queue-6.2/iommu-attach-device-group-to-old-domain-in-error-path.patch queue-6.2/iommu-fix-error-unwind-in-iommu_group_alloc.patch queue-6.2/selftests-iommu-fix-test_cmd_destroy_access-call-in-.patch queue-6.2/rdma-rxe-isolate-mr-code-from-atomic_reply.patch queue-6.2/rdma-siw-fix-user-page-pinning-accounting.patch queue-6.2/vfio-fix-null-pointer-dereference-caused-by-uninitialized-group-iommufd.patch queue-6.2/rdma-rxe-isolate-mr-code-from-atomic_write_reply.patch queue-6.2/iommufd-add-three-missing-structures-in-ucmd_buffer.patch queue-6.2/rdma-rxe-move-rxe_map_mr_sg-to-rxe_mr.c.patch queue-6.2/subject-rdma-rxe-handle-zero-length-rdma.patch queue-6.2/vfio-type1-prevent-underflow-of-locked_vm-via-exec.patch queue-6.2/rdma-rxe-fix-missing-memory-barriers-in-rxe_queue.h.patch queue-6.2/rdma-mana_ib-fix-a-bug-when-the-pf-indicates-more-en.patch queue-6.2/vfio-type1-restore-locked_vm.patch queue-6.2/ib-hfi1-fix-math-bugs-in-hfi1_can_pin_pages.patch queue-6.2/rdma-rxe-cleanup-mr_check_range.patch queue-6.2/iommufd-do-not-add-the-same-hwpt-to-the-ioas-hwpt_list-twice.patch queue-6.2/ib-hfi1-fix-sdma.h-tx-num_descs-off-by-one-errors.patch queue-6.2/rdma-rxe-cleanup-page-variables-in-rxe_mr.c.patch queue-6.2/vfio-type1-exclude-mdevs-from-vfio_update_vaddr.patch queue-6.2/iommufd-make-sure-to-zero-vfio_iommu_type1_info-before-copying-to-user.patch queue-6.2/vfio-type1-track-locked_vm-per-dma.patch