libhwloc.so will segmentation fault when attempting to modify static string in environ
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
hwloc (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Matthew Ruffell | ||
Kinetic |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
hwloc sets the ZES_ENABLE_SYSMAN environment variable in environ using putenv. The issue is, it is a static string in environ, and if any applications that pull in libhwloc.so attempts to modify environ, they will segmentation fault. The fix is straightforward, by using setenv instead of putenv.
A workaround is to export ZES_ENABLE_SYSMAN=1 before running processes that use libhwloc.
[Testcase]
A minimal reproducer is readily available for this issue.
$ sudo apt install hwloc build-essential
Place the following C program into reproducer.c
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
void *lib = dlopen(
}
$ gcc -o reproducer reproducer.c
On a system effected by the issue, you will receive a segmentation fault on running:
$ ./reproducer
dlopen: 0x561a33e2f2d0
getenv: (nil)
dlclose: 0
Segmentation fault (core dumped)
Test packages are available in the following ppa:
https:/
If you install the test package, the output you should see is below, with no segmentation faults:
$ ./reproducer
dlopen: 0x5589ef8572d0
getenv: (nil)
dlclose: 0
getenv: (nil)
[Where problems could occur]
The change is small, as we swap from putenv to setenv to set a single environment variable, ZES_ENABLE_SYSMAN.
If a regression were to occur, affected users would be limited to those whose applications dynamically link against libhwloc.so, libhwloc.so.15.
A workaround for a regression would be to export ZES_ENABLE_SYSMAN=1 before running processes that use libhwloc.
[Other info]
Minimal reproducer and analysis is from:
https:/
Upstream Bug report:
https:/
Commit which fixed the issue:
commit 91b9e44910f4fe4
From: Joshua Hursey <email address hidden>
Date: Sat, 29 Jan 2022 11:08:30 +0100
Subject: core+levelzero: Set ZES_ENABLE_SYSMAN via setenv instead of putenv
Link: https:/
Changed in hwloc (Ubuntu Jammy): | |
status: | New → Fix Released |
Changed in hwloc (Ubuntu Kinetic): | |
status: | Confirmed → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Matthew Ruffell (mruffell) |
tags: | added: sts |
summary: |
- hwloc 2.7.0 putenv of static string + libhwloc.so will segmentation fault when attempting to modify static + string in environ |
description: | updated |
tags: | added: sts-sponsor |
Changed in hwloc (Ubuntu Kinetic): | |
status: | In Progress → Fix Released |
Changed in hwloc (Ubuntu Jammy): | |
status: | Fix Released → In Progress |
Changed in hwloc (Ubuntu Kinetic): | |
importance: | Medium → Undecided |
assignee: | Matthew Ruffell (mruffell) → nobody |
Changed in hwloc (Ubuntu Jammy): | |
assignee: | nobody → Matthew Ruffell (mruffell) |
+1 for this, I faced this issue while running the Slurm workload manager: /bugs.schedmd. com/show_ bug.cgi? id=14276
https:/