Re: [PATCH v2 4/5] iommu/arm-smmu-v3-test: Fix OOB in arm_smmu_v3_invs_test_verify()
From: Pranjal Shrivastava
Date: Mon Sep 28 2026 - 20:02:50 EST
On Thu, Sep 24, 2026 at 08:56:15AM +0000, Mostafa Saleh wrote:
> arm_smmu_v3_invs_test_verify() validates the array bounds using
> KUNIT_EXPECT_EQ(), which triggers a failure and continues execution.
> If invs->num_invs was smaller than expected, the next loop over
> num_invs would blindly read past the end of the invs->inv[] array.
> Switch to KUNIT_ASSERT_EQ() to fail and stop the test on bound errors.
>
> Fixes: 15a2a5645ad7 ("iommu/arm-smmu-v3: Introduce a per-domain arm_smmu_invs array")
> Reported-by: Sashiko <>
> Reviewed-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Mostafa Saleh <smostafa@xxxxxxxxxx>
Reviewed-by: Pranjal Shrivastava <praan@xxxxxxxxxx>
Thanks,
Praan
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c
> index 366dcb2b5554..244cf34e5a0b 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c
> @@ -643,7 +643,7 @@ static void arm_smmu_v3_invs_test_verify(struct kunit *test,
> const int *ids, const int *users,
> const int *ssids)
> {
> - KUNIT_EXPECT_EQ(test, invs->num_invs, num_invs);
> + KUNIT_ASSERT_EQ(test, invs->num_invs, num_invs);
> KUNIT_EXPECT_EQ(test, invs->num_trashes, num_trashes);
> while (num_invs--) {
> KUNIT_EXPECT_EQ(test, invs->inv[num_invs].id, ids[num_invs]);
> --
> 2.56.0.rc1.315.gc6ed9934b7-goog
>