Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1477080pxm; Thu, 3 Mar 2022 19:20:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyz56DumZW6Aft+1E+TPBknVJaJqu2L1XMCTyQhOw5BYNUY3KLBFrPB9lxtuu8+uXsEVAjd X-Received: by 2002:a17:90a:af88:b0:1bd:6b5d:4251 with SMTP id w8-20020a17090aaf8800b001bd6b5d4251mr8466243pjq.134.1646364050292; Thu, 03 Mar 2022 19:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646364050; cv=none; d=google.com; s=arc-20160816; b=sjzoOaI17BSH0AFIT3faIWom6bwQPwtn5mARfUFIyGrHyltuhCobxtelqspuGbtnyk 2iq/5/fpmW0Uhj2mUvOiwog8lZH2LeFN5TTnaRHHlg4lsJxkpOXrsPhmXXXZiIKhzaDW k7ae0BYoNXo/cTF2Gv5twJK55gmVmHbfJSDeYynE7sRTKhkZbSsv1GZd9kN/DSR5kJUV hKQlRJSBpa3fDTwlhXoku+/bY/TIQ8fDxxFC0M02S/zcpQVWNvWo3VloMJclcpYIoj1f jRYYp/sUPk5a4WRuCngfBWMwPibcWEgYAELqMgj2+Tuv4HTd2ZHpu35+rHIjmMdJMetx +teQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FR7366Di99yTyHJIbovR9LHqPQL69gNs/+RxpOoEfdQ=; b=d4d8a01YRPMxAoQYttuQl5NEitpqHk4eQX05vRRzItThWxY7RUT+NCQ292HE6nVCeK GVosHkBoknqtR2OBYflunPGvFTSBoZ6KTiyWgQynVaoeOs2uRjdXVqbdNF75LcxhJntx BNNJQvIocCfxztOJ6YwhTuhRr0uyFt0SQuehbT30JaZ0sTKS1dn4hh9H22qcIP5MFOty EC0XbNgUYiGsRQHo7c+jj77CDYz38jm9/94kIK8JY6+64VNX40T02NrViDOxDOK9/VC4 sSwP24Scq2Z6YUtA7WYnDJXWgfDJnV0spI7oN+vrEMdv2qDZCrdA5NvB0/duCdNLad9d IfkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VJLlau3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a630213000000b0037c56cd75fbsi3314662pgc.118.2022.03.03.19.20.31; Thu, 03 Mar 2022 19:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VJLlau3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233901AbiCDCEp (ORCPT + 99 others); Thu, 3 Mar 2022 21:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbiCDCEo (ORCPT ); Thu, 3 Mar 2022 21:04:44 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B493A13D90D for ; Thu, 3 Mar 2022 18:03:57 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id bd1so6432201plb.13 for ; Thu, 03 Mar 2022 18:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FR7366Di99yTyHJIbovR9LHqPQL69gNs/+RxpOoEfdQ=; b=VJLlau3KSmcs7NGnpO9zSiLmHToeEVv2U1Y3zyv87tdjdXEwmoBehutpwwHFEQImR3 KYdPhwq3nbwlqbVynWP+9T00kskMgoKgW37M1jva2kQnpkqD6ZX54qve/Ajfn6fKxh1g 3Xh8w305m+aD5E8ZLQvcs7El6f0EhomMrBhVWjSfIIeBl5ONM97vaQKWYn0U/BSk4fae lmTUiI2L5kJOUsjW8xaZEX+Be2LEGARI8C0wgCBvqnwfLo9ee5m+SJ9crFJf7OfyHgXg CtO9uYYTKorZC3Dhbhn6nsxDNf4Zw/BB3m+EUcy2Jx32lKx2JgDIYD59sr/G7CnqN8KH hxTg== 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=FR7366Di99yTyHJIbovR9LHqPQL69gNs/+RxpOoEfdQ=; b=DqbFykJpXbTYKM0XYESOirDBmvQJ+lThpLU1hrjXdLb7PfoUryUmbwn1BTALI807yH RuwZ1HL3lIg4ULtO4hz2s1RtKroVIbUxMqss/vvFR2q96z5ohN9t5xOBupz64OCJDZXW d+G71PK14HnI/Yj90JzZPFIWiVRxsNM+hcPhZ8p3gQaQjc0RIJL8O3lFEp8DwiCTu6TK OMhI0n5HSZdiE261EmPg4432zpb1pzt5ZnAaxECaCOwzCV+9gry9BFKTuVZ0ZAq7fu4t h1qI0K7lG1ZSketuFgAr89t11HR0TUE2wXCquXJp5JHBu6YWSYivIVHsBovjGFcrRUJi W4Ww== X-Gm-Message-State: AOAM530A8F0bA7KkX21lzLM9DuOCXyULJs8TiWAQoZC766R/yzJWCxSR qk1KcsQH2JTamB3ULJMg098= X-Received: by 2002:a17:90a:eb07:b0:1be:f354:940a with SMTP id j7-20020a17090aeb0700b001bef354940amr8283349pjz.43.1646359437290; Thu, 03 Mar 2022 18:03:57 -0800 (PST) Received: from localhost ([240e:3a1:2e5:800:f995:6136:f760:a3d0]) by smtp.gmail.com with ESMTPSA id bh6-20020a056a00308600b004f6aa0367f6sm1162719pfb.118.2022.03.03.18.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 18:03:56 -0800 (PST) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Coiby Xu , linux-kernel@vger.kernel.org (open list) Subject: [RESEND PATCH v3 1/3] kexec: clean up arch_kexec_kernel_verify_sig Date: Fri, 4 Mar 2022 10:03:39 +0800 Message-Id: <20220304020341.85583-2-coiby.xu@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304020341.85583-1-coiby.xu@gmail.com> References: <20220304020341.85583-1-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coiby Xu commit 9ec4ecef0af7790551109283ca039a7c52de343c ("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)) { -- 2.34.1