Skip to content

Commit b306019

Browse files
Artem Sadovnikovawilliam
authored andcommitted
vfio/mlx5: fix possible overflow in tracking max message size
MLX cap pg_track_log_max_msg_size consists of 5 bits, value of which is used as power of 2 for max_msg_size. This can lead to multiplication overflow between max_msg_size (u32) and integer constant, and afterwards incorrect value is being written to rq_size. Fix this issue by extending integer constant to u64 type. Found by Linux Verification Center (linuxtesting.org) with SVACE. Suggested-by: Alex Williamson <[email protected]> Signed-off-by: Artem Sadovnikov <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent e908f58 commit b306019

File tree

1 file changed

+2
-2
lines changed
  • drivers/vfio/pci/mlx5

1 file changed

+2
-2
lines changed

drivers/vfio/pci/mlx5/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,8 +1523,8 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,
15231523
log_max_msg_size = MLX5_CAP_ADV_VIRTUALIZATION(mdev, pg_track_log_max_msg_size);
15241524
max_msg_size = (1ULL << log_max_msg_size);
15251525
/* The RQ must hold at least 4 WQEs/messages for successful QP creation */
1526-
if (rq_size < 4 * max_msg_size)
1527-
rq_size = 4 * max_msg_size;
1526+
if (rq_size < 4ULL * max_msg_size)
1527+
rq_size = 4ULL * max_msg_size;
15281528

15291529
memset(tracker, 0, sizeof(*tracker));
15301530
tracker->uar = mlx5_get_uars_page(mdev);

0 commit comments

Comments
 (0)