From patchwork Fri Mar 18 09:40:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coiby Xu X-Patchwork-Id: 12785077 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 DDDABC433F5 for ; Fri, 18 Mar 2022 09:42:36 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9eh5fzLLd0vDIrHJ8RXu2RMIrBvLisarXoewytpasu8=; b=kxLcqbSZDdfwuo BWOinIsD59eVT0sK0K14uf1l9Jys2zQp6HQlA9MYOuIHoDEbDMYbjSV0WG8W7sl6R6ignjFsxBBvR WF5aqYlPoqXWCyAr29v0kLLAjNx9DFvNbvAi9ouE5O1C3Iq2v+J74y2JYqEjP7AcwOuXK+veNP4pB egiNTNlTsjUYkEgdf8kMw2ua8nLNKghzYflfTzjkzot7nyeZxHPm12icxZDSK7NlkAmdPXvu55sdB cIebULywadOHpk/ckQ3oXs6NEGVfIkOukx9Q9uSl+aj/p6OGyA67CgXt6SsinMRt6TqfyaNEiCD6/ Hk4LPcGxzeIr8I7IN4mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nV96q-000zy7-My; Fri, 18 Mar 2022 09:41:24 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nV96d-000ztV-U8 for linux-arm-kernel@lists.infradead.org; Fri, 18 Mar 2022 09:41:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647596470; 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=gwB9ZURkcH7/Y+etuUEb9xxXjVVCmMsQlrMh7LXVjOY=; b=b7eNLCj1+oycnLGllfRIb4LlfvNDURBVTsaxTWl32hadnEEhPBx3W1wFc9LxdgBUUXqGx+ fCnix96lqbJkZ5kKz+8h75P3b6wO99XEZN5XwUm2pIr6BoEm9caHusqsBQcpe4OYwAsnVf XEZWzKeu0FtYr924j7B0HmbQ8b0Pl3c= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-186-mDYHr686Nxa5CC2_hrM_gg-1; Fri, 18 Mar 2022 05:41:09 -0400 X-MC-Unique: mDYHr686Nxa5CC2_hrM_gg-1 Received: by mail-pf1-f197.google.com with SMTP id b19-20020a621b13000000b004fa68b3677bso1503602pfb.20 for ; Fri, 18 Mar 2022 02:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwB9ZURkcH7/Y+etuUEb9xxXjVVCmMsQlrMh7LXVjOY=; b=qdF+kTth8EfOeTKm36Ay67WhuF2oVOQev5YADZLNHnAzr9zFkOjF5N3rAms5RdR390 bX0YUHojZPp/hFy1K4Y7Ezg5bTMBqwXLlRBVclYbv+HOVI+uPb+PR/nCeZ1we3auVssY S3pUviBd1M0/OfvmfNc3McrXobEcxWmmUrKR3PjRltsK1bO1lIGDup2UggVWnFjyF9Bz NAYT3/jk9XNhMnacJtNSr0yqMozFu1PlMdWmZGHQ4udfRGzfGa0gi2sbH6Cba1y0qKZ/ umCSqEuP0QE5YEZt7AwfAnSo1mC3rwcj1VkavzO8fOVfW90O0zVofU1pozsW7vhU0Eqs fiKQ== X-Gm-Message-State: AOAM533EW+ME8BowN+PEJc4VfyNO53Q8/qKPIHvUavnpAOotZbV0/2MD MMUnRguhHOk6mWVhR6ZHrMUzuWEgoW9LM06IX0V2AoKue19Lc16AxtQigmzcXr9LSD2Lk6M6I+d bQAsiTl2lal5lSqp0uU0gmZfYiAw4Lc382ho= X-Received: by 2002:a17:90a:ca96:b0:1c6:b478:788e with SMTP id y22-20020a17090aca9600b001c6b478788emr1699045pjt.162.1647596468356; Fri, 18 Mar 2022 02:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgBkcXsK1rGQ1Ahb6434nwbtdmmC/q90wdZ/LIeinBZlv3tTPqVTddL5TmOxAl7jnaZ1Gryw== X-Received: by 2002:a17:90a:ca96:b0:1c6:b478:788e with SMTP id y22-20020a17090aca9600b001c6b478788emr1699023pjt.162.1647596468092; Fri, 18 Mar 2022 02:41:08 -0700 (PDT) Received: from localhost ([240e:3a1:2e5:800:f995:6136:f760:a3d0]) by smtp.gmail.com with ESMTPSA id m18-20020a639412000000b003820bd9f2f2sm3599952pge.53.2022.03.18.02.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 02:41:07 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig Date: Fri, 18 Mar 2022 17:40:59 +0800 Message-Id: <20220318094101.274950-2-coxu@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220318094101.274950-1-coxu@redhat.com> References: <20220318094101.274950-1-coxu@redhat.com> MIME-Version: 1.0 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220318_024112_080983_05D2ABA7 X-CRM114-Status: GOOD ( 13.80 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 9ec4ecef0af7 ("kexec_file,x86,powerpc: factor out kexec_file_ops functions") allows implementing the arch-specific implementation of kernel image verification in kexec_file_ops->verify_sig. Currently, there is no arch-specific implementation of arch_kexec_kernel_verify_sig. So clean it up. Suggested-by: Eric W. Biederman Signed-off-by: Coiby Xu --- include/linux/kexec.h | 4 ---- kernel/kexec_file.c | 34 +++++++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 0c994ae37729..755fed183224 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi, const Elf_Shdr *relsec, const Elf_Shdr *symtab); int arch_kimage_file_post_load_cleanup(struct kimage *image); -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, - unsigned long buf_len); -#endif int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf); extern int kexec_add_buffer(struct kexec_buf *kbuf); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 8347fc158d2b..3720435807eb 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image) return kexec_image_post_load_cleanup_default(image); } -#ifdef CONFIG_KEXEC_SIG -static int kexec_image_verify_sig_default(struct kimage *image, void *buf, - unsigned long buf_len) -{ - if (!image->fops || !image->fops->verify_sig) { - pr_debug("kernel loader does not support signature verification.\n"); - return -EKEYREJECTED; - } - - return image->fops->verify_sig(buf, buf_len); -} - -int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, - unsigned long buf_len) -{ - return kexec_image_verify_sig_default(image, buf, buf_len); -} -#endif - /* * arch_kexec_apply_relocations_add - apply relocations of type RELA * @pi: Purgatory to be relocated. @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) } #ifdef CONFIG_KEXEC_SIG +static int kexec_image_verify_sig(struct kimage *image, void *buf, + unsigned long buf_len) +{ + if (!image->fops || !image->fops->verify_sig) { + pr_debug("kernel loader does not support signature verification.\n"); + return -EKEYREJECTED; + } + + return image->fops->verify_sig(buf, buf_len); +} + static int kimage_validate_signature(struct kimage *image) { int ret; - ret = arch_kexec_kernel_verify_sig(image, image->kernel_buf, - image->kernel_buf_len); + ret = kexec_image_verify_sig(image, image->kernel_buf, + image->kernel_buf_len); if (ret) { if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)) { From patchwork Fri Mar 18 09:41:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coiby Xu X-Patchwork-Id: 12785078 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 D6C56C433EF for ; Fri, 18 Mar 2022 09:42:47 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Uf73j6MUsj7nM4RP3K0XGueviZ2t8MBXz4APboZN63s=; b=ZOvGbbAVT1xZlH pEKeMNt01CEcyCLs1Ba019ynSdlwr5y7ZronXiKuCGfjvlJx3WrBCtMkT2IuenLxyOHQ59iV9MGBC FbLRsz414MVG+lQMkfW880fHds1RM3tS8/ir0lbgXCqQ1NvTKB7rlCvPCrRYOEQtQMI19ZdlxIbk5 kGUOr+U/KMpQhYPAODPRmrPSvfO8S/de0SUrPkfW/zPSWIy1GKZ9OuA3q++nj/cMtaEbEFP3KkLx1 +DCD07ygdhiTnobpFWlNQGorTHwpq2tpWBtS/fSL3ltGV/NzEzN0A8Z5mVzLjH4cJE+PMFEjd8YMc e1XQA6nh6RR4VuIckQcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nV973-00102m-8b; Fri, 18 Mar 2022 09:41:37 +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 1nV96h-000zuH-06 for linux-arm-kernel@lists.infradead.org; Fri, 18 Mar 2022 09:41:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647596474; 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=XVmPCPO0oF3pRYu+F7qpHdcQzaq88pJ0kcN8pmyvV4M=; b=WdLsD6qLqu8ka1Z8ad0N8Hc5Pc0ewwAGsVIzk/yxaVSNJ7eARarvEhPaIo6+/EYqbCVd1k 1o6U++qNOkSjgLl1FacIyzrfyH0hj85TBnpaRDzLPk2eEv0cUE3foHKPuU1ThDv7Z8vZZf C2ZQhA8zI8lC8PDxcLNiErj09aUHYGw= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-c2b24lKTMe6O2RpgJ-T-nw-1; Fri, 18 Mar 2022 05:41:12 -0400 X-MC-Unique: c2b24lKTMe6O2RpgJ-T-nw-1 Received: by mail-pf1-f198.google.com with SMTP id i2-20020a056a00224200b004fa60c248a1so1852219pfu.13 for ; Fri, 18 Mar 2022 02:41:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XVmPCPO0oF3pRYu+F7qpHdcQzaq88pJ0kcN8pmyvV4M=; b=EFbrWNmf9XOPMmRGyrdExd+tPqOpPTeDC3u2yJJhgOUz7v+tqmmD3siojR2oMz3mNw +htCN9LJE2BigBgsKfn6wvhGBFg+aHaQecdV9D9jVFjlkWarwEjFFFcnObsiZ0/NziwD 3yUNcukygA1xR0tuAin2b/llkhUumFIJtmXJTI9aEhVEAHxCxe6nwgC1qkGjx1Exmzbp 62ZS2mkLCiMZSHivX8b8lywbfG3iOjA/IruHDlzeVe3s7lbVxEA0Bi8yU0QTWHitYI5M MpV2aDC31nhfZ0Nlv/XGzRd78cbRvzq0nK+2h9oSIX6lhAFdvt3A6/LPhRgdGJO7Yq1U NkYg== X-Gm-Message-State: AOAM532iKUBr2oYOAgsY5zgsXKF++DgrerVFij9ldWMjbaHH+ZJ76ocE AP+mp5JBZdD9eqhsCpNxzzwG+wuGNgOQrzO470yszw6ezT16iQMd4KOlUPNcQ6Tu1Tw4MUi3rJM WOg0KHxTYKD/5UjNKtv1f64nzdrdfrEGgoFw= X-Received: by 2002:a63:ab47:0:b0:375:5d05:9f79 with SMTP id k7-20020a63ab47000000b003755d059f79mr7232003pgp.192.1647596471696; Fri, 18 Mar 2022 02:41:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC67EGQnlUHMa8v+f0Jvrco6hTVeignBbFV846ZQZwUN1ugwR1tKrHp9uyTiLPMVPVkFvsXA== X-Received: by 2002:a63:ab47:0:b0:375:5d05:9f79 with SMTP id k7-20020a63ab47000000b003755d059f79mr7231986pgp.192.1647596471470; Fri, 18 Mar 2022 02:41:11 -0700 (PDT) Received: from localhost ([240e:3a1:2e5:800:f995:6136:f760:a3d0]) by smtp.gmail.com with ESMTPSA id q16-20020a056a00151000b004f7cdeddfffsm9107299pfu.115.2022.03.18.02.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 02:41:10 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [PATCH v4 2/3] kexec, KEYS: make the code in bzImage64_verify_sig generic Date: Fri, 18 Mar 2022 17:41:00 +0800 Message-Id: <20220318094101.274950-3-coxu@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220318094101.274950-1-coxu@redhat.com> References: <20220318094101.274950-1-coxu@redhat.com> MIME-Version: 1.0 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220318_024115_179748_E3B384BF X-CRM114-Status: GOOD ( 14.31 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The code in bzImage64_verify_sig could make use of system keyrings including .buitin_trusted_keys, .secondary_trusted_keys and .platform keyring to verify signed kernel image as PE file. Make it generic so both x86_64 and arm64 can use it. Signed-off-by: Coiby Xu --- arch/x86/kernel/kexec-bzimage64.c | 13 +------------ include/linux/kexec.h | 7 +++++++ kernel/kexec_file.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 170d0fd68b1f..f73aab3fde33 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -531,17 +530,7 @@ static int bzImage64_cleanup(void *loader_data) #ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len) { - int ret; - - ret = verify_pefile_signature(kernel, kernel_len, - VERIFY_USE_SECONDARY_KEYRING, - VERIFYING_KEXEC_PE_SIGNATURE); - if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) { - ret = verify_pefile_signature(kernel, kernel_len, - VERIFY_USE_PLATFORM_KEYRING, - VERIFYING_KEXEC_PE_SIGNATURE); - } - return ret; + return kexec_kernel_verify_pe_sig(kernel, kernel_len); } #endif diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 755fed183224..2fe39e946988 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -19,6 +19,7 @@ #include #include +#include #ifdef CONFIG_KEXEC_CORE #include @@ -196,6 +197,12 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi, const Elf_Shdr *relsec, const Elf_Shdr *symtab); int arch_kimage_file_post_load_cleanup(struct kimage *image); +#ifdef CONFIG_KEXEC_SIG +#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION +int kexec_kernel_verify_pe_sig(const char *kernel, + unsigned long kernel_len); +#endif +#endif int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf); extern int kexec_add_buffer(struct kexec_buf *kbuf); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 3720435807eb..754885b96aab 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -165,6 +165,23 @@ void kimage_file_post_load_cleanup(struct kimage *image) } #ifdef CONFIG_KEXEC_SIG +#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION +int kexec_kernel_verify_pe_sig(const char *kernel, unsigned long kernel_len) +{ + int ret; + + ret = verify_pefile_signature(kernel, kernel_len, + VERIFY_USE_SECONDARY_KEYRING, + VERIFYING_KEXEC_PE_SIGNATURE); + if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) { + ret = verify_pefile_signature(kernel, kernel_len, + VERIFY_USE_PLATFORM_KEYRING, + VERIFYING_KEXEC_PE_SIGNATURE); + } + return ret; +} +#endif + static int kexec_image_verify_sig(struct kimage *image, void *buf, unsigned long buf_len) { From patchwork Fri Mar 18 09:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coiby Xu X-Patchwork-Id: 12785079 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 66936C433F5 for ; Fri, 18 Mar 2022 09:43:05 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kryg+5fXk4ZgYKKsHUfVRRmzjy6xrvhcHeoUCepBwes=; b=o/iPbAhCx1a9Nz /ZpqYY4Ac8Vp//eyQPOiEGnNsuN5JS4MOEFknJfVi0MCXuT4zbx+FofoS1Qsxk7RC2jpiXYrBNh45 mjkFL4F/7M70XsNzNqsxFvHhN8ZAoMy+sOHkGpYnHRgpbU7XELdh+kzE0yFT4VA9VV0IVmfpqZiyu 0en0p7ejQ/3mysi1j7WFfdooT5tJ5p3nsaIyifYfmHds+cHaWGZ+v2wVCSaxVKN5YVAChnfR1lqbf e6GwFEou7PeiGoc2nVs4IppvZSjJkAJhQrn2bBDrs8C3c0HKK6Z7RSK+od67Yq5paxmvFYG3TLeK5 mQ67r20izwap5UAJJrlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nV97H-00108u-TK; Fri, 18 Mar 2022 09:41:52 +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 1nV96l-000zvm-Ci for linux-arm-kernel@lists.infradead.org; Fri, 18 Mar 2022 09:41:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647596478; 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=DFnb1M2EIoVuc/P5RSzyYqF5MQJZi0h79OModGmGN0w=; b=Sqrjr5CfkeZ2aGehwv9MUV/3E4LSLrw7G+XQSE0CRBajIOx3EQ/gVQwHZxog5NaSrowDKo hxdTKFZ/yZ0f8DBDtMgHimkiMgxnNpowT+GQdtAwAbRvnaAqoCDC/DxFNH5Oyd1iNACXyQ i6Lm2u+qnqORq1tekdYpBkzw5dqsiDE= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-ZqVdruwcOp6ppj8PkH2x3A-1; Fri, 18 Mar 2022 05:41:17 -0400 X-MC-Unique: ZqVdruwcOp6ppj8PkH2x3A-1 Received: by mail-pf1-f198.google.com with SMTP id b19-20020a621b13000000b004fa68b3677bso1503754pfb.20 for ; Fri, 18 Mar 2022 02:41:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DFnb1M2EIoVuc/P5RSzyYqF5MQJZi0h79OModGmGN0w=; b=q0/7sR+Sk8g/bR2NFUGb5vI+ZjrscYrr3pP7fl4Q55OIN6aaD9OhA2MBr/i7/+HJBj b4XE2zRUjg8KzxVLrwHT44RtUs0VEFHOTmXchXj8S1pAKfhTMwmfzh2BLymEbDp5MkTu JOk49FUEQoAmqyRyzSMMwHf7rOA9k3QuQXX8kf5oGj/xX8MxKl25I/lR4dP+Q6go0W8b V8kEhr7fZ/rCtJJxA0Dd3fI7k+RPqa2e6MN/Kkp+9HidYFMjOkbd7KdeWsoOWc2Jefje maI0BVUOjzpd//rv7KzqJvFRIqj+XzczIYBc4E1Ig64Y4FTpouyFtq2moiTeaYAL1HJ7 zVgA== X-Gm-Message-State: AOAM530LdD83+rr1gBnBXQRp0QAy8CchPTKUmwOM1OHB05GkYpZwi6vw SCzwxEO1J2U5i2vL5teloTFs1LcHMawJq240BhMSZy/TFAMj+Znwo6Sm15jn+qB2G3GITmKQ5X8 p2g4lmvA8jkbXEvTrNH8lXbgreN8ShAz/hM8= X-Received: by 2002:a17:90a:2dc6:b0:1bf:654e:e17f with SMTP id q6-20020a17090a2dc600b001bf654ee17fmr10153827pjm.64.1647596475808; Fri, 18 Mar 2022 02:41:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSZE86KXD2JeC35ujxrinCaDl8UVUyVWu0d7AoIhInD1hZpGVEB0gCt6zGlQQDIot8DU43WQ== X-Received: by 2002:a17:90a:2dc6:b0:1bf:654e:e17f with SMTP id q6-20020a17090a2dc600b001bf654ee17fmr10153807pjm.64.1647596475545; Fri, 18 Mar 2022 02:41:15 -0700 (PDT) Received: from localhost ([240e:3a1:2e5:800:f995:6136:f760:a3d0]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a1f8700b001bf1db72189sm7788102pja.23.2022.03.18.02.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 02:41:14 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Catalin Marinas , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature Date: Fri, 18 Mar 2022 17:41:01 +0800 Message-Id: <20220318094101.274950-4-coxu@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220318094101.274950-1-coxu@redhat.com> References: <20220318094101.274950-1-coxu@redhat.com> MIME-Version: 1.0 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220318_024119_625121_52746D57 X-CRM114-Status: GOOD ( 11.62 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This allows to verify arm64 kernel image signature using not only .builtin_trusted_keys but also .secondary_trusted_keys and .platform 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