Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136354
b: refs/heads/master
c: 960a672
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar authored and Thomas Gleixner committed May 26, 2008
1 parent 87b0c2d commit 98f70c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 420594296838fdc9a674470d710cda7d1487f9f4
refs/heads/master: 960a672bd9f1ec06e8f197cf81a50fd07ea02e7f
20 changes: 17 additions & 3 deletions trunk/include/asm-x86/stackprotector.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _ASM_STACKPROTECTOR_H
#define _ASM_STACKPROTECTOR_H 1

#include <asm/tsc.h>

/*
* Initialize the stackprotector canary value.
*
Expand All @@ -9,16 +11,28 @@
*/
static __always_inline void boot_init_stack_canary(void)
{
u64 canary;
u64 tsc;

/*
* If we're the non-boot CPU, nothing set the PDA stack
* canary up for us - and if we are the boot CPU we have
* a 0 stack canary. This is a good place for updating
* it, as we wont ever return from this function (so the
* invalid canaries already on the stack wont ever
* trigger):
* trigger).
*
* We both use the random pool and the current TSC as a source
* of randomness. The TSC only matters for very early init,
* there it already has some randomness on most systems. Later
* on during the bootup the random pool has true entropy too.
*/
current->stack_canary = get_random_int();
write_pda(stack_canary, current->stack_canary);
get_random_bytes(&canary, sizeof(canary));
tsc = __native_read_tsc();
canary += tsc + (tsc << 32UL);

current->stack_canary = canary;
write_pda(stack_canary, canary);
}

#endif

0 comments on commit 98f70c2

Please sign in to comment.