From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbcEJImB (ORCPT ); Tue, 10 May 2016 04:42:01 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46802 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbcEJIl7 (ORCPT ); Tue, 10 May 2016 04:41:59 -0400 Date: Tue, 10 May 2016 01:40:51 -0700 From: tip-bot for Kees Cook Message-ID: Cc: mingo@kernel.org, bhe@redhat.com, akpm@linux-foundation.org, keescook@chromium.org, vgoyal@redhat.com, brgerst@gmail.com, dyoung@redhat.com, yinghai@kernel.org, luto@kernel.org, luto@amacapital.net, hpa@zytor.com, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, bp@suse.de, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, bp@alien8.de Reply-To: peterz@infradead.org, tglx@linutronix.de, bp@suse.de, linux-kernel@vger.kernel.org, bp@alien8.de, torvalds@linux-foundation.org, dyoung@redhat.com, brgerst@gmail.com, vgoyal@redhat.com, keescook@chromium.org, mingo@kernel.org, akpm@linux-foundation.org, bhe@redhat.com, dvlasenk@redhat.com, hpa@zytor.com, luto@amacapital.net, yinghai@kernel.org, luto@kernel.org In-Reply-To: <1462825332-10505-2-git-send-email-keescook@chromium.org> References: <1462825332-10505-2-git-send-email-keescook@chromium.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/KASLR: Initialize mapping_info every time Git-Commit-ID: 434a6c9f90f7ab5ade619455df01ef5ebea533ee 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 Commit-ID: 434a6c9f90f7ab5ade619455df01ef5ebea533ee Gitweb: http://git.kernel.org/tip/434a6c9f90f7ab5ade619455df01ef5ebea533ee Author: Kees Cook AuthorDate: Mon, 9 May 2016 13:22:04 -0700 Committer: Ingo Molnar CommitDate: Tue, 10 May 2016 10:12:02 +0200 x86/KASLR: Initialize mapping_info every time As it turns out, mapping_info DOES need to be initialized every time, because pgt_data address could be changed during kernel relocation. So it can not be build time assigned. Without this, page tables were not being corrected updated, which could cause reboots when a physical address beyond 2G was chosen. Signed-off-by: Kees Cook Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Baoquan He Cc: Borislav Petkov 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: kernel-hardening@lists.openwall.com Cc: lasse.collin@tukaani.org Link: http://lkml.kernel.org/r/1462825332-10505-2-git-send-email-keescook@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/boot/compressed/pagetable.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/pagetable.c b/arch/x86/boot/compressed/pagetable.c index 3c99051..34b95df 100644 --- a/arch/x86/boot/compressed/pagetable.c +++ b/arch/x86/boot/compressed/pagetable.c @@ -90,23 +90,17 @@ static void prepare_level4(void) } /* - * Mapping information structure passed to kernel_ident_mapping_init(). - * Since this never changes, there's no reason to repeatedly fill it - * in on the stack when calling add_identity_map(). - */ -static struct x86_mapping_info mapping_info = { - .alloc_pgt_page = alloc_pgt_page, - .context = &pgt_data, - .pmd_flag = __PAGE_KERNEL_LARGE_EXEC, -}; - -/* * Adds the specified range to what will become the new identity mappings. * Once all ranges have been added, the new mapping is activated by calling * finalize_identity_maps() below. */ void add_identity_map(unsigned long start, unsigned long size) { + struct x86_mapping_info mapping_info = { + .alloc_pgt_page = alloc_pgt_page, + .context = &pgt_data, + .pmd_flag = __PAGE_KERNEL_LARGE_EXEC, + }; unsigned long end = start + size; /* Make sure we have a top level page table ready to use. */