From this post it is shown that FS:[0x28]
is a stack-canary. I'm generating that same code using GCC on this function,
void foo () {
char a[500] = {};
printf("%s", a);
}
Specifically, I'm getting this assembly..
0x000006b5 64488b042528. mov rax, qword fs:[0x28] ; [0x28:8]=0x1978 ; '(' ; "x\x19"
0x000006be 488945f8 mov qword [local_8h], rax
...stuff...
0x00000700 488b45f8 mov rax, qword [local_8h]
0x00000704 644833042528. xor rax, qword fs:[0x28]
0x0000070d 7405 je 0x714
0x0000070f e85cfeffff call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
; CODE XREF from 0x0000070d (sym.foo)
0x00000714 c9 leave
0x00000715 c3 ret
What is setting the value of fs:[0x28]
? The kernel, or is GCC throwing in the code? Can you show the code in the kernel, or compiled into the binary that sets fs:[0x28]
? Is the canary regenerated -- on boot, or process spawn? Where is this documented?