diff --git a/0001-Workaround-NVCC-parse-failure-in-cast_op.patch b/0001-Workaround-NVCC-parse-failure-in-cast_op.patch deleted file mode 100644 index 01c0fe0003ea0accd9172a79e94d5167206a8c47..0000000000000000000000000000000000000000 --- a/0001-Workaround-NVCC-parse-failure-in-cast_op.patch +++ /dev/null @@ -1,51 +0,0 @@ -From e61ab44254dd585ba0f1bb6d056ecf2dbec7c24a Mon Sep 17 00:00:00 2001 -From: zhongling -Date: Thu, 2 Nov 2023 11:46:58 +0800 -Subject: [PATCH] Workaround NVCC parse failure in cast_op -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -There is a bug in some CUDA versions (observed in CUDA 12.1 and 11.7 w/ -GCC 12.2), that makes cast_op fail to compile: -cast.h:45:120: error: expected template-name before ‘<’ token - -Defining the nested type as an alias and using it allows this to work -without any change in semantics. - -Fixes #4606 - -The alternative using a static_cast or similar fails due to ambiguity -with the const Foo& and Foo& operators (one of the tests) - -see also: https://github.com/pybind/pybind11/pull/4893/files ---- - third_party/pybind11/include/pybind11/cast.h | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/third_party/pybind11/include/pybind11/cast.h b/third_party/pybind11/include/pybind11/cast.h -index 430c62f3..0482e212 100644 ---- a/third_party/pybind11/include/pybind11/cast.h -+++ b/third_party/pybind11/include/pybind11/cast.h -@@ -39,13 +39,15 @@ using make_caster = type_caster>; - // Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T - template - typename make_caster::template cast_op_type cast_op(make_caster &caster) { -- return caster.operator typename make_caster::template cast_op_type(); -+ using result_t = typename make_caster::template cast_op_type; -+ return caster.operator result_t(); - } - template - typename make_caster::template cast_op_type::type> - cast_op(make_caster &&caster) { -- return std::move(caster).operator typename make_caster:: -- template cast_op_type::type>(); -+ using result_t = typename make_caster::template cast_op_type< -+ typename std::add_rvalue_reference::type>; -+ return std::move(caster).operator result_t(); - } - - template --- -2.40.1 - diff --git a/0001-add-patch-to-fix-CVE-2025-2999.patch b/0001-add-patch-to-fix-CVE-2025-2999.patch new file mode 100644 index 0000000000000000000000000000000000000000..f43c3dfb4b939eb120b15a1deac7c4f0bf496012 --- /dev/null +++ b/0001-add-patch-to-fix-CVE-2025-2999.patch @@ -0,0 +1,70 @@ +From 494518046816d29099b7d056a74ffa5c244fdcdd Mon Sep 17 00:00:00 2001 +From: Nikita Shulga +Date: Mon, 10 Nov 2025 22:49:15 -0800 +Subject: [PATCH] Add empty tensor check for `_pad_packed_sequence` (#167521) + +That prevents null pointer dereference + +Fixes https://github.com/pytorch/pytorch/issues/149622 +Pull Request resolved: https://github.com/pytorch/pytorch/pull/167521 +Approved by: https://github.com/albanD +--- + aten/src/ATen/native/PackedSequence.cpp | 1 + + test/nn/test_packed_sequence.py | 29 +++++++++++++++++++++++++ + 2 files changed, 30 insertions(+) + +diff --git a/aten/src/ATen/native/PackedSequence.cpp b/aten/src/ATen/native/PackedSequence.cpp +index d06910834..8049be71e 100644 +--- a/aten/src/ATen/native/PackedSequence.cpp ++++ b/aten/src/ATen/native/PackedSequence.cpp +@@ -121,6 +121,7 @@ Tensor _pack_padded_sequence_backward_symint(const Tensor& grad, c10::SymIntArra + auto grad_input = at::zeros_symint(input_size_after_t, grad.options()); + auto batch_sizes_t = _batch_sizes.contiguous(); + checkLongTensor(batch_sizes_t); ++ TORCH_CHECK(batch_sizes_t.numel() > 0, "batch_sizes can not be empty"); + + int64_t offset = 0; + // NOTE: this op advertises as CompositeImplicitAutograd, but uses data_ptr(). +diff --git a/test/nn/test_packed_sequence.py b/test/nn/test_packed_sequence.py +index 0d6de0145..a33fc400c 100644 +--- a/test/nn/test_packed_sequence.py ++++ b/test/nn/test_packed_sequence.py +@@ -492,6 +492,35 @@ class PackedSequenceTest(TestCase): + torch.randn([0, 1, 10]), torch.randn([11, 14, 14, 2]), True + ) + ++ def test_empty_packed_sequence(self): ++ """ ++ Regression test for https://github.com/pytorch/pytorch/issues/149622 ++ Tests that pad_packed_sequence and unpack_sequence handle empty tensors ++ without segmentation fault (CVE-2025-2998, CVE-2025-2999) ++ """ ++ # Test case 1: pad_packed_sequence with empty tensors ++ # Previously caused segmentation fault ++ empty_data = torch.randn(0, 5) ++ empty_batch_sizes = torch.tensor([], dtype=torch.int64) ++ empty_packed = rnn_utils.PackedSequence( ++ empty_data, empty_batch_sizes, None, None ++ ) ++ ++ # Should not crash - either return empty result or raise informative error ++ with self.assertRaises(RuntimeError): ++ rnn_utils.pad_packed_sequence(empty_packed, batch_first=True) ++ ++ # Test case 2: unpack_sequence with empty tensors ++ # Previously caused segmentation fault ++ empty_data = torch.tensor([]) ++ empty_batch_sizes = torch.tensor([], dtype=torch.int64) ++ packed = rnn_utils.PackedSequence( ++ data=empty_data, batch_sizes=empty_batch_sizes ++ ) ++ ++ # Should not crash - either return empty list or raise informative error ++ with self.assertRaises(RuntimeError): ++ rnn_utils.unpack_sequence(packed) + + if __name__ == "__main__": + run_tests() +-- +2.47.3 + diff --git a/download b/download index e3eba1a46c5c06065ca0599e473534772d561e47..4ec6c288899d11a3c8c615688f713ce11271315d 100644 --- a/download +++ b/download @@ -1 +1 @@ -6186b06618415e1c4a2c9f057893c4f0 pytorch-v2.0.1.tar.gz +687f42206acc342c7e97a4bdeb44c98a pytorch-v2.8.0.tar.gz diff --git a/pytorch.spec b/pytorch.spec index c04ea59aa98c919ed22e036fcf9f6e5e159d6002..f5ef5b9e89a8a009b0bde0a0c0419909241a812f 100644 --- a/pytorch.spec +++ b/pytorch.spec @@ -1,4 +1,4 @@ -%define anolis_release 4 +%define anolis_release 1 %global vcu_maj 12 %global vcu_min 1 @@ -8,49 +8,29 @@ %undefine _annotated_build %undefine _find_debuginfo_dwz_opts %undefine _missing_build_ids_terminate_build - +ExcludeArch: loongarch64 Name: pytorch -Version: 2.0.1 +Version: 2.8.0 Release: %{anolis_release}%{dist} Summary: PyTorch Neural Network Package -License: BSD +License: BSD-3-Clause 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/Nicoshev/pytorch/commit/494518046816d29099b7d056a74ffa5c244fdcdd +Patch0001: 0001-add-patch-to-fix-CVE-2025-2999.patch BuildRequires: python3-devel cmake gcc-c++ BuildRequires: python3-typing-extensions python3-pyyaml python3-setuptools BuildRequires: python3-six python3-numpy - -BuildRequires: cuda-nvcc-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-nvtx-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-cupti-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-cudart-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-nvml-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-nvrtc-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-driver-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: cuda-profiler-api-%{vcu_maj}-%{vcu_min} -BuildRequires: libcublas-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libcufft-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libcurand-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libcusparse-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libcusolver-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libnvjitlink-devel-%{vcu_maj}-%{vcu_min} -BuildRequires: libnccl-devel -BuildRequires: libcudnn-devel -BuildRequires: magma-devel numactl-devel +BuildRequires: python3-astunparse +BuildRequires: python3-requests +BuildRequires: python3-wheel BuildRequires: chrpath - -Requires: cuda-cudart-%{vcu_maj}-%{vcu_min} -Requires: cuda-nvrtc-%{vcu_maj}-%{vcu_min} -Requires: cuda-nvtx-%{vcu_maj}-%{vcu_min} -Requires: libcublas-%{vcu_maj}-%{vcu_min} -Requires: libcufft-%{vcu_maj}-%{vcu_min} -Requires: libcurand-%{vcu_maj}-%{vcu_min} -Requires: libcusparse-%{vcu_maj}-%{vcu_min} -Requires: libcusolver-%{vcu_maj}-%{vcu_min} -Requires: libnvjitlink-%{vcu_maj}-%{vcu_min} +BuildRequires: python3-fsspec +BuildRequires: python3-sympy +BuildRequires: python3-typing-extensions Provides: pytorch-python3 = %{version}-%{release} Obsoletes: pytorch-python3 < %{version}-%{release} @@ -67,39 +47,31 @@ Requires: %{name} = %{version}-%{release} This package contains development files for pythorch. %prep -%setup -q -n %{name}-v%{version} -%patch0 -p1 +%autosetup -n %{name}-v%{version} -p1 %build -export BUILD_TEST=False -export PYTORCH_BUILD_VERSION=%{version} -export PYTORCH_BUILD_NUMBER=1 -export CUDAARCHS="all" -export CMAKE_CUDA_COMPILER=/usr/local/cuda-%{vcu_maj}.%{vcu_min}/bin/nvcc -export TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6" +export USE_CUDA=0 +export USE_NCCL=0 +export USE_SYSTEM_NCCL=0 export CFLAGS="${CFLAGS} -Wno-maybe-uninitialized -Wno-uninitialized -Wno-free-nonheap-object -Wno-restrict" export CXXFLAGS=$CFLAGS python3 setup.py build %install -export BUILD_TEST=False -export PYTORCH_BUILD_VERSION=%{version} -export PYTORCH_BUILD_NUMBER=1 -export CUDAARCHS="all" -export CMAKE_CUDA_COMPILER=/usr/local/cuda-%{vcu_maj}.%{vcu_min}/bin/nvcc -export TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6" +export USE_CUDA=0 +export USE_NCCL=0 +export USE_SYSTEM_NCCL=0 export CFLAGS="${CFLAGS} -Wno-maybe-uninitialized -Wno-uninitialized -Wno-free-nonheap-object -Wno-restrict" export CXXFLAGS=$CFLAGS mkdir %{buildroot}/usr python3 setup.py install --prefix %{buildroot}/usr -chrpath -d %{buildroot}/%{python3_sitearch}/torch/lib/* -chrpath -d %{buildroot}/%{python3_sitearch}/torch/bin/* -chrpath -d %{buildroot}/%{python3_sitearch}/nvfuser/*.so -chrpath -d %{buildroot}/%{python3_sitearch}/functorch/*.so +find %{buildroot}/%{python3_sitearch}/torch/lib -maxdepth 1 -type f -name '*.so' -print0 | xargs -0r chrpath -d +find %{buildroot}/%{python3_sitearch}/torch/bin -maxdepth 1 -type f -print0 | xargs -0r chrpath -d +find %{buildroot}/%{python3_sitearch}/functorch -maxdepth 1 -type f -name '*.so' -print0 | xargs -0r chrpath -d mkdir -p %{buildroot}/etc/ld.so.conf.d echo "%{python3_sitearch}/torch/lib" > %{buildroot}/etc/ld.so.conf.d/torch.conf @@ -107,14 +79,14 @@ echo "%{python3_sitearch}/torch/lib" > %{buildroot}/etc/ld.so.conf.d/torch.conf %ldconfig_scriptlets %pretrans -p -path = "/usr/lib64/python3.10/site-packages/torch/lib" +path = "/usr/lib64/python3.11/site-packages/torch/lib" st = posix.stat(path) if st and st.type == "link" then os.remove(path) end %pretrans devel -p -path = "/usr/lib64/python3.10/site-packages/torch/include" +path = "/usr/lib64/python3.11/site-packages/torch/include" st = posix.stat(path) if st and st.type == "link" then os.remove(path) @@ -136,6 +108,11 @@ end %{python3_sitearch}/torch/share %changelog +* Thu Jan 08 2026 lzq11122 - 2.8.0-1 +- Update to 2.8.0 for fix CVE-2025-55557,CVE-2025-55553,CVE-2025-55560, +CVE-2025-2999,CVE-2025-46148,CVE-2025-55558,CVE-2025-63396,CVE-2025-32434 +- Remove patch new version include + * Thu Nov 2 2023 Zhongling He - 2.0.1-4 - fix NVCC parse failure in cast_op