Skip to content

Commit 458c5db

Browse files
pytorch: fix cve-2024-31580
1 parent a3681e1 commit 458c5db

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

SPECS/pytorch/CVE-2024-31580.patch

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From b5c3a17c2c207ebefcb85043f0cf94be9b2fef81 Mon Sep 17 00:00:00 2001
2+
From: Octavian Guzu <octavguzu@fb.com>
3+
Date: Tue, 3 Oct 2023 18:48:08 +0000
4+
Subject: [PATCH] [fuzzing result][fuzz_torch_jit_lite_interpreter]
5+
read-heap-buffer-overflow-far-from-bounds (size 4) in c10::IValue::IValue()
6+
(#110441)
7+
8+
Summary: This diff fixes a heap underflow found by fuzzing in torch/csrc/jit/runtime/vararg_functions.cpp
9+
10+
Test Plan:
11+
CI and
12+
```
13+
arc lionhead crash reproduce 1753074381791061
14+
```
15+
doesn't crash anymore.
16+
17+
Differential Revision: D49537535
18+
19+
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110441
20+
Approved by: https://github.com/Skylion007
21+
---
22+
torch/csrc/jit/runtime/vararg_functions.cpp | 3 +++
23+
1 file changed, 3 insertions(+)
24+
25+
diff --git a/torch/csrc/jit/runtime/vararg_functions.cpp b/torch/csrc/jit/runtime/vararg_functions.cpp
26+
index 69e2c0fc1790603..bb28b61fe7e2c89 100644
27+
--- a/torch/csrc/jit/runtime/vararg_functions.cpp
28+
+++ b/torch/csrc/jit/runtime/vararg_functions.cpp
29+
@@ -267,6 +267,9 @@ void listUnpack(Stack& stack, size_t num_outputs) {
30+
}
31+
32+
void tupleConstruct(Stack& stack, size_t num_inputs) {
33+
+ if (num_inputs > stack.size()) {
34+
+ TORCH_CHECK(false, "Invalid number of inputs: ", num_inputs);
35+
+ }
36+
switch (num_inputs) {
37+
case 0:
38+
stack.emplace_back(c10::ivalue::Tuple::create());

SPECS/pytorch/pytorch.spec

Lines changed: 6 additions & 2 deletions
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.0.0
5-
Release: 3%{?dist}
5+
Release: 4%{?dist}
66
License: BSD-3-Clause
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
@@ -11,6 +11,7 @@ URL: https://pytorch.org/
1111
Source0: https://github.com/pytorch/pytorch/releases/download/v%{version}/%{name}-v%{version}.tar.gz#/%{name}-%{version}.tar.gz
1212
# Use the generate_source_tarball.sh script to create a tarball of submodules during version updates.
1313
Source1: %{name}-%{version}-submodules.tar.gz
14+
Patch0: CVE-2024-31580.patch
1415
BuildRequires: cmake
1516
BuildRequires: gcc
1617
BuildRequires: gcc-c++
@@ -55,7 +56,7 @@ PyTorch is a Python package that provides two high-level features:
5556
You can reuse your favorite Python packages such as NumPy, SciPy and Cython to extend PyTorch when needed.
5657

5758
%prep
58-
%autosetup -a 1 -n %{name}-v%{version}
59+
%autosetup -a 1 -p 1 -n %{name}-v%{version}
5960

6061
%build
6162
# Use MAX_JOBS=8 to prevent build failure in ADO pipelines
@@ -82,6 +83,9 @@ cp -arf docs %{buildroot}/%{_pkgdocdir}
8283
%{_docdir}/*
8384

8485
%changelog
86+
* Mon Apr 22 2024 Dan Streetman <ddstreet@microsoft.com> - 2.0.0-4
87+
- patch CVE-2024-31580
88+
8589
* Mon Dec 18 2023 Mandeep Plaha <mandeepplaha@microsoft.com> - 2.0.0-3
8690
- Set MAX_JOBS=8 to prevent build failure in ADO pipelines
8791

0 commit comments

Comments
 (0)