diff options
author | Dave Jiang <[email protected]> | 2017-01-11 16:20:01 -0700 |
---|---|---|
committer | Ingo Molnar <[email protected]> | 2017-01-25 12:35:50 +0100 |
commit | f28442497b5caf7bf573ade22a7f8d3559e3ef56 (patch) | |
tree | fd34626f747c0094665c2a6fe3a6e831da10fc2b /arch/x86/boot/string.c | |
parent | c19a5f35e315837170ee337eed21c7087ea94192 (diff) |
x86/boot: Fix KASLR and memmap= collision
CONFIG_RANDOMIZE_BASE=y relocates the kernel to a random base address.
However it does not take into account the memmap= parameter passed in from
the kernel command line. This results in the kernel sometimes being put in
the middle of memmap.
Teach KASLR to not insert the kernel in memmap defined regions. We support
up to 4 memmap regions: any additional regions will cause KASLR to disable.
The mem_avoid set has been augmented to add up to 4 unusable regions of
memmaps provided by the user to exclude those regions from the set of valid
address range to insert the uncompressed kernel image.
The nn@ss ranges will be skipped by the mem_avoid set since it indicates
that memory is useable.
Signed-off-by: Dave Jiang <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
Acked-by: Kees Cook <[email protected]>
Acked-by: Baoquan He <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/148417664156.131935.2248592164852799738.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'arch/x86/boot/string.c')
-rw-r--r-- | arch/x86/boot/string.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index cc3bd583dce1..93d9b991e6b1 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -155,3 +155,16 @@ char *strstr(const char *s1, const char *s2) } return NULL; } + +/** + * strchr - Find the first occurrence of the character c in the string s. + * @s: the string to be searched + * @c: the character to search for + */ +char *strchr(const char *s, int c) +{ + while (*s != (char)c) + if (*s++ == '\0') + return NULL; + return (char *)s; +} |