x86/KASLR: Fix boot crash with certain memory configurations
authorBaoquan He <bhe@redhat.com>
Fri, 1 Jul 2016 07:34:40 +0000 (15:34 +0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 8 Jul 2016 12:36:19 +0000 (14:36 +0200)
Ye Xiaolong reported this boot crash:

|
|  XZ-compressed data is corrupt
|
|   -- System halted
|

Fix the bug in mem_avoid_overlap() of finding the earliest overlap.

Reported-and-tested-by: Ye Xiaolong <xiaolong.ye@intel.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: 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: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/boot/compressed/kaslr.c

index 749c9e0..010ea16 100644 (file)
@@ -285,6 +285,7 @@ static bool mem_avoid_overlap(struct mem_vector *img,
                if (mem_overlaps(img, &mem_avoid[i]) &&
                    mem_avoid[i].start < earliest) {
                        *overlap = mem_avoid[i];
+                       earliest = overlap->start;
                        is_overlapping = true;
                }
        }
@@ -299,6 +300,7 @@ static bool mem_avoid_overlap(struct mem_vector *img,
 
                if (mem_overlaps(img, &avoid) && (avoid.start < earliest)) {
                        *overlap = avoid;
+                       earliest = overlap->start;
                        is_overlapping = true;
                }