From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <iommu@lists.linux.dev>, Kevin Tian <kevin.tian@intel.com>,
<linux-kselftest@vger.kernel.org>, Shuah Khan <shuah@kernel.org>,
"kernel test robot" <lkp@intel.com>, <patches@lists.linux.dev>,
Yi Liu <yi.l.liu@intel.com>
Subject: Re: [PATCH] iommufd/selftest: Make it clearer to gcc that the access is not out of bounds
Date: Fri, 5 Dec 2025 16:56:54 -0800 [thread overview]
Message-ID: <aTN/VuXp5AMOjg5L@nvidia.com> (raw)
In-Reply-To: <0-v1-63a2cffb09da+4486-iommufd_gcc_bounds_jgg@nvidia.com>
On Fri, Dec 05, 2025 at 08:39:59PM -0400, Jason Gunthorpe wrote:
> 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 <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512032344.kaAcKFIM-lkp@intel.com/
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
next prev parent reply other threads:[~2025-12-06 0:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 0:39 [PATCH] iommufd/selftest: Make it clearer to gcc that the access is not out of bounds Jason Gunthorpe
2025-12-06 0:56 ` Nicolin Chen [this message]
2025-12-12 4:11 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aTN/VuXp5AMOjg5L@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=lkp@intel.com \
--cc=patches@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox