Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp131461iob; Thu, 12 May 2022 20:46:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1q57mQV2UNvpODWq/EfSGdwuaPCEL0z30ieOkVu5oG2rPi8ZcKprFLY6EIoO1b2obKNBt X-Received: by 2002:a65:6047:0:b0:3c1:43c9:a4d9 with SMTP id a7-20020a656047000000b003c143c9a4d9mr2332083pgp.324.1652413580913; Thu, 12 May 2022 20:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652413580; cv=none; d=google.com; s=arc-20160816; b=swg+16FM4QLeJHwwYtgdmIWUVPSk+01ugoE12fUolc8buWZI3wsMVh1kZGc4JZU4N9 WNDCEo9jUwP9wS6J8wQXoPHTIrs0iByekl6GeL/ASPgjJVF7QbNAgdcVvDKWdt3fX5Ga 5k8/IJs4cqzrozOm9n8fBI0j4f+EK1X+t7NV1CTcbpTX7fn4SlpWIAU7blAOxubY/ERc YdsMlLQNKda5d+wvSCx8/+XROfYR1jrOAshcc4h1BaTQNVF4LPlFXwLg7K3UKtKlKOk3 cLhfpjPMyQh1UV+N5CYZBhBHNL6Z0egsKNKX488upmKH87+6N+XPaJwfIPXfMpxpn9/n QNtw== 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=Mevjy/DGPy4eqIk5EbdLPFrJaGfCXH1nWhTn6iIdPnc=; b=clZPJ4nFkJhN2UgzCpYCnUC2kMdcEgt7+s5HF2U3aUhZC4G09EaFIOxVhHb4wOhQI4 tvTdbFMhj6aas+9+RPXcQcZPKJdTbgvBF4d1kR8m+KpFcRRjf0qKvMoEtS0GuJYsDHIC zbwzalb/dQFdELgF1HpV84j92ZR4V7VQuJ2Ly3C7+5of2pMCypw1TZEzDyor/jra3Odw JoilUjGYOsn9SNN4id9IIrBKYh4wtNunjztf9iI9KYzSW5P1IBT9pfRIr5cEjHNgcgpu MLW/HEoK5xbpP9ENO4M61es2fcaZohn5r+mXBPkf57pOwjzdeKwO4q1eQn/GagZsIIsP AlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZoeeCNPR; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a170902d39100b0015e99deb6cdsi1391515pld.135.2022.05.12.20.45.47; Thu, 12 May 2022 20:46:20 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=ZoeeCNPR; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350668AbiELHC3 (ORCPT + 99 others); Thu, 12 May 2022 03:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350667AbiELHBv (ORCPT ); Thu, 12 May 2022 03:01:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8DC54C79A for ; Thu, 12 May 2022 00:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652338899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mevjy/DGPy4eqIk5EbdLPFrJaGfCXH1nWhTn6iIdPnc=; b=ZoeeCNPR/aOk2V3PNN2CKuBSBu7O1CUmGZqoNvXlPTPvRKDt+3ASMBGvnw0+52TE+gB6sK 1oqk04mnXQC2ClKghKzXDSDjJMAje9NypZS23lZXeO2MDPLFhvIB9/aiwN+4M7pOmhnXvu dmaulrMcLg4nXA2U9XRHJu6AGOYc9Zs= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-2KTnk0wGPQK3C8vZq8b6bQ-1; Thu, 12 May 2022 03:01:38 -0400 X-MC-Unique: 2KTnk0wGPQK3C8vZq8b6bQ-1 Received: by mail-pg1-f200.google.com with SMTP id q143-20020a632a95000000b003c1c3490dfbso2189771pgq.20 for ; Thu, 12 May 2022 00:01:37 -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=Mevjy/DGPy4eqIk5EbdLPFrJaGfCXH1nWhTn6iIdPnc=; b=to+OuMtX3wKUOECtXFziTBv5hNLfi3OAlkT15B6m6/JhSS0UcQjCKaOb1eYfsAQK4e yPOR1SluILNmmXFg8SL3z3ytRvKqlNzOHAyaK2VCmrnWcXKkOINbsxK8mX2248QqHhFs 3405Vg0yFzji6M1osUdEupvklltI/HMrvBpJvdVlirgqFRgKTkYFjLEEZJv88ci5aHFW kxApzc0gUbRbT3lQx+9usRSPVhJjX3xtPibGvktIxJq0u3cxdXGkftrnYy7MtYUtorSq DDrRowWWGLHR1th57CpgYpELw7e4eQVXOypea8VzM+JVHDMQDhkTiSR0Oz1Vk19cBzhT ZPhw== X-Gm-Message-State: AOAM531jzIfKbaobEk+jxuGHHjkxSybirb2COSlacwuMBPDvik8bcxLP oz6LuUwU61QY7dIEv3sAc6MEzIcuu3XDbgpsIx+ZGQvQTeZX21yX0tlRD8FL49hPP57hnuAyuW2 AFthmeNOLN4MJpqozz18XpBya X-Received: by 2002:a17:90b:50b:b0:1dc:a0b1:c783 with SMTP id r11-20020a17090b050b00b001dca0b1c783mr9496056pjz.49.1652338895898; Thu, 12 May 2022 00:01:35 -0700 (PDT) X-Received: by 2002:a17:90b:50b:b0:1dc:a0b1:c783 with SMTP id r11-20020a17090b050b00b001dca0b1c783mr9496032pjz.49.1652338895671; Thu, 12 May 2022 00:01:35 -0700 (PDT) Received: from localhost ([240e:3a1:2e9:efa0:e73c:e550:ac9e:58fd]) by smtp.gmail.com with ESMTPSA id gn21-20020a17090ac79500b001d903861194sm1082640pjb.30.2022.05.12.00.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 00:01:35 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Michal Suchanek , Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Mimi Zohar , Chun-Yi Lee , stable@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, Catalin Marinas , James Morse , AKASHI Takahiro , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 3/4] arm64: kexec_file: use more system keyrings to verify kernel image signature Date: Thu, 12 May 2022 15:01:22 +0800 Message-Id: <20220512070123.29486-4-coxu@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512070123.29486-1-coxu@redhat.com> References: <20220512070123.29486-1-coxu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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 happens 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_keys keyring. Fixes: 732b7b93d849 ("arm64: kexec_file: add kernel signature verification support") Cc: stable@vger.kernel.org # 34d5960af253: kexec: clean up arch_kexec_kernel_verify_sig Cc: stable@vger.kernel.org # 83b7bb2d49ae: kexec, KEYS: make the code in bzImage64_verify_sig generic Acked-by: Baoquan He Cc: kexec@lists.infradead.org Cc: keyrings@vger.kernel.org Cc: linux-security-module@vger.kernel.org Co-developed-by: Michal Suchanek Signed-off-by: Michal Suchanek Acked-by: Will Deacon Signed-off-by: Coiby Xu --- arch/arm64/kernel/kexec_image.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c index 9ec34690e255..5ed6a585f21f 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 @@ -130,18 +129,10 @@ static void *image_load(struct kimage *image, return NULL; } -#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 - 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, + .verify_sig = kexec_kernel_verify_pe_sig, #endif }; -- 2.35.3