]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iommufd/selftest: Cover invalid read counts on vEVENTQ FD
authorNicolin Chen <nicolinc@nvidia.com>
Mon, 1 Jun 2026 20:42:38 +0000 (13:42 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 5 Jun 2026 14:07:12 +0000 (11:07 -0300)
commit61d525d96ade3367ce65e340b33aa2f1fd5a3602
treef3174d22f25ef65da9d87269827c75d4560aec93
parent091ab6d70dc444f56ed14faedbcacfc979f4c613
iommufd/selftest: Cover invalid read counts on vEVENTQ FD

The vEVENTQ file descriptor must reject reads whose buffer cannot hold
even one event record. Add selftest coverage that exercises both the
empty-queue path (the upfront size check) and the non-empty path (the
in-loop check that fires only after an event is fetched).

For iommufd_veventq_fops_read():
 - count == 0 and count < sizeof(header) on an empty vEVENTQ both
   return -EINVAL.
 - count == 0 and count == sizeof(header) on a non-empty vEVENTQ
   (event has trailing payload) both return -EINVAL.

Link: https://patch.msgid.link/r/7bcd153d306f2cf04c094c728c0ebe146855072a.1780343944.git.nicolinc@nvidia.com
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
tools/testing/selftests/iommu/iommufd.c