Skip to content

Commit 79472ea

Browse files
[AUTO-CHERRYPICK] [Medium] patch openmpi to fix CVE-2022-47022 - branch 3.0-dev (#12504)
Co-authored-by: jykanase <v-jykanase@microsoft.com>
1 parent 3ec0ab5 commit 79472ea

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

SPECS/openmpi/CVE-2022-47022.patch

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

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.7
31-
Release: 1%{?dist}
31+
Release: 2%{?dist}
3232
License: BSD AND MIT
3333
Vendor: Microsoft Corporation
3434
Distribution: Azure Linux
@@ -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
@@ -304,6 +305,9 @@ make check
304305
%{python3_sitearch}/openmpi.pth
305306

306307
%changelog
308+
* Wed Feb 12 2025 Jyoti Kanase <v-jykanase@microsoft.com> - 4.1.7-2
309+
- Patch to fix CVE-2022-47022
310+
307311
* Thu Jan 09 2025 Alberto David Perez Guevara <aperezguevar@microsoft.com> - 4.1.7-1
308312
- Upgrade to 4.1.7 - Azure Linux 3.0 - package upgrades
309313

0 commit comments

Comments
 (0)