mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 15:43:59 +08:00
d52e7d5a95
In commit:
f28442497b
("x86/boot: Fix KASLR and memmap= collision")
... the memmap= option is parsed so that KASLR can avoid those reserved
regions. It uses cmdline_find_option() to get the value if memmap=
is specified, however the problem is that cmdline_find_option() can only
find the last entry if multiple memmap entries are provided. This
is not correct.
Address this by checking each command line token for a "memmap=" match
and parse each instance instead of using cmdline_find_option().
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dan.j.williams@intel.com
Cc: douly.fnst@cn.fujitsu.com
Cc: dyoung@redhat.com
Cc: m.mizuma@jp.fujitsu.com
Link: http://lkml.kernel.org/r/1494654390-23861-2-git-send-email-bhe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
34 lines
769 B
C
34 lines
769 B
C
#include "misc.h"
|
|
|
|
#if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
|
|
|
|
static unsigned long fs;
|
|
static inline void set_fs(unsigned long seg)
|
|
{
|
|
fs = seg << 4; /* shift it back */
|
|
}
|
|
typedef unsigned long addr_t;
|
|
static inline char rdfs8(addr_t addr)
|
|
{
|
|
return *((char *)(fs + addr));
|
|
}
|
|
#include "../cmdline.c"
|
|
unsigned long get_cmd_line_ptr(void)
|
|
{
|
|
unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
|
|
|
|
cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
|
|
|
|
return cmd_line_ptr;
|
|
}
|
|
int cmdline_find_option(const char *option, char *buffer, int bufsize)
|
|
{
|
|
return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
|
|
}
|
|
int cmdline_find_option_bool(const char *option)
|
|
{
|
|
return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
|
|
}
|
|
|
|
#endif
|