Browse Source

kernel: fix crashlog on x86/64

The bootmem area reserved for crashlog might be smaller than CRASHLOG_OFFSET
bytes, leading to an integer underflow when calculating the memory address
in crashlog_set_addr() which subsequently causes the kernel to crash when
attempting to vmap() the crashlog pages.

Change the logic to only consider the offset when the size of the used memory
area is sufficient.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Jo-Philipp Wich 9 years ago
parent
commit
d9345bc5bf
1 changed files with 6 additions and 2 deletions
  1. 6 2
      target/linux/generic/patches-4.4/930-crashlog.patch

+ 6 - 2
target/linux/generic/patches-4.4/930-crashlog.patch

@@ -43,7 +43,7 @@
  
 --- /dev/null
 +++ b/kernel/crashlog.c
-@@ -0,0 +1,209 @@
+@@ -0,0 +1,213 @@
 +/*
 + * Crash information logger
 + * Copyright (C) 2010 Felix Fietkau <[email protected]>
@@ -117,7 +117,11 @@
 +	if (addr + size > limit)
 +		size = limit - addr;
 +
-+	crashlog_addr = addr + size - CRASHLOG_OFFSET;
++	crashlog_addr = addr;
++
++	if (addr + size > CRASHLOG_OFFSET)
++		crashlog_addr += size - CRASHLOG_OFFSET;
++
 +	return true;
 +}
 +