linux-sg2042/arch
Emese Revfy 38addce8b6 gcc-plugins: Add latent_entropy plugin
This adds a new gcc plugin named "latent_entropy". It is designed to
extract as much possible uncertainty from a running system at boot time as
possible, hoping to capitalize on any possible variation in CPU operation
(due to runtime data differences, hardware differences, SMP ordering,
thermal timing variation, cache behavior, etc).

At the very least, this plugin is a much more comprehensive example for
how to manipulate kernel code using the gcc plugin internals.

The need for very-early boot entropy tends to be very architecture or
system design specific, so this plugin is more suited for those sorts
of special cases. The existing kernel RNG already attempts to extract
entropy from reliable runtime variation, but this plugin takes the idea to
a logical extreme by permuting a global variable based on any variation
in code execution (e.g. a different value (and permutation function)
is used to permute the global based on loop count, case statement,
if/then/else branching, etc).

To do this, the plugin starts by inserting a local variable in every
marked function. The plugin then adds logic so that the value of this
variable is modified by randomly chosen operations (add, xor and rol) and
random values (gcc generates separate static values for each location at
compile time and also injects the stack pointer at runtime). The resulting
value depends on the control flow path (e.g., loops and branches taken).

Before the function returns, the plugin mixes this local variable into
the latent_entropy global variable. The value of this global variable
is added to the kernel entropy pool in do_one_initcall() and _do_fork(),
though it does not credit any bytes of entropy to the pool; the contents
of the global are just used to mix the pool.

Additionally, the plugin can pre-initialize arrays with build-time
random contents, so that two different kernel builds running on identical
hardware will not have the same starting values.

Signed-off-by: Emese Revfy <re.emese@gmail.com>
[kees: expanded commit message and code comments]
Signed-off-by: Kees Cook <keescook@chromium.org>
2016-10-10 14:51:44 -07:00
..
alpha alpha: fix copy_from_user() 2016-09-09 19:34:32 -04:00
arc Merge branch 'uaccess-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-09-14 09:35:05 -07:00
arm Merge branch 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm 2016-10-02 15:23:00 -07:00
arm64 - Fix secondary CPU to NUMA node assignment 2016-09-23 11:24:42 -07:00
avr32 avr32: fix 'undefined reference to `___copy_from_user' 2016-09-18 07:26:26 -07:00
blackfin Merge branch 'uaccess-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-09-14 09:35:05 -07:00
c6x dma-mapping: use unsigned long for dma_attrs 2016-08-04 08:50:07 -04:00
cris cris: buggered copy_from_user/copy_to_user/clear_user 2016-09-13 17:49:38 -04:00
frv frv: fix clear_user() 2016-09-13 17:49:39 -04:00
h8300 h8300: Add missing include file to asm/io.h 2016-08-13 08:53:56 -07:00
hexagon hexagon: fix strncpy_from_user() error return 2016-09-13 17:49:39 -04:00
ia64 Merge branch 'uaccess-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-09-14 09:35:05 -07:00
m32r m32r: fix __get_user() 2016-09-13 17:50:16 -04:00
m68k m68knommu: fix user a5 register being overwritten 2016-08-08 12:38:47 +10:00
metag metag: copy_from_user() should zero the destination on access_ok() failure 2016-09-13 17:49:40 -04:00
microblaze microblaze: fix __get_user() 2016-09-13 17:50:17 -04:00
mips MIPS: CM: Fix mips_cm_max_vp_width for non-MT kernels on MT systems 2016-10-02 01:40:56 +02:00
mn10300 mn10300: copy_from_user() should zero on access_ok() failure... 2016-09-13 17:49:42 -04:00
nios2 nios2: fix __get_user() 2016-09-13 17:49:43 -04:00
openrisc openrisc: fix the fix of copy_from_user() 2016-09-18 07:26:42 -07:00
parisc Merge branch 'uaccess-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-09-14 09:35:05 -07:00
powerpc gcc-plugins: Add latent_entropy plugin 2016-10-10 14:51:44 -07:00
s390 Merge branch 'uaccess-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-09-14 09:35:05 -07:00
score score: fix copy_from_user() and friends 2016-09-13 17:50:14 -04:00
sh locking/atomic, arch/sh: Fix ATOMIC_FETCH_OP() 2016-09-22 14:47:02 +02:00
sparc sparc64: Fix non-SMP build. 2016-09-28 20:40:52 -04:00
tile mm/usercopy: get rid of CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 2016-08-30 10:10:21 -07:00
um um/ptrace: Fix the syscall number update after a ptrace 2016-09-07 09:25:04 -07:00
unicore32 unicore32: mm: Add missing parameter to arch_vma_access_permitted 2016-08-13 08:53:18 -07:00
x86 x86/entry/64: Fix context tracking state warning when load_gs_index fails 2016-09-30 13:53:12 +02:00
xtensa dma-mapping: use unsigned long for dma_attrs 2016-08-04 08:50:07 -04:00
.gitignore
Kconfig gcc-plugins: Add latent_entropy plugin 2016-10-10 14:51:44 -07:00