AddressSanitizer: heap-buffer-overflow in PwlApply32 (#9256)

* fixed bug related to AddressSanitizer

* changed the way of calculation of input bytes of pooling layer if a previous layer is convolution
This commit is contained in:
Dmitrii Khurtin 2021-12-22 13:31:01 +03:00 committed by GitHub
parent 8c746fd52c
commit 2ec04f9faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -883,6 +883,18 @@ void GNAGraphCompiler::PoolingPrimitive(InferenceEngine::CNNLayerPtr layer) {
uint32_t num_padding = ALIGN(hw_in, 8) - hw_in;
size_t num_data_bytes_in = c_dim_in * (hw_in + num_padding) * inputs->getPrecision().size();
if (dnn->new_num_conv_columns) {
uint32_t num_rows = 1;
uint32_t num_columns = c_dim_in * w_dim_in + (ALIGN(c_dim_in * w_dim_in, 8) - c_dim_in * w_dim_in);
if (dnn->new_num_conv_columns % num_columns == 0) {
num_rows = dnn->new_num_conv_columns / num_columns;
} else {
num_columns = dnn->new_num_conv_columns;
}
dnn->new_num_conv_columns = 0;
num_data_bytes_in = num_rows * num_columns * inputs->getPrecision().size();
}
connectInput(layer, ptr_inputs, num_data_bytes_in);
connectOutput(layer, ptr_outputs, num_data_bytes_out);
}
@ -2459,7 +2471,7 @@ GNAPluginNS::ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer,
// check for generic prev layer
if (prevDnnLayer != nullptr) {
gnamem->bind_ptr(layer, ptr, &prevDnnLayer->ptr_outputs, offset);
gnamem->bind_ptr(layer, ptr, &prevDnnLayer->ptr_outputs, offset, num_data_bytes_in);
return prevLayer;
}