提交 681558fd 编写于 作者: A Andi Kleen 提交者: Linus Torvalds

[PATCH] x86_64: Check that early arguments are words on their own

We've always had the problem that arguments only did a prefix match,
which resulted e.g.  in noapic and noapictimer getting confused.

Fix the early argument parsing code to always check that arguments are
whole words (except for those that take additional arguments of course)
I factored out the checking code for that while also makes the code
easier to maintain.
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 86ebcea8
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/ctype.h>
#include <asm/mtrr.h> #include <asm/mtrr.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -270,6 +271,13 @@ static void __init probe_roms(void) ...@@ -270,6 +271,13 @@ static void __init probe_roms(void)
} }
} }
/* Check for full argument with no trailing characters */
static int fullarg(char *p, char *arg)
{
int l = strlen(arg);
return !memcmp(p, arg, l) && (p[l] == 0 || isspace(p[l]));
}
static __init void parse_cmdline_early (char ** cmdline_p) static __init void parse_cmdline_early (char ** cmdline_p)
{ {
char c = ' ', *to = command_line, *from = COMMAND_LINE; char c = ' ', *to = command_line, *from = COMMAND_LINE;
...@@ -293,10 +301,10 @@ static __init void parse_cmdline_early (char ** cmdline_p) ...@@ -293,10 +301,10 @@ static __init void parse_cmdline_early (char ** cmdline_p)
#endif #endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
/* "acpi=off" disables both ACPI table parsing and interpreter init */ /* "acpi=off" disables both ACPI table parsing and interpreter init */
if (!memcmp(from, "acpi=off", 8)) if (fullarg(from,"acpi=off"))
disable_acpi(); disable_acpi();
if (!memcmp(from, "acpi=force", 10)) { if (fullarg(from, "acpi=force")) {
/* add later when we do DMI horrors: */ /* add later when we do DMI horrors: */
acpi_force = 1; acpi_force = 1;
acpi_disabled = 0; acpi_disabled = 0;
...@@ -304,52 +312,47 @@ static __init void parse_cmdline_early (char ** cmdline_p) ...@@ -304,52 +312,47 @@ static __init void parse_cmdline_early (char ** cmdline_p)
/* acpi=ht just means: do ACPI MADT parsing /* acpi=ht just means: do ACPI MADT parsing
at bootup, but don't enable the full ACPI interpreter */ at bootup, but don't enable the full ACPI interpreter */
if (!memcmp(from, "acpi=ht", 7)) { if (fullarg(from, "acpi=ht")) {
if (!acpi_force) if (!acpi_force)
disable_acpi(); disable_acpi();
acpi_ht = 1; acpi_ht = 1;
} }
else if (!memcmp(from, "pci=noacpi", 10)) else if (fullarg(from, "pci=noacpi"))
acpi_disable_pci(); acpi_disable_pci();
else if (!memcmp(from, "acpi=noirq", 10)) else if (fullarg(from, "acpi=noirq"))
acpi_noirq_set(); acpi_noirq_set();
else if (!memcmp(from, "acpi_sci=edge", 13)) else if (fullarg(from, "acpi_sci=edge"))
acpi_sci_flags.trigger = 1; acpi_sci_flags.trigger = 1;
else if (!memcmp(from, "acpi_sci=level", 14)) else if (fullarg(from, "acpi_sci=level"))
acpi_sci_flags.trigger = 3; acpi_sci_flags.trigger = 3;
else if (!memcmp(from, "acpi_sci=high", 13)) else if (fullarg(from, "acpi_sci=high"))
acpi_sci_flags.polarity = 1; acpi_sci_flags.polarity = 1;
else if (!memcmp(from, "acpi_sci=low", 12)) else if (fullarg(from, "acpi_sci=low"))
acpi_sci_flags.polarity = 3; acpi_sci_flags.polarity = 3;
/* acpi=strict disables out-of-spec workarounds */ /* acpi=strict disables out-of-spec workarounds */
else if (!memcmp(from, "acpi=strict", 11)) { else if (fullarg(from, "acpi=strict")) {
acpi_strict = 1; acpi_strict = 1;
} }
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
else if (!memcmp(from, "acpi_skip_timer_override", 24)) else if (fullarg(from, "acpi_skip_timer_override"))
acpi_skip_timer_override = 1; acpi_skip_timer_override = 1;
#endif #endif
#endif #endif
if (!memcmp(from, "disable_timer_pin_1", 19)) if (fullarg(from, "disable_timer_pin_1"))
disable_timer_pin_1 = 1; disable_timer_pin_1 = 1;
if (!memcmp(from, "enable_timer_pin_1", 18)) if (fullarg(from, "enable_timer_pin_1"))
disable_timer_pin_1 = -1; disable_timer_pin_1 = -1;
if (!memcmp(from, "nolapic", 7) || if (fullarg(from, "nolapic") || fullarg(from, "disableapic"))
!memcmp(from, "disableapic", 11))
disable_apic = 1; disable_apic = 1;
/* Don't confuse with noapictimer */ if (fullarg(from, "noapic"))
if (!memcmp(from, "noapic", 6) &&
(from[6] == ' ' || from[6] == 0))
skip_ioapic_setup = 1; skip_ioapic_setup = 1;
/* Make sure to not confuse with apic= */ if (fullarg(from,"apic")) {
if (!memcmp(from, "apic", 4) &&
(from[4] == ' ' || from[4] == 0)) {
skip_ioapic_setup = 0; skip_ioapic_setup = 0;
ioapic_force = 1; ioapic_force = 1;
} }
...@@ -388,7 +391,7 @@ static __init void parse_cmdline_early (char ** cmdline_p) ...@@ -388,7 +391,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
iommu_setup(from+6); iommu_setup(from+6);
} }
if (!memcmp(from,"oops=panic", 10)) if (fullarg(from,"oops=panic"))
panic_on_oops = 1; panic_on_oops = 1;
if (!memcmp(from, "noexec=", 7)) if (!memcmp(from, "noexec=", 7))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册