diff --git a/include/ur_api.h b/include/ur_api.h index 258ea85e7a..141615ba1e 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -6217,6 +6217,11 @@ urEnqueueMemBufferCopyRect( /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT /// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `patternSize == 0 || size == 0` +/// + `patternSize > size` +/// + `(patternSize & (patternSize - 1)) != 0` +/// + `size % patternSize != 0` +/// + `offset % patternSize != 0` /// + If `offset + size` results in an out-of-bounds access. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES @@ -6266,6 +6271,8 @@ urEnqueueMemBufferFill( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES UR_APIEXPORT ur_result_t UR_APICALL @@ -6317,6 +6324,8 @@ urEnqueueMemImageRead( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES UR_APIEXPORT ur_result_t UR_APICALL @@ -6362,6 +6371,8 @@ urEnqueueMemImageWrite( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES UR_APIEXPORT ur_result_t UR_APICALL diff --git a/scripts/core/enqueue.yml b/scripts/core/enqueue.yml index aef1d8023b..67a3adbee6 100644 --- a/scripts/core/enqueue.yml +++ b/scripts/core/enqueue.yml @@ -571,6 +571,11 @@ returns: - "If event objects in phEventWaitList are not valid events." - $X_RESULT_ERROR_INVALID_MEM_OBJECT - $X_RESULT_ERROR_INVALID_SIZE: + - "`patternSize == 0 || size == 0`" + - "`patternSize > size`" + - "`(patternSize & (patternSize - 1)) != 0`" + - "`size % patternSize != 0`" + - "`offset % patternSize != 0`" - "If `offset + size` results in an out-of-bounds access." - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY - $X_RESULT_ERROR_OUT_OF_RESOURCES @@ -629,6 +634,8 @@ returns: - "`phEventWaitList != NULL && numEventsInWaitList == 0`" - "If event objects in phEventWaitList are not valid events." - $X_RESULT_ERROR_INVALID_MEM_OBJECT + - $X_RESULT_ERROR_INVALID_SIZE: + - "`region.width == 0 || region.height == 0 || region.depth == 0`" - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY - $X_RESULT_ERROR_OUT_OF_RESOURCES --- #-------------------------------------------------------------------------- @@ -686,6 +693,8 @@ returns: - "`phEventWaitList != NULL && numEventsInWaitList == 0`" - "If event objects in phEventWaitList are not valid events." - $X_RESULT_ERROR_INVALID_MEM_OBJECT + - $X_RESULT_ERROR_INVALID_SIZE: + - "`region.width == 0 || region.height == 0 || region.depth == 0`" - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY - $X_RESULT_ERROR_OUT_OF_RESOURCES --- #-------------------------------------------------------------------------- @@ -735,6 +744,8 @@ returns: - "`phEventWaitList != NULL && numEventsInWaitList == 0`" - "If event objects in phEventWaitList are not valid events." - $X_RESULT_ERROR_INVALID_MEM_OBJECT + - $X_RESULT_ERROR_INVALID_SIZE: + - "`region.width == 0 || region.height == 0 || region.depth == 0`" - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY - $X_RESULT_ERROR_OUT_OF_RESOURCES --- #-------------------------------------------------------------------------- diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 2e36eeeb2c..5df41be123 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -4525,6 +4525,26 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( if (phEventWaitList != NULL && numEventsInWaitList == 0) { return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; } + + if (patternSize == 0 || size == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + + if (patternSize > size) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + + if ((patternSize & (patternSize - 1)) != 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + + if (size % patternSize != 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + + if (offset % patternSize != 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = @@ -4584,6 +4604,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( if (phEventWaitList != NULL && numEventsInWaitList == 0) { return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; } + + if (region.width == 0 || region.height == 0 || region.depth == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = pfnMemImageRead( @@ -4644,6 +4668,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( if (phEventWaitList != NULL && numEventsInWaitList == 0) { return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; } + + if (region.width == 0 || region.height == 0 || region.depth == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = pfnMemImageWrite( @@ -4704,6 +4732,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( if (phEventWaitList != NULL && numEventsInWaitList == 0) { return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; } + + if (region.width == 0 || region.height == 0 || region.depth == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 5d0b64d922..9558288694 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -5197,6 +5197,11 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT /// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `patternSize == 0 || size == 0` +/// + `patternSize > size` +/// + `(patternSize & (patternSize - 1)) != 0` +/// + `size % patternSize != 0` +/// + `offset % patternSize != 0` /// + If `offset + size` results in an out-of-bounds access. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES @@ -5259,6 +5264,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferFill( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageRead( @@ -5324,6 +5331,8 @@ ur_result_t UR_APICALL urEnqueueMemImageRead( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageWrite( @@ -5385,6 +5394,8 @@ ur_result_t UR_APICALL urEnqueueMemImageWrite( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageCopy( diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 1d6371781b..4289b0fc53 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -4405,6 +4405,11 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT /// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `patternSize == 0 || size == 0` +/// + `patternSize > size` +/// + `(patternSize & (patternSize - 1)) != 0` +/// + `size % patternSize != 0` +/// + `offset % patternSize != 0` /// + If `offset + size` results in an out-of-bounds access. /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES @@ -4458,6 +4463,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferFill( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageRead( @@ -4515,6 +4522,8 @@ ur_result_t UR_APICALL urEnqueueMemImageRead( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageWrite( @@ -4567,6 +4576,8 @@ ur_result_t UR_APICALL urEnqueueMemImageWrite( /// + `phEventWaitList != NULL && numEventsInWaitList == 0` /// + If event objects in phEventWaitList are not valid events. /// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `region.width == 0 || region.height == 0 || region.depth == 0` /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES ur_result_t UR_APICALL urEnqueueMemImageCopy(