TensorFlow is an open source platform for machine learning. In affected versions TensorFlow allows tensor to have a large number of dimensions and each dimension can be as large as desired. However, the total number of elements in a tensor must fit within an `int64_t`. If an overflow occurs, `MultiplyWithoutOverflow` would return a negative result. In the majority of TensorFlow codebase this then results in a `CHECK`-failure. Newer constructs exist which return a `Status` instead of crashing the binary. This is similar to CVE-2021-29584. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
455FB550-4C9C-4BD6-9F76-A627B62AB332
2.4.4
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
035CDF63-1548-4FB4-B8A9-B8D328FAF910
2.5.2
2.5.0
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
5D68D8D1-DB27-4395-9D3D-2BED901B852C
2.6.1
2.6.0
OR
**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 2.6.0
- Python version: 3.6.8
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A

**Describe the current behavior**
`tf.pad` crashes when the argument "paddings" has large values.

**Describe the expected behavior**
Expect an exception to be thrown if the input `paddings` is unexpected.

**Standalone code to reproduce the issue**
```
import tensorflow as tf
input_tensor = tf.random.uniform([1, 32, 32, 3], dtype=tf.float32)
paddings = [[125106557, 1415887920], [747509374, 2136925906], [413308538, 904601717], [1900762018, 831358864]]
res = tf.pad(input_tensor,paddings)
```
outputs:
```
2021-09-09 12:46:38.123113: F tensorflow/core/framework/tensor_shape.cc:352] Check failed: 0 <= new_num_elements (0 vs. -1)
Aborted (core dumped)
```

tf.pad crashes with large paddings
This is a GitHub Issue
repo:tensorflow
owner:tensorflow
Title : tf.pad crashes with large paddings
Issue date:

--- start body ---
**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 2.6.0
- Python version: 3.6.8
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A

**Describe the current behavior**
`tf.pad` crashes when the argument "paddings" has large values.

**Describe the expected behavior**
Expect an exception to be thrown if the input `paddings` is unexpected.

**Standalone code to reproduce the issue**
```
import tensorflow as tf
input_tensor = tf.random.uniform([1, 32, 32, 3], dtype=tf.float32)
paddings = [[125106557, 1415887920], [747509374, 2136925906], [413308538, 904601717], [1900762018, 831358864]]
res = tf.pad(input_tensor,paddings)
```
outputs:
```
2021-09-09 12:46:38.123113: F tensorflow/core/framework/tensor_shape.cc:352] Check failed: 0 <= new_num_elements (0 vs. -1)
Aborted (core dumped)
```

--- end body ---

comments :
--- start comments ---

--- end comments ---