Skip to content

Commit eabbb15

Browse files
authored
[SYCL] Default-initialize UR structs used in handler_impl (#14885)
The C-style structs used by the `handler_impl` for bindless images are not initialized. Although their values get initialized later in execution, when it is decided this information is actually used, leaving these values uninitialized still leave the possibility of vulnerabilities. This PR initializes them. I'd like to bring attention to the fact that we could also use `std::optional` here, although that'll increase the size used for each field here. Zero initializing these structs is also an option, although I noticed many of these structs have default values, so I default initialized instead. If `std::optional` or zero initializing would be a better option here, please let me know and I'll make the changes. Thanks!
1 parent 1ebfd89 commit eabbb15

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sycl/source/detail/handler_impl.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ class handler_impl {
123123
bool MKernelUsesClusterLaunch = false;
124124

125125
// Extra information for bindless image copy
126-
ur_image_desc_t MSrcImageDesc;
127-
ur_image_desc_t MDstImageDesc;
128-
ur_image_format_t MSrcImageFormat;
129-
ur_image_format_t MDstImageFormat;
130-
ur_exp_image_copy_flags_t MImageCopyFlags;
131-
132-
ur_rect_offset_t MSrcOffset;
133-
ur_rect_offset_t MDestOffset;
134-
ur_rect_region_t MCopyExtent;
126+
ur_image_desc_t MSrcImageDesc = {};
127+
ur_image_desc_t MDstImageDesc = {};
128+
ur_image_format_t MSrcImageFormat = {};
129+
ur_image_format_t MDstImageFormat = {};
130+
ur_exp_image_copy_flags_t MImageCopyFlags = {};
131+
132+
ur_rect_offset_t MSrcOffset = {};
133+
ur_rect_offset_t MDestOffset = {};
134+
ur_rect_region_t MCopyExtent = {};
135135

136136
// Extra information for semaphore interoperability
137137
ur_exp_external_semaphore_handle_t MExternalSemaphore;

0 commit comments

Comments
 (0)