rusticl: fix UB in CLProp machinery
authorLingMan <18294-LingMan@users.noreply.gitlab.freedesktop.org>
Wed, 14 Jun 2023 07:02:53 +0000 (09:02 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 15 Jun 2023 02:31:19 +0000 (02:31 +0000)
commit0535948535e0aa7702d4427f02e39a71ad2fac00
tree1011b266bc3cb529244ceb6d566ae81dba19e78a
parentfdcb86168d151adaf3385d580a9caabe48b66f88
rusticl: fix UB in CLProp machinery

Viewing structs as a collection of u8 is not generally sound. Any padding bytes might be
uninitialized and creating an integer from uninitialized memory constitutes producing an invalid
value, which is instant UB.

Since we only copy these bytes around, the fix is to simply work with MaybeUninit<u8>, which can handle uninitialized memory just fine, instead.

See: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23652>
src/gallium/frontends/rusticl/api/context.rs
src/gallium/frontends/rusticl/api/device.rs
src/gallium/frontends/rusticl/api/event.rs
src/gallium/frontends/rusticl/api/kernel.rs
src/gallium/frontends/rusticl/api/memory.rs
src/gallium/frontends/rusticl/api/platform.rs
src/gallium/frontends/rusticl/api/program.rs
src/gallium/frontends/rusticl/api/queue.rs
src/gallium/frontends/rusticl/api/util.rs