[libc-commits] [libc] [libc] Simple __stack_chk_guard implementation (PR #78804)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Jan 23 08:38:52 PST 2024


nickdesaulniers wrote:

> Does this mean that we do not know when the global guard will be ready?

I see your point.  There's a function attribute we can add to disable stack checks, which is helpful in routines that are responsible for initializing the stack canary in the first place (otherwise the initial value placed on the stack is undefined, which is very likely to result in a call to `__stack_chk_fail`). [`no_stack_protector`](https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers) IIRC it was only added to GCC in gcc-10 though.  This generally isn't a problem in the Linux kernel because canary initialization is done very early, then you don't need to worry about it.

> Consider the following approach instead

Sure, could be a well-named help function.

> When pointer width is > 8

What platform is that? I'm going to go with "let's worry about that when we need to add support for such platform."

> This approach diverges the values of TLS canary and global guard.

If we have TLS canary, then we don't need a single global, right?

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


More information about the libc-commits mailing list