linux/drivers/iommu
Daniel Mentz f63237f54c iommu/arm-smmu-v3: Fix last_sid_idx calculation for sid_bits==32
The function arm_smmu_init_strtab_2lvl uses the expression

((1 << smmu->sid_bits) - 1)

to calculate the largest StreamID value. However, this fails for the
maximum allowed value of SMMU_IDR1.SIDSIZE which is 32. The C standard
states:

"If the value of the right operand is negative or is greater than or
equal to the width of the promoted left operand, the behavior is
undefined."

With smmu->sid_bits being 32, the prerequisites for undefined behavior
are met.  We observed that the value of (1 << 32) is 1 and not 0 as we
initially expected.

Similar bit shift operations in arm_smmu_init_strtab_linear seem to not
be affected, because it appears to be unlikely for an SMMU to have
SMMU_IDR1.SIDSIZE set to 32 but then not support 2-level Stream tables

This issue was found by Ryan Huang <tzukui@google.com> on our team.

Fixes: ce410410f1 ("iommu/arm-smmu-v3: Add arm_smmu_strtab_l1/2_idx()")
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Link: https://lore.kernel.org/r/20241002015357.1766934-1-danielmentz@google.com
Signed-off-by: Will Deacon <will@kernel.org>
2024-10-08 18:37:48 +01:00
..
amd
arm iommu/arm-smmu-v3: Fix last_sid_idx calculation for sid_bits==32 2024-10-08 18:37:48 +01:00
intel
iommufd [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
apple-dart.c
dma-iommu.c dma-mapping: fix vmap and mmap of noncontiougs allocations 2024-09-22 18:47:51 +02:00
dma-iommu.h
exynos-iommu.c
fsl_pamu_domain.c
fsl_pamu_domain.h
fsl_pamu.c
fsl_pamu.h
hyperv-iommu.c
io-pgfault.c
io-pgtable-arm-v7s.c
io-pgtable-arm.c
io-pgtable-arm.h
io-pgtable-dart.c
io-pgtable.c
iommu-debugfs.c
iommu-pages.h
iommu-priv.h
iommu-sva.c
iommu-sysfs.c
iommu-traces.c
iommu.c
iova.c
ipmmu-vmsa.c
irq_remapping.c
irq_remapping.h
Kconfig
Makefile
msm_iommu_hw-8xxx.h
msm_iommu.c
msm_iommu.h
mtk_iommu_v1.c
mtk_iommu.c
of_iommu.c
omap-iommu-debug.c
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
rockchip-iommu.c
s390-iommu.c
sprd-iommu.c
sun50i-iommu.c
tegra-smmu.c
virtio-iommu.c