Headline
CVE-2022-35999: Fix GPU/CPU Conv2DBackpropInputOp check error. · tensorflow/tensorflow@27a65a4
TensorFlow is an open source platform for machine learning. When Conv2DBackpropInput
receives empty out_backprop
inputs (e.g. [3, 1, 0, 1]
), the current CPU/GPU kernels CHECK
fail (one with dnnl, the other with cudnn). This can be used to trigger a denial of service attack. We have patched the issue in GitHub commit 27a65a43cf763897fecfa5cdb5cc653fc5dd0346. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.
@@ -37,6 +37,7 @@ limitations under the License.
#include “tensorflow/core/kernels/conv_2d.h”
#include “tensorflow/core/kernels/conv_grad_ops.h”
#include “tensorflow/core/kernels/conv_grad_shape_utils.h”
#include “tensorflow/core/kernels/fill_functor.h”
#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
#include “tensorflow/core/kernels/xsmm_conv2d.h”
#endif
@@ -436,6 +437,15 @@ class Conv2DBackpropInputOp : public OpKernel {
return;
}
// If shapes are valid but `out_backprop` is empty, in_backprop should be
// set to all zeros. Otherwise, cudnn/dnnl fail with an empty input.
if (out_backprop.NumElements() == 0) {
functor::SetZeroFunctor<Device, T> set_zero;
set_zero(context->eigen_device<Device>(),
in_backprop->template flat<T>());
return;
}
// For now we take the stride from the second and third dimensions only (we
// do not support striding on the batch or depth dimension).
const int stride_rows = GetTensorDim(strides_, data_format_, ‘H’);
@@ -554,6 +564,15 @@ class Conv2DCustomBackpropInputOp : public OpKernel {
return;
}
// If shapes are valid but `out_backprop` is empty, in_backprop should be
// set to all zeros. Otherwise, cudnn/dnnl fail with an empty input.
if (out_backprop.NumElements() == 0) {
functor::SetZeroFunctor<Device, T> set_zero;
set_zero(context->eigen_device<Device>(),
in_backprop->template flat<T>());
return;
}
// TODO(ezhulenev): Remove custom kernel and move XSMM support to
// LaunchConv2DBackpropInputOp functor.
#if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \
Related news
### Impact When `Conv2DBackpropInput` receives empty `out_backprop` inputs (e.g. `[3, 1, 0, 1]`), the current CPU/GPU kernels `CHECK` fail (one with dnnl, the other with cudnn). This can be used to trigger a denial of service attack. ```python import tensorflow as tf import numpy as np input_sizes = [3, 1, 1, 2] filter = np.ones([1, 3, 2, 3]) out_backprop = np.ones([3, 1, 0, 3]) strides = [1, 1, 2, 1] padding = 'VALID' tf.raw_ops.Conv2DBackpropInput( input_sizes = input_sizes, filter = filter, out_backprop = out_backprop, strides = strides, padding = padding ) ``` ### Patches We have patched the issue in GitHub commit [27a65a43cf763897fecfa5cdb5cc653fc5dd0346](https://github.com/tensorflow/tensorflow/commit/27a65a43cf763897fecfa5cdb5cc653fc5dd0346). The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. ### For more inform...