-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] add __stack_chk_guard to generic #121121
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
[libc] add __stack_chk_guard to generic #121121
Conversation
@llvm/pr-subscribers-libc Author: Tristan Ross (RossComputerGuy) Changes
Full diff: https://github.com/llvm/llvm-project/pull/121121.diff 1 Files Affected:
diff --git a/libc/src/compiler/generic/__stack_chk_fail.cpp b/libc/src/compiler/generic/__stack_chk_fail.cpp
index c76ec1407ad356..68ab887afe3175 100644
--- a/libc/src/compiler/generic/__stack_chk_fail.cpp
+++ b/libc/src/compiler/generic/__stack_chk_fail.cpp
@@ -12,6 +12,8 @@
extern "C" {
+uintptr_t __stack_chk_guard;
+
void __stack_chk_fail(void) {
LIBC_NAMESPACE::write_to_stderr("stack smashing detected\n");
LIBC_NAMESPACE::abort();
|
@@ -12,6 +12,8 @@ | |||
|
|||
extern "C" { | |||
|
|||
uintptr_t __stack_chk_guard; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you assign an arbitrary random number as its default value? It should be better than zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, hopefully the number I gave is arbitrary and random enough heh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is better to use static_cast<uintptr_t>(XXX)
; otherwise a warning will be triggered on 32bit targets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I added that now.
b4a9f33
to
6ae9973
Compare
6ae9973
to
2b4301e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/10339 Here is the relevant piece of the build log for the reference
|
Hardcoding a value like this is suspicious. At the very least, our startup code should be initializing this potentially using the |
__stack_chk_guard
is needed for many things and it's undefined so let's define it. If we need a more complex definition, we can do it per target or expand it. This is meant as a simple definition.