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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B935AC433F5 for ; Thu, 14 Apr 2022 01:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239496AbiDNBsE (ORCPT ); Wed, 13 Apr 2022 21:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239500AbiDNBr5 (ORCPT ); Wed, 13 Apr 2022 21:47:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C26C252B1 for ; Wed, 13 Apr 2022 18:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649900733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UaUH/uBDt0Khh1i/AkQAQeFZf7ctY3a5V5SG+bAPmQY=; b=RC+9QE2ZbCehRQxP+3Hmg1epOJc5yvNrh/2NIKUFwV1K7zy6qEzVwQF4/DwRDVRgIxfLdW +cv0zxxi+HigCZPDSYQFOKw6JtirVdZZegvb7v9ORSOnAHg40iiqc5wmhNQNOWtCcYc6XQ QsYYW5h0KMc5vU8ZRffOtR9oVyJmv7I= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-iL0NJb2RP-eSttnPK0eorQ-1; Wed, 13 Apr 2022 21:45:32 -0400 X-MC-Unique: iL0NJb2RP-eSttnPK0eorQ-1 Received: by mail-pj1-f70.google.com with SMTP id r15-20020a17090a4dcf00b001cb7ea0b0bdso2257046pjl.1 for ; Wed, 13 Apr 2022 18:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=UaUH/uBDt0Khh1i/AkQAQeFZf7ctY3a5V5SG+bAPmQY=; b=l/TscxO1ZMAe6cl/hEFPr772dcAimhX1EbVRBNjyQzPejscT15hql5W+kja7UtnB1p 3gLMSz6d8opLLD0qCgpkR5UDLeVpXxu1lnkPz8r4WYRsEUB3z0gcb+h8SFLgC+Yuh624 MQk7FT3fiwOq14Hx8fgD1pE4ZmzkvRWFzSSNMIOlP7t7neX27ja/e1SzwcKQZyXiW/5B 06E17n4IRNiusCzxWlY8ycVKqfQ2xHVX8bEq1RDbp2OfApiqBaDBJ9zB63q89VCpI9dL OJUp+INUhL0lEKd1uTB/mkW7vCe3nuCPwoZpCpcV6NeWLJOUalU99Za2eDvBGdPXCOeH vD6Q== X-Gm-Message-State: AOAM532NBe84bKVvzA5vacYlOUzSbHM52KFRrGL3b0GsyuzjcuaehyUC p6Az0qJaNqF+dVb2VawesWQ9G87PpmW0Lhl6j6uAGrIw1tzw+mj6HZHQz8rK1bM0ERAe9cqAT6U eQpF+z4WPQQ/Qx41dUf60k5bt X-Received: by 2002:a17:90b:3b4d:b0:1cd:3ce7:aaec with SMTP id ot13-20020a17090b3b4d00b001cd3ce7aaecmr1137071pjb.32.1649900731303; Wed, 13 Apr 2022 18:45:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhkFSPwz69To4M7mJ3fKFULldZWpqa3OVP1lY/uMySD5zgHHwlIcM9BKs0THLjUvA8cwG07Q== X-Received: by 2002:a17:90b:3b4d:b0:1cd:3ce7:aaec with SMTP id ot13-20020a17090b3b4d00b001cd3ce7aaecmr1137051pjb.32.1649900731059; Wed, 13 Apr 2022 18:45:31 -0700 (PDT) Received: from localhost ([240e:3a1:31c:360:52fc:c968:cb41:efbc]) by smtp.gmail.com with ESMTPSA id u17-20020a056a00159100b004faef351ebcsm335950pfk.45.2022.04.13.18.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 18:45:30 -0700 (PDT) Date: Thu, 14 Apr 2022 09:44:46 +0800 From: Coiby Xu To: Michal =?utf-8?B?U3VjaMOhbmVr?= Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Catalin Marinas , open list Subject: Re: [PATCH v5 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature Message-ID: <20220414014446.tqopgaz2n3srwc6p@Rk> References: <20220401013118.348084-1-coxu@redhat.com> <20220401013118.348084-4-coxu@redhat.com> <20220411085938.GA163591@kunlun.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220411085938.GA163591@kunlun.suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 11, 2022 at 10:59:38AM +0200, Michal Suchánek wrote: >On Fri, Apr 01, 2022 at 09:31:18AM +0800, Coiby Xu wrote: >> Currently, a problem faced by arm64 is if a kernel image is signed by a >> MOK key, loading it via the kexec_file_load() system call would be >> rejected with the error "Lockdown: kexec: kexec of unsigned images is >> restricted; see man kernel_lockdown.7". > >This is because image_verify_sig uses only the primary keyring that >contains only kernel built-in keys to verify the kexec image. > >> This patch allows to verify arm64 kernel image signature using not only >> .builtin_trusted_keys but also .platform and .secondary_trusted_key >> keyring. >> >> Acked-by: Will Deacon >> Signed-off-by: Coiby Xu >> --- >> arch/arm64/kernel/kexec_image.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c >> index 9ec34690e255..51af1c22d6da 100644 >> --- a/arch/arm64/kernel/kexec_image.c >> +++ b/arch/arm64/kernel/kexec_image.c >> @@ -14,7 +14,6 @@ >> #include >> #include >> #include >> -#include >> #include >> #include >> #include >> @@ -133,8 +132,7 @@ static void *image_load(struct kimage *image, >> #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); >> + return kexec_kernel_verify_pe_sig(kernel, kernel_len); >> } >> #endif > >You can eliminate image_verify_sig here aswell and directly assign >kexec_kernel_verify_pe_sig to fops. Good suggestions, thanks! > >Thanks > >Michal > -- Best regards, Coiby 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA06CC433F5 for ; Thu, 14 Apr 2022 01:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XI7tsJFm67UhNnaOrvpegDBFLuDIlDLznz9rDHDdH1I=; b=B4ZrtZAixnw5A+mCxnP8+1Pn+u D6V07JvMWqqPPXS7H1uBbD7MPplTAZ3ebRjIky6TaKmWtg/NrvAUnwdBJ8CIKcaLvrlX+nxHxgWao 5+cDnbdJ7akjHX7bwMVpBq+C8hAoxbHGrlAnbbdR2aE+IhAgNwg/1UUmAFeqAgbHemQD7N2MEbSGY lrVDFAOTDOvbT1qfqTyxU3Ay2AWLvQ6tchq7ib4Pse4ebsTTf4Hh06g/UNhdC93tJBxe9Mhpla1e0 DC9nCp8v2/0nAq6GyFniAzxJ4PBoo06KQmOEVsOf99uKXIZXpPNIDIw3cG+j71E46gtBmgmPHA4OI /dFrT1WQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neoYI-003JcR-LU; Thu, 14 Apr 2022 01:45:43 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neoYA-003JYC-Jx for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 01:45:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649900733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UaUH/uBDt0Khh1i/AkQAQeFZf7ctY3a5V5SG+bAPmQY=; b=RC+9QE2ZbCehRQxP+3Hmg1epOJc5yvNrh/2NIKUFwV1K7zy6qEzVwQF4/DwRDVRgIxfLdW +cv0zxxi+HigCZPDSYQFOKw6JtirVdZZegvb7v9ORSOnAHg40iiqc5wmhNQNOWtCcYc6XQ QsYYW5h0KMc5vU8ZRffOtR9oVyJmv7I= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-sLdr7tZ7PD2uZRevzmSh6A-1; Wed, 13 Apr 2022 21:45:32 -0400 X-MC-Unique: sLdr7tZ7PD2uZRevzmSh6A-1 Received: by mail-pj1-f72.google.com with SMTP id p14-20020a17090a348e00b001cbc57fedc1so2252180pjb.3 for ; Wed, 13 Apr 2022 18:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=UaUH/uBDt0Khh1i/AkQAQeFZf7ctY3a5V5SG+bAPmQY=; b=mlnXFusiDuMnQntvzSUhZH04K0/poSVNALS/8FHSVQz+L8/s1c3Fnvg3QPE9J+ektP Ij7pHJNbAVIKQQNf2+8nVO1OZbUeBf7lPgGlJK+Cm3Z+XJbVF8lPeRPJ0iW1HFhJlC/F wh8zhGjdkpNRh9YL4kRe7og44hgVo52RkBQVUWDdDtpJgYbnkaieM2yEFeurupum2FYv qE7euezvgOzRXacjaOAPYKjQLK4Yj+Uae0a0npFdzAgJ222Zyfv8hlLokQeuHFBZZ14v s6AE++nwT1vlUiIwsHDjH8L5HKSJl6kXiuXoNpntx0VpzaQpbX1ej/mS0fe9zLGg7Wkl Idwg== X-Gm-Message-State: AOAM532WfxkkllqEhJZUm/AYrim4bxYJgrW3SZcZHfrqO27xCWxw8O40 oQAGJWoiCRQmC296TEMDxBbeyGyZxUKv9rUE4BVI+Wxal2FtagnQBg+StGbwBW9ifnAbAalEGQd MRbRl3QNN5XkP0AwZDxI+H65BzyI3yqxy5Gg= X-Received: by 2002:a17:90b:3b4d:b0:1cd:3ce7:aaec with SMTP id ot13-20020a17090b3b4d00b001cd3ce7aaecmr1137073pjb.32.1649900731305; Wed, 13 Apr 2022 18:45:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhkFSPwz69To4M7mJ3fKFULldZWpqa3OVP1lY/uMySD5zgHHwlIcM9BKs0THLjUvA8cwG07Q== X-Received: by 2002:a17:90b:3b4d:b0:1cd:3ce7:aaec with SMTP id ot13-20020a17090b3b4d00b001cd3ce7aaecmr1137051pjb.32.1649900731059; Wed, 13 Apr 2022 18:45:31 -0700 (PDT) Received: from localhost ([240e:3a1:31c:360:52fc:c968:cb41:efbc]) by smtp.gmail.com with ESMTPSA id u17-20020a056a00159100b004faef351ebcsm335950pfk.45.2022.04.13.18.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 18:45:30 -0700 (PDT) Date: Thu, 14 Apr 2022 09:44:46 +0800 From: Coiby Xu To: Michal =?utf-8?B?U3VjaMOhbmVr?= Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Catalin Marinas , open list Subject: Re: [PATCH v5 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature Message-ID: <20220414014446.tqopgaz2n3srwc6p@Rk> References: <20220401013118.348084-1-coxu@redhat.com> <20220401013118.348084-4-coxu@redhat.com> <20220411085938.GA163591@kunlun.suse.cz> MIME-Version: 1.0 In-Reply-To: <20220411085938.GA163591@kunlun.suse.cz> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=coxu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_184534_835302_D8484101 X-CRM114-Status: GOOD ( 17.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 11, 2022 at 10:59:38AM +0200, Michal Such=E1nek wrote: >On Fri, Apr 01, 2022 at 09:31:18AM +0800, Coiby Xu wrote: >> Currently, a problem faced by arm64 is if a kernel image is signed by a >> MOK key, loading it via the kexec_file_load() system call would be >> rejected with the error "Lockdown: kexec: kexec of unsigned images is >> restricted; see man kernel_lockdown.7". > >This is because image_verify_sig uses only the primary keyring that >contains only kernel built-in keys to verify the kexec image. > >> This patch allows to verify arm64 kernel image signature using not only >> .builtin_trusted_keys but also .platform and .secondary_trusted_key >> keyring. >> >> Acked-by: Will Deacon >> Signed-off-by: Coiby Xu >> --- >> arch/arm64/kernel/kexec_image.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_i= mage.c >> index 9ec34690e255..51af1c22d6da 100644 >> --- a/arch/arm64/kernel/kexec_image.c >> +++ b/arch/arm64/kernel/kexec_image.c >> @@ -14,7 +14,6 @@ >> #include >> #include >> #include >> -#include >> #include >> #include >> #include >> @@ -133,8 +132,7 @@ static void *image_load(struct kimage *image, >> #ifdef CONFIG_KEXEC_IMAGE_VERIFY_SIG >> static int image_verify_sig(const char *kernel, unsigned long kernel_le= n) >> { >> - return verify_pefile_signature(kernel, kernel_len, NULL, >> - VERIFYING_KEXEC_PE_SIGNATURE); >> + return kexec_kernel_verify_pe_sig(kernel, kernel_len); >> } >> #endif > >You can eliminate image_verify_sig here aswell and directly assign >kexec_kernel_verify_pe_sig to fops. Good suggestions, thanks! > >Thanks > >Michal > -- = Best regards, Coiby _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Coiby Xu Date: Thu, 14 Apr 2022 09:44:46 +0800 Subject: [PATCH v5 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature In-Reply-To: <20220411085938.GA163591@kunlun.suse.cz> References: <20220401013118.348084-1-coxu@redhat.com> <20220401013118.348084-4-coxu@redhat.com> <20220411085938.GA163591@kunlun.suse.cz> Message-ID: <20220414014446.tqopgaz2n3srwc6p@Rk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kexec@lists.infradead.org On Mon, Apr 11, 2022 at 10:59:38AM +0200, Michal Such?nek wrote: >On Fri, Apr 01, 2022 at 09:31:18AM +0800, Coiby Xu wrote: >> Currently, a problem faced by arm64 is if a kernel image is signed by a >> MOK key, loading it via the kexec_file_load() system call would be >> rejected with the error "Lockdown: kexec: kexec of unsigned images is >> restricted; see man kernel_lockdown.7". > >This is because image_verify_sig uses only the primary keyring that >contains only kernel built-in keys to verify the kexec image. > >> This patch allows to verify arm64 kernel image signature using not only >> .builtin_trusted_keys but also .platform and .secondary_trusted_key >> keyring. >> >> Acked-by: Will Deacon >> Signed-off-by: Coiby Xu >> --- >> arch/arm64/kernel/kexec_image.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c >> index 9ec34690e255..51af1c22d6da 100644 >> --- a/arch/arm64/kernel/kexec_image.c >> +++ b/arch/arm64/kernel/kexec_image.c >> @@ -14,7 +14,6 @@ >> #include >> #include >> #include >> -#include >> #include >> #include >> #include >> @@ -133,8 +132,7 @@ static void *image_load(struct kimage *image, >> #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); >> + return kexec_kernel_verify_pe_sig(kernel, kernel_len); >> } >> #endif > >You can eliminate image_verify_sig here aswell and directly assign >kexec_kernel_verify_pe_sig to fops. Good suggestions, thanks! > >Thanks > >Michal > -- Best regards, Coiby