Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd

Pull iommufd fixes from Jason Gunthorpe:
"A few minor fixes, other than the randconfig fix this is only relevant
to test code, not releases:

- Randconfig failure if CONFIG_DMA_SHARED_BUFFER is not set

- Remove gcc warning in kselftest

- Fix a refcount leak on an error path in the selftest support code

- Fix missing overflow checks in the selftest support code"

* tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd:
iommufd/selftest: Check for overflow in IOMMU_TEST_OP_ADD_RESERVED
iommufd/selftest: Do not leak the hwpt if IOMMU_TEST_OP_MD_CHECK_MAP fails
iommufd/selftest: Make it clearer to gcc that the access is not out of bounds
iommufd: Fix building without dmabuf

+19 -9
+5 -1
drivers/iommu/iommufd/io_pagetable.c
··· 495 495 return -EOVERFLOW; 496 496 497 497 start_byte = start - ALIGN_DOWN(start, PAGE_SIZE); 498 - dmabuf = dma_buf_get(fd); 498 + if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER)) 499 + dmabuf = dma_buf_get(fd); 500 + else 501 + dmabuf = ERR_PTR(-ENXIO); 502 + 499 503 if (!IS_ERR(dmabuf)) { 500 504 pages = iopt_alloc_dmabuf_pages(ictx, dmabuf, start_byte, start, 501 505 length,
+11 -3
drivers/iommu/iommufd/selftest.c
··· 1184 1184 unsigned int mockpt_id, 1185 1185 unsigned long start, size_t length) 1186 1186 { 1187 + unsigned long last; 1187 1188 struct iommufd_ioas *ioas; 1188 1189 int rc; 1190 + 1191 + if (!length) 1192 + return -EINVAL; 1193 + if (check_add_overflow(start, length - 1, &last)) 1194 + return -EOVERFLOW; 1189 1195 1190 1196 ioas = iommufd_get_ioas(ucmd->ictx, mockpt_id); 1191 1197 if (IS_ERR(ioas)) 1192 1198 return PTR_ERR(ioas); 1193 1199 down_write(&ioas->iopt.iova_rwsem); 1194 - rc = iopt_reserve_iova(&ioas->iopt, start, start + length - 1, NULL); 1200 + rc = iopt_reserve_iova(&ioas->iopt, start, last, NULL); 1195 1201 up_write(&ioas->iopt.iova_rwsem); 1196 1202 iommufd_put_object(ucmd->ictx, &ioas->obj); 1197 1203 return rc; ··· 1221 1215 page_size = 1 << __ffs(mock->domain.pgsize_bitmap); 1222 1216 if (iova % page_size || length % page_size || 1223 1217 (uintptr_t)uptr % page_size || 1224 - check_add_overflow((uintptr_t)uptr, (uintptr_t)length, &end)) 1225 - return -EINVAL; 1218 + check_add_overflow((uintptr_t)uptr, (uintptr_t)length, &end)) { 1219 + rc = -EINVAL; 1220 + goto out_put; 1221 + } 1226 1222 1227 1223 for (; length; length -= page_size) { 1228 1224 struct page *pages[1];
+3 -5
tools/testing/selftests/iommu/iommufd.c
··· 755 755 struct iommu_test_hw_info info; 756 756 uint64_t trailing_bytes; 757 757 } buffer_larger; 758 - struct iommu_test_hw_info_buffer_smaller { 759 - __u32 flags; 760 - } buffer_smaller; 761 758 762 759 if (self->device_id) { 763 760 uint8_t max_pasid = 0; ··· 786 789 * the fields within the size range still gets updated. 787 790 */ 788 791 test_cmd_get_hw_info(self->device_id, 789 - IOMMU_HW_INFO_TYPE_DEFAULT, 790 - &buffer_smaller, sizeof(buffer_smaller)); 792 + IOMMU_HW_INFO_TYPE_DEFAULT, &buffer_exact, 793 + offsetofend(struct iommu_test_hw_info, 794 + flags)); 791 795 test_cmd_get_hw_info_pasid(self->device_id, &max_pasid); 792 796 ASSERT_EQ(0, max_pasid); 793 797 if (variant->pasid_capable) {