Skip to content

Commit 2a6d8d2

Browse files
authored
[MEDIUM] Patch pytorch for CVE-2025-2953 (#13641)
1 parent e803fe7 commit 2a6d8d2

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

SPECS/pytorch/CVE-2025-2953.patch

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 9f61c215128adce56200d0bf30992e791725e4ad Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <v-shettigara@microsoft.com>
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+
common(self, shape1, shape2, op, dtype)
30+
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+
instantiate_device_type_tests(TestMkldnn, globals(), only_for=('cpu',))
40+
41+
if __name__ == '__main__':
42+
--
43+
2.45.3
44+

SPECS/pytorch/pytorch.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration.
33
Name: pytorch
44
Version: 2.2.2
5-
Release: 6%{?dist}
5+
Release: 7%{?dist}
66
License: BSD-3-Clause
77
Vendor: Microsoft Corporation
88
Distribution: Azure Linux
@@ -31,6 +31,7 @@ Patch6: CVE-2024-7776.patch
3131
Patch7: CVE-2021-22569.patch
3232
Patch8: CVE-2025-32434.patch
3333
Patch9: CVE-2025-3730.patch
34+
Patch10: CVE-2025-2953.patch
3435

3536
%description
3637
PyTorch is a Python package that provides two high-level features:
@@ -92,6 +93,9 @@ cp -arf docs %{buildroot}/%{_pkgdocdir}
9293
%{_docdir}/*
9394

9495
%changelog
96+
* Tue Apr 29 2025 Archana Shettigar <v-shettigara@microsoft.com> - 2.2.2-7
97+
- Patch CVE-2025-2953
98+
9599
* Wed Apr 23 2025 Kanishk Bansal <kanbansal@microsoft.com> - 2.2.2-6
96100
- Patch CVE-2025-32434, CVE-2025-3730
97101

0 commit comments

Comments
 (0)