Skip to contentSkip to conversation

x86: ACPI - add checking for NULL early param

PATCH In review Cyrill Gorcunov 2 participants 7 messages Jul 5, 2008 – Jul 22, 2008 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/5 x86: ACPI - add checking for NULL early param

In reply to a message not in the archive

---

drivers/acpi/tables.c +2 -0
Index: linux-2.6.git/drivers/acpi/tables.c
====================================================================
@@ -300,6 +300,8 @@ int __init acpi_table_init(void)
 
 static int __init acpi_parse_apic_instance(char *str)
 {
+	if (!str)
+		return -EINVAL;
 
 	acpi_apic_instance = simple_strtoul(str, NULL, 0);
 
#4 lore raw

PATCH 2/5 x86: idle process - add checking for NULL early param

In reply to a message not in the archive

---

arch/x86/kernel/process.c +3 -0
Index: linux-2.6.git/arch/x86/kernel/process.c
====================================================================
@@ -325,6 +325,9 @@ void __cpuinit select_idle_routine(const
 
 static int __init idle_setup(char *str)
 {
+	if (!str)
+		return -EINVAL;
+
 	if (!strcmp(str, "poll")) {
 		printk("using polling idle threads.\n");
 		pm_idle = poll_idle;
#5 lore raw

PATCH 3/5 x86: io delay - add checking for NULL early param

In reply to a message not in the archive

---

arch/x86/kernel/io_delay.c +3 -0
Index: linux-2.6.git/arch/x86/kernel/io_delay.c
====================================================================
@@ -103,6 +103,9 @@ void __init io_delay_init(void)
 
 static int __init io_delay_param(char *s)
 {
+	if (!s)
+		return -EINVAL;
+
 	if (!strcmp(s, "0x80"))
 		io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
 	else if (!strcmp(s, "0xed"))
#6 lore raw

PATCH 4/5 x86: smpboot maxcpus - add checking for NULL early param

In reply to a message not in the archive

---

arch/x86/kernel/smpboot.c +2 -1
Index: linux-2.6.git/arch/x86/kernel/smpboot.c
====================================================================
@@ -1383,7 +1383,8 @@ static int __init parse_maxcpus(char *ar
 {
 	extern unsigned int maxcpus;
 
-	maxcpus = simple_strtoul(arg, NULL, 0);
+	if (arg)
+		maxcpus = simple_strtoul(arg, NULL, 0);
 	return 0;
 }
 early_param("maxcpus", parse_maxcpus);
#7 lore raw

PATCH 5/5 x86: e820 memmap - add checking for NULL early param

In reply to a message not in the archive

---

arch/x86/kernel/e820.c +3 -0
Index: linux-2.6.git/arch/x86/kernel/e820.c
====================================================================
@@ -1131,6 +1131,9 @@ static int __init parse_memmap_opt(char 
 	char *oldp;
 	u64 start_at, mem_size;
 
+	if (!p)
+		return -EINVAL;
+
 	if (!strcmp(p, "exactmap")) {
 #ifdef CONFIG_CRASH_DUMP
 		/*
#2 lore raw
In reply to Cyrill Gorcunov
Quoted 8 lines · On Sat, 05 Jul 2008 15:53:35 +0400 Cyrill Gorcunov <[email protected]> wrote:

---

Index: linux-2.6.git/drivers/acpi/tables.c
====================================================================

drivers/acpi/tables.c int __init acpi_table_init(void) · line 307

Quoted 8 lines
drivers/acpi/tables.c +2 -0
@@ -300,6 +300,8 @@ int __init acpi_table_init(void)
 
 static int __init acpi_parse_apic_instance(char *str)
 {
+	if (!str)
+		return -EINVAL;
 
 	acpi_apic_instance = simple_strtoul(str, NULL, 0);
 

Could you please explain this patch?

#3 lore raw

[Andrew Morton - Tue, Jul 22, 2008 at 02:53:32AM -0700]

| On Sat, 05 Jul 2008 15:53:35 +0400 Cyrill Gorcunov <[email protected]> wrote:
| 
| > Signed-off-by: Cyrill Gorcunov <[email protected]>
| > ---
| > 
| > Index: linux-2.6.git/drivers/acpi/tables.c
| > ====================================================================
| > --- linux-2.6.git.orig/drivers/acpi/tables.c	2008-01-21 23:14:47.000000000 +0300
| > +++ linux-2.6.git/drivers/acpi/tables.c	2008-07-05 12:24:16.000000000 +0400
| > @@ -300,6 +300,8 @@ int __init acpi_table_init(void)
| >  
| >  static int __init acpi_parse_apic_instance(char *str)
| >  {
| > +	if (!str)
| > +		return -EINVAL;
| >  
| >  	acpi_apic_instance = simple_strtoul(str, NULL, 0);
| >  
| 
| Could you please explain this patch?
| 

we could get NULL deref here - if you start kernel as

qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "root=/dev/sda acpi_apic_instance" ../images/root-j

so user was not carried about correct boot option and the kernel respond by hang - which is not good I think. Actually - by the patch we easy protect ourself from user-madness :)

- Cyrill -