From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752497AbdGDPqj (ORCPT ); Tue, 4 Jul 2017 11:46:39 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49164 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752286AbdGDPqi (ORCPT ); Tue, 4 Jul 2017 11:46:38 -0400 Date: Tue, 4 Jul 2017 17:46:35 +0200 (CEST) From: Thomas Gleixner To: Matt Fleming cc: Baoquan He , LKML , x86@kernel.org, "H. Peter Anvin" , Ingo Molnar , Kees Cook , thgarnie@google.com, caoj.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com Subject: Re: [PATCH v2 2/2] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions In-Reply-To: <20170704153633.GA3149@codeblueprint.co.uk> Message-ID: References: <1499155442-17467-1-git-send-email-bhe@redhat.com> <1499155442-17467-3-git-send-email-bhe@redhat.com> <20170704143034.GA25192@x1> <20170704153633.GA3149@codeblueprint.co.uk> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Jul 2017, Matt Fleming wrote: > On Tue, 04 Jul, at 04:46:58PM, Thomas Gleixner wrote: > > On Tue, 4 Jul 2017, Baoquan He wrote: > > > > > In fact I just referred to code in setup_arch(). Now I have a question, > > > though CONFIG_EFI=y but efi firmware is not enabled, > > > boot_params.efi_info.efi_loader_signature should be initilized to 0. > > > Then below code is also problematic. > > > > > > #ifdef CONFIG_EFI > > > if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, > > > EFI32_LOADER_SIGNATURE, 4)) { > > > set_bit(EFI_BOOT, &efi.flags); > > > } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, > > > EFI64_LOADER_SIGNATURE, 4)) { > > > set_bit(EFI_BOOT, &efi.flags); > > > set_bit(EFI_64BIT, &efi.flags); > > > } > > > > > > if (efi_enabled(EFI_BOOT)) > > > efi_memblock_x86_reserve_range(); > > > #endif > > > > Indeed. Matt? > > It's possibly that I'm missing some context, but boot_params should be > zero'd -- the x86 boot protocol requires that the entire data > structure be zero'd on allocation. > > Have I missed something? No. I misread the code. The strncmp() operates on boot_params.efi_info.efi_loader_signature itself, so yes, all is fine. It's just Baoquans copy and paste wreckage which is busted. Thanks, tglx