[libc-commits] [libc] [libc] fix issues around stack protector (PR #74567)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Tue Dec 12 09:21:30 PST 2023


================
@@ -9,15 +9,22 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
 
-#include "syscall.h"             // For internal syscall function.
+#include "syscall.h" // For internal syscall function.
 
 #include "src/__support/common.h"
 
 #include <sys/syscall.h> // For syscall numbers.
 
 namespace LIBC_NAMESPACE {
 
-LIBC_INLINE void quick_exit(int status) {
+// mark as no_stack_protector for x86 since TLS can be torn down before calling
+// quick_exit so that the stack protector canary cannot be loaded.
+#if defined(__i386) || defined(__i386__) || defined(__x86_64__) ||             \
+    defined(__x86_64)
+__attribute__((no_stack_protector))
----------------
SchrodingerZhu wrote:

Sorry I have folded my initial reply.

in-tree clang does not seem to recognize [[gnu::no_stack_protector]].

[[clang::]] works but I will need to add other macro guards.

https://github.com/llvm/llvm-project/pull/74567


More information about the libc-commits mailing list