Skip to content

Commit a38e071

Browse files
nicolincgregkh
authored andcommitted
iommufd: Break the loop on failure in iommufd_fault_fops_read()
[ Upstream commit 172fc8b ] On a copy_to_user() failure inside the inner list_for_each_entry, only the inner loop breaks; the outer while re-fetches the just-restored fault group and retries the failing copy_to_user() forever, spinning the reader at 100% CPU with fault->mutex held. Check rc after the inner loop and break the outer while as well. Fixes: 07838f7 ("iommufd: Add iommufd fault object") Link: https://patch.msgid.link/r/336a9b6e44fe66a24199d3be777c405c85c98622.1780343944.git.nicolinc@nvidia.com Cc: stable@vger.kernel.org Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Pranjal Shrivastava <praan@google.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 415cd5a commit a38e071

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/iommu/iommufd/fault.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ static ssize_t iommufd_fault_fops_read(struct file *filep, char __user *buf,
299299
}
300300
done += fault_size;
301301
}
302+
if (rc)
303+
break;
302304
}
303305
mutex_unlock(&fault->mutex);
304306

0 commit comments

Comments
 (0)