Skip to content

Commit 85345be

Browse files
nicolincjgunthorpe
authored andcommitted
iommufd: Fix data_len byte-count vs element-count mismatch
kzalloc_flex() computes the allocation size. With event_data typed as u64, data_len is interpreted as a u64 element count. Yet, every caller and the read path treat data_len as a byte count. The current code over-allocates by sizeof(u64) and the __counted_by() annotation overstates the length by the same factor. Re-type event_data as u8. No functional change in user-visible behavior. Fixes: e36ba5a ("iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC") Link: https://patch.msgid.link/r/f7665f839b9dce917d6bd394375a1cf56568d86b.1779408671.git.nicolinc@nvidia.com Cc: stable@vger.kernel.org Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent be93d18 commit 85345be

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iommu/iommufd/iommufd_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ struct iommufd_vevent {
602602
struct iommufd_vevent_header header;
603603
struct list_head node; /* for iommufd_eventq::deliver */
604604
ssize_t data_len;
605-
u64 event_data[] __counted_by(data_len);
605+
u8 event_data[] __counted_by(data_len);
606606
};
607607

608608
#define vevent_for_lost_events_header(vevent) \

0 commit comments

Comments
 (0)