Skip to content

Commit 02134b0

Browse files
authored
Prevent clGetExtensionFunctionAddressForPlatform from returning ICD-specific symbols. (#253)
1 parent cfb99ae commit 02134b0

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

loader/icd_dispatch.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,25 @@ static inline void* clGetExtensionFunctionAddressForPlatform_body(
303303
// to get the extension function address.
304304

305305
KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(platform, NULL);
306+
307+
#define KHR_ICD_REJECT_EXTENSION_FUNCTION(name) \
308+
do \
309+
{ \
310+
if (!strcmp(function_name, #name)) \
311+
{ \
312+
return NULL; \
313+
} \
314+
} while (0)
315+
316+
// Reject ICD-specific functions that could be misused by users
317+
KHR_ICD_REJECT_EXTENSION_FUNCTION(clIcdGetPlatformIDsKHR);
318+
KHR_ICD_REJECT_EXTENSION_FUNCTION(clIcdGetFunctionAddressForPlatformKHR);
319+
KHR_ICD_REJECT_EXTENSION_FUNCTION(clIcdSetPlatformDispatchDataKHR);
320+
306321
return KHR_ICD2_DISPATCH(platform)->clGetExtensionFunctionAddressForPlatform(
307322
platform,
308323
function_name);
324+
#undef KHR_ICD_REJECT_EXTENSION_FUNCTION
309325
}
310326

311327
void* CL_API_CALL clGetExtensionFunctionAddressForPlatform_disp(

0 commit comments

Comments
 (0)