Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752646AbcD2IEU (ORCPT ); Fri, 29 Apr 2016 04:04:20 -0400 Received: from terminus.zytor.com ([198.137.202.10]:50512 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbcD2IEQ (ORCPT ); Fri, 29 Apr 2016 04:04:16 -0400 Date: Fri, 29 Apr 2016 01:02:55 -0700 From: tip-bot for Baoquan He Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, luto@amacapital.net, brgerst@gmail.com, keescook@chromium.org, akpm@linux-foundation.org, vgoyal@redhat.com, torvalds@linux-foundation.org, bp@alien8.de, peterz@infradead.org, tglx@linutronix.de, dyoung@redhat.com, dvlasenk@redhat.com, yinghai@kernel.org, bhe@redhat.com, linux-kernel@vger.kernel.org, luto@kernel.org Reply-To: keescook@chromium.org, akpm@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, brgerst@gmail.com, luto@amacapital.net, linux-kernel@vger.kernel.org, luto@kernel.org, yinghai@kernel.org, bhe@redhat.com, tglx@linutronix.de, peterz@infradead.org, dvlasenk@redhat.com, dyoung@redhat.com, bp@alien8.de, vgoyal@redhat.com, torvalds@linux-foundation.org In-Reply-To: <1461888548-32439-2-git-send-email-keescook@chromium.org> References: <1461888548-32439-2-git-send-email-keescook@chromium.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/KASLR: Handle kernel relocations above 2G correctly Git-Commit-ID: 6f9af75faa1df61e1ee5bea8a787a90605bb528d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2251 Lines: 56 Commit-ID: 6f9af75faa1df61e1ee5bea8a787a90605bb528d Gitweb: http://git.kernel.org/tip/6f9af75faa1df61e1ee5bea8a787a90605bb528d Author: Baoquan He AuthorDate: Thu, 28 Apr 2016 17:09:03 -0700 Committer: Ingo Molnar CommitDate: Fri, 29 Apr 2016 09:58:26 +0200 x86/KASLR: Handle kernel relocations above 2G correctly When processing the relocation table, the offset used to calculate the relocation is an 'int'. This is sufficient for calculating the physical address of the relocs entry on 32-bit systems and on 64-bit systems when the relocation is under 2G. To handle relocations above 2G (seen in situations like kexec, netboot, etc), this offset needs to be calculated using a 'long' to avoid wrapping and miscalculating the relocation. Signed-off-by: Baoquan He [ Rewrote the changelog. ] Signed-off-by: Kees Cook Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Young Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vivek Goyal Cc: Yinghai Lu Cc: lasse.collin@tukaani.org Link: http://lkml.kernel.org/r/1461888548-32439-2-git-send-email-keescook@chromium.org Signed-off-by: Ingo Molnar Signed-off-by: Ingo Molnar --- arch/x86/boot/compressed/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 6dde6cc..4514514 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -232,7 +232,7 @@ static void handle_relocations(void *output, unsigned long output_len) * So we work backwards from the end of the decompressed image. */ for (reloc = output + output_len - sizeof(*reloc); *reloc; reloc--) { - int extended = *reloc; + long extended = *reloc; extended += map; ptr = (unsigned long)extended;