> From: Chatre, Reinette <reinette.chatre@xxxxxxxxx> > Sent: Friday, April 28, 2023 1:36 AM > > struct vfio_pci_core_device::num_ctx counts how many interrupt > contexts have been allocated. When all interrupt contexts are > allocated simultaneously num_ctx provides the upper bound of all > vectors that can be used as indices into the interrupt context > array. > > With the upcoming support for dynamic MSI-X the number of > interrupt contexts does not necessarily span the range of allocated > interrupts. Consequently, num_ctx is no longer a trusted upper bound > for valid indices. > > Stop using num_ctx to determine if a provided vector is valid. Use > the existence of allocated interrupt. > > This changes behavior on the error path when user space provides > an invalid vector range. Behavior changes from early exit without > any modifications to possible modifications to valid vectors within > the invalid range. This is acceptable considering that an invalid > range is not a valid scenario, see link to discussion. > > The checks that ensure that user space provides a range of vectors > that is valid for the device are untouched. > > Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>