From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752299AbdGDXQo (ORCPT ); Tue, 4 Jul 2017 19:16:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57846 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbdGDXQn (ORCPT ); Tue, 4 Jul 2017 19:16:43 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7C3D081226 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=bhe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7C3D081226 Date: Wed, 5 Jul 2017 07:16:38 +0800 From: Baoquan He To: Thomas Gleixner Cc: Matt Fleming , 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 Message-ID: <20170704231638.GA19994@x1> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 04 Jul 2017 23:16:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/04/17 at 05:46pm, Thomas Gleixner wrote: > 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. Sorry, I must be dizzy at late night of yesterday, just gave wrong answer when questioned. > > It's just Baoquans copy and paste wreckage which is busted. > > Thanks, > > tglx >