From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760166AbcCDQ10 (ORCPT ); Fri, 4 Mar 2016 11:27:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34333 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760151AbcCDQ1Y (ORCPT ); Fri, 4 Mar 2016 11:27:24 -0500 From: Baoquan He To: linux-kernel@vger.kernel.org Cc: yinghai@kernel.org, keescook@chromium.org, hpa@zytor.com, vgoyal@redhat.com, mingo@redhat.com, bp@alien8.de, luto@kernel.org, lasse.collin@tukaani.org, akpm@linux-foundation.org, dyoung@redhat.com, Baoquan He Subject: [PATCH v3 12/19] x86, kaslr: Fix a bug that relocation can not be handled when kernel is loaded above 2G Date: Sat, 5 Mar 2016 00:25:10 +0800 Message-Id: <1457108717-12191-13-git-send-email-bhe@redhat.com> In-Reply-To: <1457108717-12191-1-git-send-email-bhe@redhat.com> References: <1457108717-12191-1-git-send-email-bhe@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 04 Mar 2016 16:27:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When process 32 bit relocation tables a local variable 'extended' is defined to calculate the physical address of relocs entry. However its type is 'int' which is enough for i386, but not enough for x86_64. That's why relocation can only be handled under 2G. Otherwise a overflow will happen and cause system hang. Here change it to 'long' as 32 bit inverse relocation processing does, and this change is safe for i386 relocation handling. Signed-off-by: Baoquan He --- 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 4b2cd0c..70445c3 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -298,7 +298,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; -- 2.5.0