Skip to content

Commit ce58cea

Browse files
committed
backport: cpu: aarch64: fix potential overflow in ACL strides
Signed-off-by: Fadi Arafeh <[email protected]>
1 parent 3dc6a7d commit ce58cea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cpu/aarch64/acl_utils.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*******************************************************************************/
1616

1717
#include "cpu/aarch64/acl_utils.hpp"
18+
#include <limits>
1819

1920
namespace dnnl {
2021
namespace impl {
@@ -154,8 +155,12 @@ status_t tensor_info(
154155
for (int i = md.ndims() - 1; i >= 0; --i) {
155156
// ACL strides are in bytes, oneDNN strides are in numbers of elements,
156157
// multiply by data type size to convert
157-
strides_in_bytes.set(
158-
acl_stride_i, blocking_desc.strides[i] * md.data_type_size());
158+
size_t size = blocking_desc.strides[i] * md.data_type_size();
159+
// ACL stride value is uint32, check for overflow
160+
if (size > std::numeric_limits<uint32_t>::max()) {
161+
return status::unimplemented;
162+
}
163+
strides_in_bytes.set(acl_stride_i, size);
159164
++acl_stride_i;
160165
}
161166

0 commit comments

Comments
 (0)