Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp461059imm; Thu, 26 Jul 2018 06:41:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpePu55hjhT5w9yComu+4PWO3G5i5PupP5+7yQlHHEqitQT2f1MU9OxZu79ey6mgVBT+t9f2 X-Received: by 2002:a65:5803:: with SMTP id g3-v6mr2042883pgr.117.1532612475833; Thu, 26 Jul 2018 06:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532612475; cv=none; d=google.com; s=arc-20160816; b=NHe+YIxKpDtNleCl3pdbddPyt5sSRIIwcdMeakJpIX3zpNX1B2kikbs0kUF3VR0lVZ YRo5AUJJz9eRBQ3vMdvwv8ym9WmBw1fLTX6Wq9qfJ3p/wXvWqx7drM1Arie+s7EA9Ogi sZTtbjbnhx5B/r9bjUeos6EEEfJCfs6ZF/cPU0RXpCFvSfU/DgUkJ+dh+5bIB+nTvjlT I5MLxHq2Sk2MMCcQEUriXwWFaLWN3I1Hnwa5xegOdSq9oroFibsHxmDkCOxAzpH2LWCg tS02HRM/OPfl6dgu57Mt6oqdMmtCamnKkhNBCM4hIRPjVFar7mIdRnbmoYnm+00fJHrj ET8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=G4TRie7jJ0Y9Ebl4anWXyONKzjq/5RaLcWJvl59MOpQ=; b=H/oF+TO1qx5evw1kYkYK6mJ0VazR3bArEMZF2ZewI6eZZGSb5LnugUKMbXhKH1Tc/J NXbIOzvz0uC8rURjY/9x8wTc4Itnw8uCuSyRgX6IEsUZ48NbBy2zKJ+MijjrTjTwhezR qq6eSd/ZQXMPj6fJJfdZS3umO4MzkquRJEHHolsHCcCYrHcIIXk6YyoGaYheZ6VwYbuU 5kSiQOBqnWpd84Ey9vuWtE49IszB/FJUC9GHWon1FIBzfPbLEveYIPLrFSNXJTQ6SUQT Y3xDcSvAD+jYtONWNDNOt7eJyjrJv3mnZc7LLxES7ue9mGiKrvnfPEQtkvD9b3HPFDui +fXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t89-v6si1449597pfe.59.2018.07.26.06.41.00; Thu, 26 Jul 2018 06:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730105AbeGZO4Z (ORCPT + 99 others); Thu, 26 Jul 2018 10:56:25 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56122 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbeGZO4Z (ORCPT ); Thu, 26 Jul 2018 10:56:25 -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 E3DFD15A2; Thu, 26 Jul 2018 06:39:29 -0700 (PDT) Received: from [10.4.12.81] (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D3013F6A8; Thu, 26 Jul 2018 06:39:27 -0700 (PDT) Subject: Re: [PATCH v12 15/16] 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, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180724065759.19186-1-takahiro.akashi@linaro.org> <20180724065759.19186-16-takahiro.akashi@linaro.org> From: James Morse Message-ID: Date: Thu, 26 Jul 2018 14:39:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180724065759.19186-16-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 24/07/18 07:57, 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 Reviewed-by: James Morse > diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c > index d64f5e9f9d22..578d358632d0 100644 > --- a/arch/arm64/kernel/kexec_image.c > +++ b/arch/arm64/kernel/kexec_image.c > @@ -102,7 +106,18 @@ static void *image_load(struct kimage *image, > return ERR_PTR(ret); > } > > +#ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG > +static int image_verify_sig(const char *kernel, unsigned long kernel_len) > +{ > + return verify_pefile_signature(kernel, kernel_len, NULL, > + VERIFYING_KEXEC_PE_SIGNATURE); > +} > +#endif This is identical to x86's PE image verification helper. We can clean this up later by providing some kexec_image_verify_pe() in the core kexec_file code. Its not worth doing now. > const struct kexec_file_ops kexec_image_ops = { > .probe = image_probe, > .load = image_load, > +#ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG > + .verify_sig = image_verify_sig, > +#endif > }; Thanks, James