Skip to content

[OpenMP] Close up permissions on /tmp files #85469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions openmp/runtime/src/kmp_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6752,11 +6752,11 @@ void __kmp_register_library_startup(void) {
int fd1 = -1;
shm_name = __kmp_str_format("/%s", name);
int shm_preexist = 0;
fd1 = shm_open(shm_name, O_CREAT | O_EXCL | O_RDWR, 0666);
fd1 = shm_open(shm_name, O_CREAT | O_EXCL | O_RDWR, 0600);
if ((fd1 == -1) && (errno == EEXIST)) {
// file didn't open because it already exists.
// try opening existing file
fd1 = shm_open(shm_name, O_RDWR, 0666);
fd1 = shm_open(shm_name, O_RDWR, 0600);
if (fd1 == -1) { // file didn't open
KMP_WARNING(FunctionError, "Can't open SHM");
__kmp_shm_available = false;
Expand Down Expand Up @@ -6800,11 +6800,11 @@ void __kmp_register_library_startup(void) {
int fd1 = -1;
temp_reg_status_file_name = __kmp_str_format("/tmp/%s", name);
int tmp_preexist = 0;
fd1 = open(temp_reg_status_file_name, O_CREAT | O_EXCL | O_RDWR, 0666);
fd1 = open(temp_reg_status_file_name, O_CREAT | O_EXCL | O_RDWR, 0600);
if ((fd1 == -1) && (errno == EEXIST)) {
// file didn't open because it already exists.
// try opening existing file
fd1 = open(temp_reg_status_file_name, O_RDWR, 0666);
fd1 = open(temp_reg_status_file_name, O_RDWR, 0600);
if (fd1 == -1) { // file didn't open if (fd1 == -1) {
KMP_WARNING(FunctionError, "Can't open TEMP");
__kmp_tmp_available = false;
Expand Down Expand Up @@ -6944,7 +6944,7 @@ void __kmp_unregister_library(void) {
int fd1;
if (__kmp_shm_available) {
shm_name = __kmp_str_format("/%s", name);
fd1 = shm_open(shm_name, O_RDONLY, 0666);
fd1 = shm_open(shm_name, O_RDONLY, 0600);
if (fd1 != -1) { // File opened successfully
char *data1 = (char *)mmap(0, SHM_SIZE, PROT_READ, MAP_SHARED, fd1, 0);
if (data1 != MAP_FAILED) {
Expand Down