File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ def define_common_targets():
133
133
],
134
134
deps = [
135
135
"//executorch/schema:program" ,
136
+ "//executorch/runtime/core/exec_aten/util:tensor_dimension_limit"
136
137
],
137
138
visibility = [
138
139
"//executorch/runtime/executor/..." ,
Original file line number Diff line number Diff line change 10
10
11
11
#include < executorch/runtime/core/exec_aten/util/dim_order_util.h>
12
12
#include < executorch/runtime/core/exec_aten/util/scalar_type_util.h>
13
+ #include < executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h>
13
14
#include < executorch/runtime/core/named_data_map.h>
14
15
#include < executorch/runtime/executor/memory_manager.h>
15
16
#include < executorch/runtime/executor/program.h>
@@ -58,6 +59,13 @@ Result<at::Tensor> parseTensor(
58
59
s_tensor->sizes () != nullptr , InvalidProgram, " Missing sizes field" );
59
60
size_t ndim = s_tensor->sizes ()->size ();
60
61
62
+ ET_CHECK_OR_RETURN_ERROR (
63
+ ndim <= kTensorDimensionLimit ,
64
+ InvalidProgram,
65
+ " Tensor rank too large %" ET_PRIsize_t " > %zu" ,
66
+ ndim,
67
+ kTensorDimensionLimit )
68
+
61
69
ET_CHECK_OR_RETURN_ERROR (
62
70
s_tensor->dim_order () != nullptr ,
63
71
InvalidProgram,
Original file line number Diff line number Diff line change 11
11
#include < executorch/runtime/core/exec_aten/exec_aten.h>
12
12
#include < executorch/runtime/core/exec_aten/util/dim_order_util.h>
13
13
#include < executorch/runtime/core/exec_aten/util/scalar_type_util.h>
14
+ #include < executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h>
14
15
#include < executorch/runtime/core/named_data_map.h>
15
16
#include < executorch/runtime/executor/memory_manager.h>
16
17
#include < executorch/runtime/executor/program.h>
@@ -62,6 +63,13 @@ Result<Tensor> parseTensor(
62
63
const auto serialized_sizes = s_tensor->sizes ()->data ();
63
64
const auto dim = s_tensor->sizes ()->size ();
64
65
66
+ ET_CHECK_OR_RETURN_ERROR (
67
+ dim <= kTensorDimensionLimit ,
68
+ InvalidProgram,
69
+ " Tensor rank too large %" PRIu32 " > %zu" ,
70
+ dim,
71
+ kTensorDimensionLimit )
72
+
65
73
ET_CHECK_OR_RETURN_ERROR (
66
74
s_tensor->dim_order () != nullptr ,
67
75
InvalidProgram,
You can’t perform that action at this time.
0 commit comments