Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146129061
D15173.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D15173.id.diff
View Options
Index: head/lib/libc/secure/stack_protector.c
===================================================================
--- head/lib/libc/secure/stack_protector.c
+++ head/lib/libc/secure/stack_protector.c
@@ -54,15 +54,27 @@
__guard_setup(void)
{
static const int mib[2] = { CTL_KERN, KERN_ARND };
+ volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)];
size_t len;
- int error;
+ int error, idx;
if (__stack_chk_guard[0] != 0)
return;
- error = _elf_aux_info(AT_CANARY, __stack_chk_guard,
- sizeof(__stack_chk_guard));
- if (error == 0 && __stack_chk_guard[0] != 0)
+ /*
+ * Avoid using functions which might have stack protection
+ * enabled, to update the __stack_chk_guard. First fetch the
+ * data into a temporal array, then do manual volatile copy to
+ * not allow optimizer to call memcpy() behind us.
+ */
+ error = _elf_aux_info(AT_CANARY, (void *)tmp_stack_chk_guard,
+ sizeof(tmp_stack_chk_guard));
+ if (error == 0 && tmp_stack_chk_guard[0] != 0) {
+ for (idx = 0; idx < nitems(__stack_chk_guard); idx++) {
+ __stack_chk_guard[idx] = tmp_stack_chk_guard[idx];
+ tmp_stack_chk_guard[idx] = 0;
+ }
return;
+ }
len = sizeof(__stack_chk_guard);
if (__sysctl(mib, nitems(mib), __stack_chk_guard, &len, NULL, 0) ==
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 1:46 AM (11 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29090698
Default Alt Text
D15173.id.diff (1 KB)
Attached To
Mode
D15173: udpate stack guard bytes inside __guard_setup()
Attached
Detach File
Event Timeline
Log In to Comment