I've been looking into implementing pre-thread stack protector
canaries for ARM and I would be interested in people's opinions on
whether I have understood it correctly.
At the moment the global canary value is stored in __stack_chk_guard
which is exported by glibc and accesses to this variable are emitted
by gcc if it detects a capable glibc version at configure time.
glibc with per-thread stack canary values does not export
__stack_chk_guard but adds an element to the TCB to contain the
per-thread value and gcc emits TP-relative accesses to load this
Implementing the per-thread scheme would therefore seem to me to break
ABI compatibility and cause problems when mixing gcc and glibc
Old gcc, old glibc: OK
Old gcc, new glibc: __stack_chk_guard is missing, link time failure.
New gcc, old glibc: stack canary value is loaded from uninitialized
TCB area, security issue.
New gcc, new glibc: OK.
It should be possible to add support for both schemes at the same time
in glibc, exporting __stack_chk_guard at the same time as supporting
per-thread canary values, which would fix the "old gcc, new glibc"
I am not sure if there is a good fix for "new gcc, old glibc",
although gcc configure could be taught about glibc versions and do the
right thing for each.
Or is there a simpler way to handle this? Has any other architecture
implemented per-thread stack protector after already supporting the
No machine has a per-thread canary value. Using one would break
user-implemented stack-switching schemes.
Some machines store the global canary value in every thread's TCB for the
sole reason that it's cheaper to access a field in the TCB than to access a
global variable. I don't think that's the case on ARM.
> No machine has a per-thread canary value. Using one would break
> user-implemented stack-switching schemes.
> Some machines store the global canary value in every thread's TCB for the
> sole reason that it's cheaper to access a field in the TCB than to access a
> global variable. I don't think that's the case on ARM.
Thanks for the clarification. So the two methods are functionally identical?
I looked at this problem initially after reading Carlos's mail to the
fedora devel list: