Skip to content

Commit 5548cce

Browse files
jykanaseCBL-Mariner-Bot
authored andcommitted
[Medium] patch hwloc to fix CVE-2022-47022 (#12144)
Co-authored-by: Sam Meluch <[email protected]> Co-authored-by: jslobodzian <[email protected]> (cherry picked from commit d30c1af)
1 parent 03b17c4 commit 5548cce

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

SPECS/hwloc/CVE-2022-47022.patch

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
From b85436757996b58b805dc4d471ec1cb3c6f56781 Mon Sep 17 00:00:00 2001
2+
From: jykanase <[email protected]>
3+
Date: Tue, 28 Jan 2025 12:11:44 +0000
4+
Subject: [PATCH] CVE-2022-47022
5+
6+
Source Link: https://github.com/open-mpi/hwloc/commit/ac1f8db9a0790d2bf153711ff4cbf6101f89aace
7+
---
8+
hwloc/topology-linux.c | 15 ++++++++++++++-
9+
1 file changed, 14 insertions(+), 1 deletion(-)
10+
11+
diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c
12+
index c7b63d2..fd6745e 100644
13+
--- a/hwloc/topology-linux.c
14+
+++ b/hwloc/topology-linux.c
15+
@@ -870,6 +870,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+
@@ -950,7 +952,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+
@@ -978,8 +983,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+
@@ -1333,6 +1342,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+
@@ -1424,6 +1435,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/hwloc/hwloc.spec

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
Summary: Portable Hardware Locality - portable abstraction of hierarchical architectures
22
Name: hwloc
33
Version: 2.9.2
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: BSD-2-Clause
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
88
URL: https://www.open-mpi.org/projects/hwloc/
99
Source0: http://www.open-mpi.org/software/hwloc/v2.9/downloads/%{name}-%{version}.tar.bz2
10+
Patch0: CVE-2022-47022.patch
1011
BuildRequires: gcc
1112
# C++ only for hwloc-hello-cpp test:
1213
BuildRequires: gcc-c++
@@ -167,6 +168,9 @@ LD_LIBRARY_PATH=$PWD/hwloc/.libs make check
167168
%{_libdir}/%{name}/hwloc*
168169

169170
%changelog
171+
* Wed Jan 29 2025 Jyoti Kanase <[email protected]> - 2.9.2-2
172+
- Fix CVE-2022-47022
173+
170174
* Fri Oct 27 2023 CBL-Mariner Servicing Account <[email protected]> - 2.9.2-1
171175
- Auto-upgrade to 2.9.2 - Azure Linux 3.0 - package upgrades
172176

0 commit comments

Comments
 (0)