> From: Jason Gunthorpe <[email protected]> > Sent: Saturday, December 6, 2025 8:40 AM > > GCC gets a bit confused and reports: > > In function '_test_cmd_get_hw_info', > inlined from 'iommufd_ioas_get_hw_info' at iommufd.c:779:3, > inlined from 'wrapper_iommufd_ioas_get_hw_info' at iommufd.c:752:1: > >> iommufd_utils.h:804:37: warning: array subscript 'struct > iommu_test_hw_info[0]' is partly outside array bounds of 'struct > iommu_test_hw_info_buffer_smaller[1]' [-Warray-bounds=] > 804 | assert(!info->flags); > | ~~~~^~~~~~~ > iommufd.c: In function 'wrapper_iommufd_ioas_get_hw_info': > iommufd.c:761:11: note: object 'buffer_smaller' of size 4 > 761 | } buffer_smaller; > | ^~~~~~~~~~~~~~ > > While it is true that "struct iommu_test_hw_info[0]" is partly out of > bounds of the input pointer, it is not true that info->flags is out of > bounds. Unclear why it warns on this. > > Reuse an existing properly sized stack buffer and pass a truncated length > instead to test the same thing. > > Fixes: af4fde93c319 ("iommufd/selftest: Add coverage for > IOMMU_GET_HW_INFO ioctl") > Reported-by: kernel test robot <[email protected]> > Closes: https://lore.kernel.org/oe-kbuild-all/202512032344.kaAcKFIM- > [email protected]/ > Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Kevin Tian <[email protected]>
