diff --git a/1001-add-patch-to-fix-CVE-2025-32434.patch b/1001-add-patch-to-fix-CVE-2025-32434.patch new file mode 100644 index 0000000000000000000000000000000000000000..24c80678f9a4a7d9e7846dc7a9831a609d120bcc --- /dev/null +++ b/1001-add-patch-to-fix-CVE-2025-32434.patch @@ -0,0 +1,61 @@ +From 1f16a8725893d13936236e8cd55872965e3a7533 Mon Sep 17 00:00:00 2001 +From: WB02254423 +Date: Mon, 17 Nov 2025 22:10:56 -0500 +Subject: [PATCH 1/1] add patch to fix CVE-2025-32434 + +--- + test/test_serialization.py | 6 +++++- + torch/serialization.py | 13 +++++++++---- + 2 files changed, 14 insertions(+), 5 deletions(-) + +diff --git a/test/test_serialization.py b/test/test_serialization.py +index 9b9a7133..822f5adb 100644 +--- a/test/test_serialization.py ++++ b/test/test_serialization.py +@@ -404,7 +404,11 @@ class SerializationMixin: + b += [a[0].storage()] + b += [a[0].reshape(-1)[1:4].clone().storage()] + path = download_file('https://download.pytorch.org/test_data/legacy_serialized.pt') +- c = torch.load(path, weights_only=weights_only) ++ if weights_only: ++ with self.assertRaisesRegex(RuntimeError, ++ "Cannot use ``weights_only=True`` with files saved in the legacy .tar format."): ++ c = torch.load(path, weights_only=weights_only) ++ c = torch.load(path, weights_only=False) + self.assertEqual(b, c, atol=0, rtol=0) + self.assertTrue(isinstance(c[0], torch.FloatTensor)) + self.assertTrue(isinstance(c[1], torch.FloatTensor)) +diff --git a/torch/serialization.py b/torch/serialization.py +index a3e1abdf..c964f40b 100644 +--- a/torch/serialization.py ++++ b/torch/serialization.py +@@ -768,9 +768,10 @@ def load( + """ + torch._C._log_api_usage_once("torch.load") + UNSAFE_MESSAGE = ( +- "Weights only load failed. Re-running `torch.load` with `weights_only` set to `False`" +- " will likely succeed, but it can result in arbitrary code execution." +- "Do it only if you get the file from a trusted source. WeightsUnpickler error: " ++ "In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` " ++ "from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, " ++ "but it can result in arbitrary code execution. Do it only if you got the file from a " ++ "trusted source." + ) + # Add ability to force safe only weight loads via environment variable + if os.getenv("TORCH_FORCE_WEIGHTS_ONLY_LOAD", "0").lower() in ['1', 'y', 'yes', 'true']: +@@ -900,7 +901,11 @@ def _legacy_load(f, map_location, pickle_module, **pickle_load_args): + + with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \ + mkdtemp() as tmpdir: +- ++ if pickle_module is _weights_only_unpickler: ++ raise RuntimeError( ++ "Cannot use ``weights_only=True`` with files saved in the " ++ "legacy .tar format. " + UNSAFE_MESSAGE ++ ) + tar.extract('storages', path=tmpdir) + with open(os.path.join(tmpdir, 'storages'), 'rb', 0) as f: + num_storages = pickle_module.load(f, **pickle_load_args) +-- +2.47.3 + diff --git a/pytorch.spec b/pytorch.spec index c04ea59aa98c919ed22e036fcf9f6e5e159d6002..339070ae75ebc014871eb457c038244e65d04e20 100644 --- a/pytorch.spec +++ b/pytorch.spec @@ -1,7 +1,7 @@ -%define anolis_release 4 +%define anolis_release 5 %global vcu_maj 12 -%global vcu_min 1 +%global vcu_min 5 %global _lto_cflags %{nil} %global __cmake_in_source_build 1 %undefine _hardened_build @@ -18,6 +18,8 @@ License: BSD URL: https://pytorch.org Source0: https://github.com/pytorch/pytorch/releases/download/v%{version}/pytorch-v%{version}.tar.gz Patch0: 0001-Workaround-NVCC-parse-failure-in-cast_op.patch +# https://github.com/pytorch/pytorch/commit/8d4b8a920a2172523deb95bf20e8e52d50649c04 +Patch1: 1001-add-patch-to-fix-CVE-2025-32434.patch BuildRequires: python3-devel cmake gcc-c++ BuildRequires: python3-typing-extensions python3-pyyaml python3-setuptools @@ -69,7 +71,7 @@ This package contains development files for pythorch. %prep %setup -q -n %{name}-v%{version} %patch0 -p1 - +%patch1 -p1 %build export BUILD_TEST=False @@ -136,6 +138,9 @@ end %{python3_sitearch}/torch/share %changelog +* Tue Nov 18 2025 lzq11122 - 2.0.1-5 +- Add patch to fix CVE-2025-32434 + * Thu Nov 2 2023 Zhongling He - 2.0.1-4 - fix NVCC parse failure in cast_op