Skip to content

Commit 1a1c51b

Browse files
[AUTO-CHERRYPICK] [Medium] patch openmpi to fix CVE-2022-47022 - branch main (#12132)
Co-authored-by: jykanase <v-jykanase@microsoft.com>
1 parent c89c217 commit 1a1c51b

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

SPECS/openmpi/CVE-2022-47022.patch

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
From 6f10f14877d8637a3d561b2eb00e56bb3da178c2 Mon Sep 17 00:00:00 2001
2+
From: jykanase <v-jykanase@microsoft.com>
3+
Date: Wed, 29 Jan 2025 07:14:24 +0000
4+
Subject: [PATCH] CVE-2022-47022
5+
6+
Source Link: https://github.com/open-mpi/hwloc/commit/ac1f8db9a0790d2bf153711ff4cbf6101f89aace
7+
---
8+
.../hwloc/hwloc201/hwloc/hwloc/topology-linux.c | 15 ++++++++++++++-
9+
1 file changed, 14 insertions(+), 1 deletion(-)
10+
11+
diff --git a/opal/mca/hwloc/hwloc201/hwloc/hwloc/topology-linux.c b/opal/mca/hwloc/hwloc201/hwloc/hwloc/topology-linux.c
12+
index 2c60b1e..62ddedf 100644
13+
--- a/opal/mca/hwloc/hwloc201/hwloc/hwloc/topology-linux.c
14+
+++ b/opal/mca/hwloc/hwloc201/hwloc/hwloc/topology-linux.c
15+
@@ -806,6 +806,8 @@ hwloc_linux_set_tid_cpubind(hwloc_topology_t topology __hwloc_attribute_unused,
16+
17+
setsize = CPU_ALLOC_SIZE(last+1);
18+
plinux_set = CPU_ALLOC(last+1);
19+
+ if (!plinux_set)
20+
+ return -1;
21+
22+
CPU_ZERO_S(setsize, plinux_set);
23+
hwloc_bitmap_foreach_begin(cpu, hwloc_set)
24+
@@ -886,7 +888,10 @@ hwloc_linux_find_kernel_nr_cpus(hwloc_topology_t topology)
25+
while (1) {
26+
cpu_set_t *set = CPU_ALLOC(nr_cpus);
27+
size_t setsize = CPU_ALLOC_SIZE(nr_cpus);
28+
- int err = sched_getaffinity(0, setsize, set); /* always works, unless setsize is too small */
29+
+ int err;
30+
+ if (!set)
31+
+ return -1; /* caller will return an error, and we'll try again later */
32+
+ err = sched_getaffinity(0, setsize, set); /* always works, unless setsize is too small */
33+
CPU_FREE(set);
34+
nr_cpus = setsize * 8; /* that's the value that was actually tested */
35+
if (!err)
36+
@@ -914,8 +919,12 @@ hwloc_linux_get_tid_cpubind(hwloc_topology_t topology __hwloc_attribute_unused,
37+
38+
/* find the kernel nr_cpus so as to use a large enough cpu_set size */
39+
kernel_nr_cpus = hwloc_linux_find_kernel_nr_cpus(topology);
40+
+ if (kernel_nr_cpus < 0)
41+
+ return -1;
42+
setsize = CPU_ALLOC_SIZE(kernel_nr_cpus);
43+
plinux_set = CPU_ALLOC(kernel_nr_cpus);
44+
+ if (!plinux_set)
45+
+ return -1;
46+
47+
err = sched_getaffinity(tid, setsize, plinux_set);
48+
49+
@@ -1269,6 +1278,8 @@ hwloc_linux_set_thread_cpubind(hwloc_topology_t topology, pthread_t tid, hwloc_c
50+
51+
setsize = CPU_ALLOC_SIZE(last+1);
52+
plinux_set = CPU_ALLOC(last+1);
53+
+ if (!plinux_set)
54+
+ return -1;
55+
56+
CPU_ZERO_S(setsize, plinux_set);
57+
hwloc_bitmap_foreach_begin(cpu, hwloc_set)
58+
@@ -1360,6 +1371,8 @@ hwloc_linux_get_thread_cpubind(hwloc_topology_t topology, pthread_t tid, hwloc_b
59+
60+
setsize = CPU_ALLOC_SIZE(last+1);
61+
plinux_set = CPU_ALLOC(last+1);
62+
+ if (!plinux_set)
63+
+ return -1;
64+
65+
err = pthread_getaffinity_np(tid, setsize, plinux_set);
66+
if (err) {
67+
--
68+
2.45.2
69+

SPECS/openmpi/openmpi.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Summary: Open Message Passing Interface
2929
Name: openmpi%{?_cc_name_suffix}
3030
Version: 4.1.4
31-
Release: 11%{?dist}
31+
Release: 12%{?dist}
3232
License: BSD AND MIT
3333
Vendor: Microsoft Corporation
3434
Distribution: Mariner
@@ -38,6 +38,7 @@ Source0: https://www.open-mpi.org/software/ompi/v4.1/downloads/openmpi-%{
3838
Source1: openmpi.module.in
3939
Source3: openmpi.pth.py3
4040
Source4: macros.openmpi
41+
Patch0: CVE-2022-47022.patch
4142
BuildRequires: gcc-c++
4243
BuildRequires: gcc-gfortran
4344
BuildRequires: hwloc-devel
@@ -303,6 +304,9 @@ make check
303304
%{python3_sitearch}/openmpi.pth
304305

305306
%changelog
307+
* Wed Jan 29 2025 Jyoti Kanase <v-jykanase@microsoft.com> - 4.1.4-12
308+
- Patch to fix CVE-2022-47022.
309+
306310
* Tue Sep 26 2023 Sumedh Sharma <sumsharma@microsoft.com> - 4.1.4-11
307311
- Bump version to recompile with pmix update for CVE-2023-41915
308312

0 commit comments

Comments
 (0)