mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfio/mlx5: fix possible overflow in tracking max
@ 2025-06-29  9:58 Artem Sadovnikov
  2025-06-30 17:28 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Artem Sadovnikov @ 2025-06-29  9:58 UTC (permalink / raw)
  To: kvm
  Cc: Artem Sadovnikov, Yishai Hadas, Jason Gunthorpe,
	Shameer Kolothum, Kevin Tian, Alex Williamson, linux-kernel,
	lvc-project

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 max_msg_size up to u64 so multiplication will
be extended to u64.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
---
 drivers/vfio/pci/mlx5/cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c
index 5b919a0b2524..0bdaf1d23a78 100644
--- a/drivers/vfio/pci/mlx5/cmd.c
+++ b/drivers/vfio/pci/mlx5/cmd.c
@@ -1503,7 +1503,7 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,
 	struct mlx5_vhca_qp *fw_qp;
 	struct mlx5_core_dev *mdev;
 	u32 log_max_msg_size;
-	u32 max_msg_size;
+	u64 max_msg_size;
 	u64 rq_size = SZ_2M;
 	u32 max_recv_wr;
 	int err;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-01 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-29  9:58 [PATCH] vfio/mlx5: fix possible overflow in tracking max Artem Sadovnikov
2025-06-30 17:28 ` Alex Williamson
2025-07-01 14:18   ` Yishai Hadas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®