Skip to content

Commit d73cf5f

Browse files
LuBaolujgunthorpe
authored andcommitted
iommufd: Add check on user response code
The response code from user space is only allowed to be SUCCESS or INVALID. All other values are treated by the device as a response code of Response Failure according to PCI spec, section 10.4.2.1. This response disables the Page Request Interface for the Function. Add a check in iommufd_fault_fops_write() to avoid invalid response code. Fixes: 07838f7 ("iommufd: Add iommufd fault object") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 861f96a commit d73cf5f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/iommu/iommufd/fault.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ static ssize_t iommufd_fault_fops_write(struct file *filep, const char __user *b
305305
if (rc)
306306
break;
307307

308+
static_assert((int)IOMMUFD_PAGE_RESP_SUCCESS ==
309+
(int)IOMMU_PAGE_RESP_SUCCESS);
310+
static_assert((int)IOMMUFD_PAGE_RESP_INVALID ==
311+
(int)IOMMU_PAGE_RESP_INVALID);
312+
if (response.code != IOMMUFD_PAGE_RESP_SUCCESS &&
313+
response.code != IOMMUFD_PAGE_RESP_INVALID) {
314+
rc = -EINVAL;
315+
break;
316+
}
317+
308318
group = xa_erase(&fault->response, response.cookie);
309319
if (!group) {
310320
rc = -EINVAL;

0 commit comments

Comments
 (0)