Skip to content

Commit c37d2bc

Browse files
committed
Merge tag 'iommu-fixes-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux
Pull iommu fixes from Joerg Roedel: - AMD-Vi: Fix potential stack buffer overflow via command line - NVidia-Tegra: Fix endianess sparse warning - ARM-SMMU: Fix ATS-masters reference count issue - Virtio-IOMMU: Fix race condition on instance lookup - RISC-V IOMMU: Fix potential NULL-ptr dereference in riscv_iommu_iova_to_phys() * tag 'iommu-fixes-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux: iommu/riscv: prevent NULL deref in iova_to_phys iommu/virtio: Make instance lookup robust iommu/arm-smmu-v3: Fix smmu_domain->nr_ats_masters decrement iommu/tegra241-cmdqv: Fix missing cpu_to_le64 at lvcmdq_err_map iommu/amd: Avoid stack buffer overflow from kernel cmdline
2 parents f28ad47 + 99d4d1a commit c37d2bc

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

drivers/iommu/amd/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,7 @@ static int __init parse_ivrs_acpihid(char *str)
36383638
{
36393639
u32 seg = 0, bus, dev, fn;
36403640
char *hid, *uid, *p, *addr;
3641-
char acpiid[ACPIID_LEN] = {0};
3641+
char acpiid[ACPIID_LEN + 1] = { }; /* size with NULL terminator */
36423642
int i;
36433643

36443644
addr = strchr(str, '@');
@@ -3664,7 +3664,7 @@ static int __init parse_ivrs_acpihid(char *str)
36643664
/* We have the '@', make it the terminator to get just the acpiid */
36653665
*addr++ = 0;
36663666

3667-
if (strlen(str) > ACPIID_LEN + 1)
3667+
if (strlen(str) > ACPIID_LEN)
36683668
goto not_found;
36693669

36703670
if (sscanf(str, "=%s", acpiid) != 1)

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,9 +2997,9 @@ void arm_smmu_attach_commit(struct arm_smmu_attach_state *state)
29972997
/* ATS is being switched off, invalidate the entire ATC */
29982998
arm_smmu_atc_inv_master(master, IOMMU_NO_PASID);
29992999
}
3000-
master->ats_enabled = state->ats_enabled;
30013000

30023001
arm_smmu_remove_master_domain(master, state->old_domain, state->ssid);
3002+
master->ats_enabled = state->ats_enabled;
30033003
}
30043004

30053005
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)

drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,11 @@ static void tegra241_vintf_user_handle_error(struct tegra241_vintf *vintf)
301301
struct iommu_vevent_tegra241_cmdqv vevent_data;
302302
int i;
303303

304-
for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++)
305-
vevent_data.lvcmdq_err_map[i] =
306-
readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i)));
304+
for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++) {
305+
u64 err = readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i)));
306+
307+
vevent_data.lvcmdq_err_map[i] = cpu_to_le64(err);
308+
}
307309

308310
iommufd_viommu_report_event(viommu, IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV,
309311
&vevent_data, sizeof(vevent_data));

drivers/iommu/riscv/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
12831283
unsigned long *ptr;
12841284

12851285
ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
1286-
if (_io_pte_none(*ptr) || !_io_pte_present(*ptr))
1286+
if (!ptr)
12871287
return 0;
12881288

12891289
return pfn_to_phys(__page_val_to_pfn(*ptr)) | (iova & (pte_size - 1));

drivers/iommu/virtio-iommu.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,7 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
998998
iommu_dma_get_resv_regions(dev, head);
999999
}
10001000

1001-
static const struct iommu_ops viommu_ops;
1002-
static struct virtio_driver virtio_iommu_drv;
1001+
static const struct bus_type *virtio_bus_type;
10031002

10041003
static int viommu_match_node(struct device *dev, const void *data)
10051004
{
@@ -1008,8 +1007,9 @@ static int viommu_match_node(struct device *dev, const void *data)
10081007

10091008
static struct viommu_dev *viommu_get_by_fwnode(struct fwnode_handle *fwnode)
10101009
{
1011-
struct device *dev = driver_find_device(&virtio_iommu_drv.driver, NULL,
1012-
fwnode, viommu_match_node);
1010+
struct device *dev = bus_find_device(virtio_bus_type, NULL, fwnode,
1011+
viommu_match_node);
1012+
10131013
put_device(dev);
10141014

10151015
return dev ? dev_to_virtio(dev)->priv : NULL;
@@ -1160,6 +1160,9 @@ static int viommu_probe(struct virtio_device *vdev)
11601160
if (!viommu)
11611161
return -ENOMEM;
11621162

1163+
/* Borrow this for easy lookups later */
1164+
virtio_bus_type = dev->bus;
1165+
11631166
spin_lock_init(&viommu->request_lock);
11641167
ida_init(&viommu->domain_ids);
11651168
viommu->dev = dev;
@@ -1229,10 +1232,10 @@ static int viommu_probe(struct virtio_device *vdev)
12291232
if (ret)
12301233
goto err_free_vqs;
12311234

1232-
iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev);
1233-
12341235
vdev->priv = viommu;
12351236

1237+
iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev);
1238+
12361239
dev_info(dev, "input address: %u bits\n",
12371240
order_base_2(viommu->geometry.aperture_end));
12381241
dev_info(dev, "page mask: %#llx\n", viommu->pgsize_bitmap);

0 commit comments

Comments
 (0)