From ca1923a820e357458ecf7b067582b2d1b43e2c1a Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Fri, 27 Mar 2026 19:06:09 +0800 Subject: [PATCH] pvr: follow other drivers' practice for copying build ID Previously the output length of pvr_get_driver_build_sha() is changed to BUILD_ID_EXPECTED_HASH_LENGTH, but the array defined to receive its output, the driver_build_sha array inside struct pvr_instance, is declared with BLAKE3_KEY_LEN, which is longer than BUILD_ID_EXPECTED_HASH_LENGTH. This leads to uninitialized memory being accessed when creating pipelineCacheUUID value, and the pipelineCacheUUID value would become random in each run, defecting the purpose of it. Refactor the code copying the build ID to follow other drivers: changing the parameter from the buffer to the instance pointer, inserting a static assert thanks to being able to retrieve the destination buffer length (as an array inside the instance structure) and using copy_build_id_to_sha1() to do the final copy. Fixes: 6a42493c94b6 ("pvr: Use BUILD_ID_EXPECTED_HASH_LENGTH") Signed-off-by: Icenowy Zheng Reviewed-by: Ella Stanforth (cherry picked from commit 9870c8d8c4bfff16f2c60f378742d144242f08e6) Part-of: --- .pick_status.json | 2 +- src/imagination/vulkan/pvr_instance.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 903d1faadc0..3147b048195 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4454,7 +4454,7 @@ "description": "pvr: follow other drivers' practice for copying build ID", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "6a42493c94b669108a36d0c83f1ab0c6c67397ba", "notes": null diff --git a/src/imagination/vulkan/pvr_instance.c b/src/imagination/vulkan/pvr_instance.c index 632b2bc70df..498857c1a6f 100644 --- a/src/imagination/vulkan/pvr_instance.c +++ b/src/imagination/vulkan/pvr_instance.c @@ -306,7 +306,7 @@ out: } static bool -pvr_get_driver_build_sha(uint8_t sha_out[const static BUILD_ID_EXPECTED_HASH_LENGTH]) +pvr_get_driver_build_sha(struct pvr_instance *instance) { const struct build_id_note *note; unsigned build_id_len; @@ -323,7 +323,8 @@ pvr_get_driver_build_sha(uint8_t sha_out[const static BUILD_ID_EXPECTED_HASH_LEN return false; } - memcpy(sha_out, build_id_data(note), BUILD_ID_EXPECTED_HASH_LENGTH); + STATIC_ASSERT(sizeof(instance->driver_build_sha) == SHA1_DIGEST_LENGTH); + copy_build_id_to_sha1(instance->driver_build_sha, note); return true; } @@ -373,7 +374,7 @@ VkResult pvr_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false)); - if (!pvr_get_driver_build_sha(instance->driver_build_sha)) { + if (!pvr_get_driver_build_sha(instance)) { result = vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED, "Failed to get driver build sha.");