[llvm] [BOLT][runtime] harden profile file open. (PR #191669)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 11 14:52:30 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/191669.diff
2 Files Affected:
- (modified) bolt/runtime/common.h (+1)
- (modified) bolt/runtime/instr.cpp (+2-2)
``````````diff
diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h
index f4ab28f10a815..8689bc8b72041 100644
--- a/bolt/runtime/common.h
+++ b/bolt/runtime/common.h
@@ -74,6 +74,7 @@ typedef int int32_t;
#define O_CREAT 64
#define O_TRUNC 512
#define O_APPEND 1024
+#define O_CLOEXEC 524288
// Functions that are required by freestanding environment. Compiler may
// generate calls to these implicitly.
diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp
index a44f1266ea65d..0499dd1378bb6 100644
--- a/bolt/runtime/instr.cpp
+++ b/bolt/runtime/instr.cpp
@@ -1500,8 +1500,8 @@ int openProfile() {
Ptr = strCopy(Ptr, ".fdata", BufSize - (Ptr - Buf + 1));
}
*Ptr++ = '\0';
- uint64_t FD = __open(Buf, O_WRONLY | O_TRUNC | O_CREAT,
- /*mode=*/0666);
+ uint64_t FD = __open(Buf, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC,
+ /*mode=*/0600);
if (static_cast<int64_t>(FD) < 0) {
report("Error while trying to open profile file for writing: ");
report(Buf);
``````````
</details>
https://github.com/llvm/llvm-project/pull/191669
More information about the llvm-commits
mailing list