public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* protecting early_param from null injecting
@ 2008-08-12 16:21 Cyrill Gorcunov
  0 siblings, 0 replies; only message in thread
From: Cyrill Gorcunov @ 2008-08-12 16:21 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

Hi Ingo,

I spent some time on eraly_param handling and it seems
it will not be possible to just set absentee parameter
to end of string to prevent NULL deref. As I can see
the easier way is to add checking for NULL pointer.

And here is why - currently kernel will hang if user
forget to specify mandatory boot parameter - pointing
us to fix that point in kernel to prevent NULL deref.
If we may early_param to behave as __setup() funtion does -
we will have to review/fix kernel code anyway - for example
in arch/mips/kernel/setup.c

---
static int __init early_parse_mem(char *p)
{
	unsigned long start, size;

	/*
	 * If a user specifies memory size, we
	 * blow away any automatically generated
	 * size.
	 */
	if (usermem == 0) {
		boot_mem_map.nr_map = 0;
		usermem = 1;
 	}
	start = 0;
	size = memparse(p, &p);
	if (*p == '@')
		start = memparse(p + 1, &p);

	add_memory_region(start, size, BOOT_MEM_RAM);
	return 0;
}
early_param("mem", early_parse_mem);
---

If user will specify boot option as "mem=" without arg
we will have hang on eraly boot stage but if we change it
to zero-sized-string it will not fail and add_memory_region
will be processed as well by adding zero-sized memory region.
I don't know maybe it's safe to add zero-sized memory region
but I have a gut feeling in this way we could change program
flow and get hidden bugs.

I think there about ~15-20 places in kernel left without NULL
checking - not that many :) As only I finish with my current
APIC attempts - I could fix them.

		- Cyrill -

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-12 16:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 16:21 protecting early_param from null injecting Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox