Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/executor/targets.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,6 +133,7 @@ def define_common_targets():
],
deps = [
"//executorch/schema:program",
"//executorch/runtime/core/exec_aten/util:tensor_dimension_limit"
],
visibility = [
"//executorch/runtime/executor/...",
Expand Down
8 changes: 8 additions & 0 deletions runtime/executor/tensor_parser_aten.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@

#include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h>
#include <executorch/runtime/core/named_data_map.h>
#include <executorch/runtime/executor/memory_manager.h>
#include <executorch/runtime/executor/program.h>
Expand DownExpand Up@@ -58,6 +59,13 @@ Result<at::Tensor> parseTensor(
s_tensor->sizes() != nullptr, InvalidProgram, "Missing sizes field");
size_t ndim = s_tensor->sizes()->size();

ET_CHECK_OR_RETURN_ERROR(
ndim <= kTensorDimensionLimit,
InvalidProgram,
"Tensor rank too large %" ET_PRIsize_t " > %zu",
ndim,
kTensorDimensionLimit)

ET_CHECK_OR_RETURN_ERROR(
s_tensor->dim_order() != nullptr,
InvalidProgram,
Expand Down
8 changes: 8 additions & 0 deletions runtime/executor/tensor_parser_portable.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@
#include <executorch/runtime/core/exec_aten/exec_aten.h>
#include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h>
#include <executorch/runtime/core/named_data_map.h>
#include <executorch/runtime/executor/memory_manager.h>
#include <executorch/runtime/executor/program.h>
Expand DownExpand Up@@ -62,6 +63,13 @@ Result<Tensor> parseTensor(
const auto serialized_sizes = s_tensor->sizes()->data();
const auto dim = s_tensor->sizes()->size();

ET_CHECK_OR_RETURN_ERROR(
dim <= kTensorDimensionLimit,
InvalidProgram,
"Tensor rank too large %" PRIu32 " > %zu",
dim,
kTensorDimensionLimit)

ET_CHECK_OR_RETURN_ERROR(
s_tensor->dim_order() != nullptr,
InvalidProgram,
Expand Down
Loading