aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kelly <mike.kelly@arm.com>2020-02-18 10:03:30 +0000
committerRyan O'Shea <ryan.oshea2@arm.com>2020-02-20 18:30:42 +0000
commiteec836eb731767eb2a0e8d86757de605bfd148d6 (patch)
tree924568d1b767959dd509820221429776790ce5f2
parent5ca1abf5b5f663a308b48b67bdae9c172d65bbd6 (diff)
downloadandroid-nn-driver-eec836eb731767eb2a0e8d86757de605bfd148d6.tar.gz
IVGCVSW-4375 Fixed driver crashes
* Fixed driver crashes caused by ignoring the result of GetTensorInt32Values. * Fixed driver crashes where padding, axis, permutation dimension or block size operands were inputs. Signed-off-by: Mike Kelly <mike.kelly@arm.com> Change-Id: I59867e9545a240e6be46b7f68da6adaa120a56d8
-rw-r--r--ConversionUtils.hpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp
index 550c320..5c6238e 100644
--- a/ConversionUtils.hpp
+++ b/ConversionUtils.hpp
@@ -1399,7 +1399,10 @@ bool ConvertPaddings(const HalOperation& operation,
}
std::vector<int32_t> paddings;
- GetTensorInt32Values<HalPolicy>(*paddingsOperand, paddings, model, data);
+ if (!GetTensorInt32Values<HalPolicy>(*paddingsOperand, paddings, model, data))
+ {
+ return Fail("%s: Operation has invalid or unsupported paddings operand", __func__);
+ }
// add padding for each dimension of input tensor.
for (unsigned int i = 0; i < paddings.size() - 1; i += 2)
@@ -3271,9 +3274,9 @@ bool ConvertSqueeze(const HalOperation& operation, const HalModel& model, Conver
axis.assign(dimensionSequence,
dimensionSequence + rank);
}
- else
+ else if (!GetTensorInt32Values<HalPolicy>(*axisOperand, axis, model, data))
{
- GetTensorInt32Values<HalPolicy>(*axisOperand, axis, model, data);
+ return Fail("%s: Operation has an invalid or unsupported axis operand", __func__);
}
std::vector<uint32_t> outputDims;
@@ -3451,9 +3454,9 @@ bool ConvertTranspose(const HalOperation& operation, const HalModel& model, Conv
perm[rank - i] = boost::numeric_cast<int> (i - 1);
}
}
- else
+ else if (!GetTensorInt32Values<HalPolicy>(*permOperand, perm, model, data))
{
- GetTensorInt32Values<HalPolicy>(*permOperand, perm, model, data);
+ return Fail("%s: Operation has an invalid or unsupported permutation operand", __func__);
}
std::vector<uint32_t> outputDims(perm.begin(), perm.begin() + rank);
@@ -3634,7 +3637,10 @@ bool ConvertSpaceToBatchNd(const HalOperation& operation, const HalModel& model,
}
std::vector<int32_t> blockShape;
- GetTensorInt32Values<HalPolicy>(*blockShapeOperand, blockShape, model, data);
+ if (!GetTensorInt32Values<HalPolicy>(*blockShapeOperand, blockShape, model, data))
+ {
+ return Fail("%s: Operation has an invalid or unsupported block size operand", __func__);
+ }
if (std::any_of(blockShape.cbegin(), blockShape.cend(), [](int32_t i){ return i < 1; }))
{
return Fail("%s: Block shape must be at least 1 in all dimensions.", __func__);
@@ -3648,7 +3654,10 @@ bool ConvertSpaceToBatchNd(const HalOperation& operation, const HalModel& model,
std::vector<std::pair<unsigned int, unsigned int>> paddingList;
std::vector<int32_t> paddings;
- GetTensorInt32Values<HalPolicy>(*paddingsOperand, paddings, model, data);
+ if (!GetTensorInt32Values<HalPolicy>(*paddingsOperand, paddings, model, data))
+ {
+ return Fail("%s: Operation has an invalid or unsupported paddings operand", __func__);
+ }
for (unsigned int i = 0; i < paddings.size() - 1; i += 2)
{
int paddingBeforeInput = paddings[i];