* [PATCH] selftests: iommu: fix Warray-bounds in get_hw_info test
@ 2025-12-10 21:13 Kathara Sasikumar
2025-12-12 6:31 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Kathara Sasikumar @ 2025-12-10 21:13 UTC (permalink / raw)
To: jgg, kevin.tian, shuah
Cc: iommu, linux-kselftest, linux-kernel, yi.l.liu, nicolinc,
alex.williamson, katharaasasikumar007, Kathara Sasikumar
The get_hw_info uses a smaller user buffer on purpose to check how
the kernel updates only the fields that fit in the buffer. The test
created a custom smaller struct for this, but the helper function later
treats the buffer as struct iommu_test_hw_info. This makes the compiler
warn about a possible out-of-bounds access (-Warray-bounds).
This keeps the test behavior the same and removes the warning.
Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com>
---
tools/testing/selftests/iommu/iommufd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index 10e051b6f592..f6aceb65313f 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -755,9 +755,7 @@ TEST_F(iommufd_ioas, get_hw_info)
struct iommu_test_hw_info info;
uint64_t trailing_bytes;
} buffer_larger;
- struct iommu_test_hw_info_buffer_smaller {
- __u32 flags;
- } buffer_smaller;
+ struct iommu_test_hw_info buffer_smaller;
if (self->device_id) {
uint8_t max_pasid = 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: iommu: fix Warray-bounds in get_hw_info test
2025-12-10 21:13 [PATCH] selftests: iommu: fix Warray-bounds in get_hw_info test Kathara Sasikumar
@ 2025-12-12 6:31 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2025-12-12 6:31 UTC (permalink / raw)
To: Kathara Sasikumar
Cc: kevin.tian, shuah, iommu, linux-kselftest, linux-kernel, yi.l.liu,
nicolinc, alex.williamson, katharaasasikumar007
On Wed, Dec 10, 2025 at 09:13:42PM +0000, Kathara Sasikumar wrote:
> The get_hw_info uses a smaller user buffer on purpose to check how
> the kernel updates only the fields that fit in the buffer. The test
> created a custom smaller struct for this, but the helper function later
> treats the buffer as struct iommu_test_hw_info. This makes the compiler
> warn about a possible out-of-bounds access (-Warray-bounds).
>
> This keeps the test behavior the same and removes the warning.
>
> Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com>
> ---
> tools/testing/selftests/iommu/iommufd.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
This breaks the test, I already posted a fix, it should be in linux-next.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-12 6:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 21:13 [PATCH] selftests: iommu: fix Warray-bounds in get_hw_info test Kathara Sasikumar
2025-12-12 6:31 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.