From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFC83C6778A for ; Tue, 3 Jul 2018 17:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97705249C1 for ; Tue, 3 Jul 2018 17:47:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97705249C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934379AbeGCRrq (ORCPT ); Tue, 3 Jul 2018 13:47:46 -0400 Received: from foss.arm.com ([217.140.101.70]:53658 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934218AbeGCRro (ORCPT ); Tue, 3 Jul 2018 13:47:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B01947A9; Tue, 3 Jul 2018 10:47:43 -0700 (PDT) Received: from [10.1.206.34] (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF4873F5BA; Tue, 3 Jul 2018 10:47:40 -0700 (PDT) Subject: Re: [PATCH v10 13/14] arm64: kexec_file: add kernel signature verification support To: AKASHI Takahiro Cc: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180623022058.10935-1-takahiro.akashi@linaro.org> <20180623022058.10935-14-takahiro.akashi@linaro.org> From: James Morse Message-ID: Date: Tue, 3 Jul 2018 18:47:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180623022058.10935-14-takahiro.akashi@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Akashi, On 23/06/18 03:20, AKASHI Takahiro wrote: > With this patch, kernel verification can be done without IMA security > subsystem enabled. Turn on CONFIG_KEXEC_VERIFY_SIG instead. > > On x86, a signature is embedded into a PE file (Microsoft's format) header > of binary. Since arm64's "Image" can also be seen as a PE file as far as > CONFIG_EFI is enabled, we adopt this format for kernel signing. > > You can create a signed kernel image with: > $ sbsign --key ${KEY} --cert ${CERT} Image > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index f68318f61c85..5133c22a01ab 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -845,6 +845,30 @@ config KEXEC_FILE > for kernel and initramfs as opposed to list of segments as > accepted by previous system call. > > +config KEXEC_VERIFY_SIG > + bool "Verify kernel signature during kexec_file_load() syscall" > + depends on KEXEC_FILE > + help > + Select this option to verify a signature with loaded kernel > + image. If configured, any attempt of loading a image without > + valid signature will fail. > + > + In addition to that option, you need to enable signature > + verification for the corresponding kernel image type being > + loaded in order for this to work. > + > +config KEXEC_IMAGE_VERIFY_SIG > + bool "Enable Image signature verification support" > + default y > + depends on KEXEC_VERIFY_SIG > + depends on EFI && SIGNED_PE_FILE_VERIFICATION > + help > + Enable Image signature verification support. > + > +comment "Image signature verification is missing yet" > + depends on KEXEC_VERIFY_SIG > + depends on !EFI || !SIGNED_PE_FILE_VERIFICATION This comment thing is a good idea, but its also a bit confusing... it took me quite a while to work out what was missing. Could we phrase it something like: "Support for PE file signature verification disabled!" This tells us its about PE files, and its probably a missing config option somewhere, not some code that hasn't been written yet. (which was my first assumption!). KEXEC_VERIFY_SIG presumably turns on just the IMA verification, which verifies the Image, but not in the same way as KEXEC_IMAGE_VERIFY_SIG.... (if I've understood it properly) Is there any reason to have these as separate enables? Couldn't we 'select SIGNED_PE_FILE_VERIFICATION if EFI' in KEXEC_VERIFY_SIG? This would mean there is one option to verify signatures, instead of two... (does it really depend on EFI?) Thanks, James