lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250711150026.19818a98.alex.williamson@redhat.com>
Date: Fri, 11 Jul 2025 15:00:26 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Artem Sadovnikov <a.sadovnikov@...ras.ru>
Cc: kvm@...r.kernel.org, Yishai Hadas <yishaih@...dia.com>, Jason Gunthorpe
 <jgg@...pe.ca>, Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
 Kevin Tian <kevin.tian@...el.com>, linux-kernel@...r.kernel.org,
 lvc-project@...uxtesting.org
Subject: Re: [PATCH v2] vfio/mlx5: fix possible overflow in tracking max
 message size

On Tue,  1 Jul 2025 14:40:17 +0000
Artem Sadovnikov <a.sadovnikov@...ras.ru> wrote:

> 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 <alex.williamson@...hat.com>
> Signed-off-by: Artem Sadovnikov <a.sadovnikov@...ras.ru>
> ---
> Changes from v1:
> - The constant type was changed instead of variable type.
> - The patch name was accidentally cut and is now fixed.
> - LKML: https://lore.kernel.org/all/20250629095843.13349-1-a.sadovnikov@ispras.ru/
> ---
>  drivers/vfio/pci/mlx5/cmd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c
> index 5b919a0b2524..a92b095b90f6 100644
> --- a/drivers/vfio/pci/mlx5/cmd.c
> +++ b/drivers/vfio/pci/mlx5/cmd.c
> @@ -1523,8 +1523,8 @@ int mlx5vf_start_page_tracker(struct vfio_device *vdev,
>  	log_max_msg_size = MLX5_CAP_ADV_VIRTUALIZATION(mdev, pg_track_log_max_msg_size);
>  	max_msg_size = (1ULL << log_max_msg_size);
>  	/* The RQ must hold at least 4 WQEs/messages for successful QP creation */
> -	if (rq_size < 4 * max_msg_size)
> -		rq_size = 4 * max_msg_size;
> +	if (rq_size < 4ULL * max_msg_size)
> +		rq_size = 4ULL * max_msg_size;
>  
>  	memset(tracker, 0, sizeof(*tracker));
>  	tracker->uar = mlx5_get_uars_page(mdev);

LGTM, Yishai?  Thanks,

Alex


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ