|
| 1 | +From 9f61c215128adce56200d0bf30992e791725e4ad Mon Sep 17 00:00:00 2001 |
| 2 | +From: archana25-ms < [email protected]> |
| 3 | +Date: Tue, 6 May 2025 20:12:29 +0000 |
| 4 | +Subject: [PATCH] Patch pytorch for CVE-2025-2953 |
| 5 | +Upstream Patch Reference: https://github.com/pytorch/pytorch/commit/6f327128a99debfb2312ee256523ad6b62f763d6 |
| 6 | + |
| 7 | +--- |
| 8 | + aten/src/ATen/native/mkldnn/Utils.cpp | 1 + |
| 9 | + test/test_mkldnn.py | 7 +++++++ |
| 10 | + 2 files changed, 8 insertions(+) |
| 11 | + |
| 12 | +diff --git a/aten/src/ATen/native/mkldnn/Utils.cpp b/aten/src/ATen/native/mkldnn/Utils.cpp |
| 13 | +index 400eb916..e240a2d2 100644 |
| 14 | +--- a/aten/src/ATen/native/mkldnn/Utils.cpp |
| 15 | ++++ b/aten/src/ATen/native/mkldnn/Utils.cpp |
| 16 | +@@ -19,6 +19,7 @@ std::vector<int64_t> pool_output_sizes( |
| 17 | + output_size[1] = input_size[1]; |
| 18 | + |
| 19 | + for (const auto i : c10::irange(2, input_size.size())) { |
| 20 | ++ TORCH_CHECK_VALUE(stride[i -2] > 0, "Strides must be positive!"); |
| 21 | + output_size[i] = pooling_output_shape_pad_lr<int64_t>( |
| 22 | + input_size[i], |
| 23 | + kernel_size[i - 2], |
| 24 | +diff --git a/test/test_mkldnn.py b/test/test_mkldnn.py |
| 25 | +index 7c39d36e..cf599c70 100644 |
| 26 | +--- a/test/test_mkldnn.py |
| 27 | ++++ b/test/test_mkldnn.py |
| 28 | +@@ -1588,6 +1588,13 @@ class TestMkldnn(TestCase): |
| 29 | + cn2.sum().backward(retain_graph=True) |
| 30 | + self.assertEqual(c1.grad, c2.grad, rtol=rtol, atol=atol) |
| 31 | + |
| 32 | ++ def test_mkldnn_error_on_zero_stride(self, device): |
| 33 | ++ # Regression test for https://github.com/pytorch/pytorch/issues/149274 |
| 34 | ++ x = torch.rand(1, 2, 3, 3).to_mkldnn() |
| 35 | ++ with self.assertRaises(ValueError): |
| 36 | ++ torch.mkldnn_max_pool2d(x, kernel_size=3, stride=0) |
| 37 | ++ |
| 38 | ++ |
| 39 | + |
| 40 | + if __name__ == '__main__': |
| 41 | + run_tests() |
| 42 | +-- |
| 43 | +2.45.3 |
| 44 | + |
0 commit comments