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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <61a12a08-86bf-498f-8e3e-a49a91c1bbd1@collabora.com>
Date: Thu, 11 Dec 2025 07:58:57 +0300
From: Dmitry Osipenko <dmitry.osipenko@...labora.com>
To: Alexey Simakov <bigalex934@...il.com>, David Airlie <airlied@...hat.com>
Cc: Gerd Hoffmann <kraxel@...hat.com>,
 Gurchetan Singh <gurchetansingh@...omium.org>, Chia-I Wu
 <olvaffe@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 Simona Vetter <simona@...ll.ch>, Lingfeng Yang <lfy@...gle.com>,
 dri-devel@...ts.freedesktop.org, virtualization@...ts.linux.dev,
 linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] drm/virtio: fix undefined behavior in capset shift
 calculation

On 12/8/25 19:02, Alexey Simakov wrote:
> According to MAX_CAPSET_ID, possible values of vgdev->capsets[i].id
> range from 0 to 63. Since the intermediate calculation uses type int,
> shifting by values larger than the bit width of int is undefined
> behavior as per the C language standard.
> 
> Explicitly cast the left-shift operand to ULL to prevent undefined
> behavior during the calculation.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> Fixes: 1925d6a7e0f4 ("drm/virtio: implement context init: track valid capabilities in a mask")
> Signed-off-by: Alexey Simakov <bigalex934@...il.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_kms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index 1c15cbf326b7..2e0ec7590ac2 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -104,7 +104,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
>  			return;
>  		}
>  
> -		vgdev->capset_id_mask |= 1 << vgdev->capsets[i].id;
> +		vgdev->capset_id_mask |= 1ULL << vgdev->capsets[i].id;
>  		DRM_INFO("cap set %d: id %d, max-version %d, max-size %d\n",
>  			 i, vgdev->capsets[i].id,
>  			 vgdev->capsets[i].max_version,

Reviewed-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>

-- 
Best regards,
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ