From 968a13a916bf2ae292ab5ba3f94e309d3a1b0d37 Mon Sep 17 00:00:00 2001 From: yserrr Date: Sun, 10 May 2026 19:25:52 +0000 Subject: [PATCH] llvmpipe: fix UB and incorrect value in compute caps shift `1 << 31` invokes signed shift UB. When the int result is assigned to uint64_t, sign extension produces 0xFFFFFFFF80000000 (~18 EiB) instead of the intended 0x80000000 (2 GiB). Use 1ull << 31 to perform the shift in unsigned 64-bit type. The 2 GiB value matches the surrounding finite cap values and OpenCL minimum requirements, making the original intent clear. Detected by UBSan with piglit. Fixes: a65b74af5139 ("llvmpipe: init shader and compute caps") Signed-off-by: yserrr Reviewed-by: Karol Herbst Part-of: --- src/gallium/drivers/llvmpipe/lp_screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 309c3d1f0a6..622f759812a 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -175,8 +175,8 @@ llvmpipe_init_compute_caps(struct pipe_screen *screen) caps->max_local_size = 32768; caps->grid_dimension = 3; - caps->max_global_size = 1 << 31; - caps->max_mem_alloc_size = 1 << 31; + caps->max_global_size = 1ull << 31; + caps->max_mem_alloc_size = 1ull << 31; caps->subgroup_sizes = lp_native_vector_width / 32; caps->max_subgroups = 1024 / (lp_native_vector_width / 32); caps->max_compute_units = 8;