From patchwork Fri Aug 25 06:18:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=wZ0fSfqK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RX8sz400Xz1yfF for ; Fri, 25 Aug 2023 16:19:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qZQ9m-0004Xc-9y; Fri, 25 Aug 2023 06:18:54 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qZQ9f-0004Ss-8s for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:47 +0000 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C4BB63F657 for ; Fri, 25 Aug 2023 06:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944326; bh=ZBZjnT0kG2DdpOzgXNa07ul3OjRXswR9ARJFqn693Jo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wZ0fSfqKczuI1CNBPKT/LAq55HJm9BFXMRYjVhqwtb728VB5Y9kv7f9hce3bg1O81 3oFH1Sb0/vbVgrELz4q14XlmJbnmYgoSDpAOH1892o0XSkgk/9UNGRNMA9NcvR9d5j JKZ7+zTzrYvHnr82RgKABzYAR2IsZLF0csGnJuVjR6g51rEVa12IjH2ipQ/i3Rmmsm y5EsUaejPv1u7bZhGVt55R3J43iLx+UwbP9Y8nKTnl2JWiVhUBjzzlRFdL5R7EWJ8o NhHwImyWW/XW8szpu2Mu9t8ShHgGGdFeGt96S/rNhvq9LjeDKmQDcjnjZPNs7IS0vD jV8lCnCETPpOA== Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3a741f4790fso679217b6e.0 for ; Thu, 24 Aug 2023 23:18:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944324; x=1693549124; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZBZjnT0kG2DdpOzgXNa07ul3OjRXswR9ARJFqn693Jo=; b=VecmxMVmH2qiT9llup+3ZrIeUchxVJLFWvW/wemYfystgDlpLZJ45k3BC6Cvj7gI6r DQYIPLtK23pJL12RM3q0L5o18aLYGTaCGoch9WgEvndXIy6w4svkZfHw4cU/nb1mE0+O EYhnkauA+guM4x2zJwfc9pXtlTMjnRgzD0YclfcTtpy2zlfHHjTuyzT6I2GYjGcZWyQR 8mRDENr+2JrwN4++W9DyhVkkdJvpqn7U3+LRmK08zsPu7Wepsp0FZbtrwV07SLsmz1fG gg3HZUNNvQuk5e3gSdkS2jdAdIhEEFRldjDvLFH61/NyAw+A07QnBRZYKNJWCRXPg5PO 1sHw== X-Gm-Message-State: AOJu0YyKNCLqfbvqZvHfdxD1kb3Vyi0RwsIglgOwUzqTPWhcITMKmvs0 0xM9tivFXbWGInQcOz/5L9Wuik05EK48o7lPd/NLK+hLEv+lfzrOCXoCmFHhoHRMb1nCj1N/HYO +tmb62SoWBOyN49em7DobapHW8rkfwesCEifir9LMpqTvJTthF85Dmeg= X-Received: by 2002:a05:6808:2a6f:b0:3a4:225d:82c0 with SMTP id fu15-20020a0568082a6f00b003a4225d82c0mr1866748oib.31.1692944324606; Thu, 24 Aug 2023 23:18:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEm2lDXXiWgX6aN/dR6jsULoxUx3d6/UkYHRW2pkmvGHa+BbIYAEHrc2vVAad2ZQgJnGsuTg== X-Received: by 2002:a05:6808:2a6f:b0:3a4:225d:82c0 with SMTP id fu15-20020a0568082a6f00b003a4225d82c0mr1866742oib.31.1692944324390; Thu, 24 Aug 2023 23:18:44 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id u4-20020aa78484000000b00660d80087a8sm728664pfn.187.2023.08.24.23.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:43 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/3] UBUNTU: [Config]: Enable CONFIG_KEXEC_IMAGE_VERIFY_SIG Date: Fri, 25 Aug 2023 14:18:37 +0800 Message-Id: <20230825061839.52444-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061839.52444-1-chengen.du@canonical.com> References: <20230825061839.52444-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" This option enables support for kexec image signature verification, allowing signed kernels to be loaded via the kexec_file_load system call. Signed-off-by: Chengen Du --- debian.master/config/annotations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian.master/config/annotations b/debian.master/config/annotations index 5f854837a810..ee85d6e14274 100644 --- a/debian.master/config/annotations +++ b/debian.master/config/annotations @@ -6535,7 +6535,7 @@ CONFIG_KEXEC policy<{'amd64': 'y', 'arm64': ' CONFIG_KEXEC_CORE policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'ppc64el': 'y', 's390x': 'y'}> CONFIG_KEXEC_ELF policy<{'ppc64el': 'y'}> CONFIG_KEXEC_FILE policy<{'amd64': 'y', 'arm64': 'y', 'ppc64el': 'y', 's390x': 'n'}> -CONFIG_KEXEC_IMAGE_VERIFY_SIG policy<{'arm64': 'n'}> +CONFIG_KEXEC_IMAGE_VERIFY_SIG policy<{'arm64': 'y'}> CONFIG_KEXEC_JUMP policy<{'amd64': 'y'}> CONFIG_KEXEC_SIG policy<{'amd64': 'y', 'arm64': 'y'}> CONFIG_KEXEC_SIG_FORCE policy<{'amd64': 'n'}> From patchwork Fri Aug 25 06:18:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ocHqcScp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RX8sv1YTdz1yg8 for ; Fri, 25 Aug 2023 16:18:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qZQ9j-0004VQ-BI; Fri, 25 Aug 2023 06:18:51 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qZQ9g-0004TP-1F for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:48 +0000 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id CACF73F21F for ; Fri, 25 Aug 2023 06:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944327; bh=xhXV4Hk839H5iwPbE5GVmiOWTcXerJNJbhtO2vylqqU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ocHqcScpwU0V6ITlscSoZCzjaI1cF5r9F/DPPAr2V8ldrRHRcpqXAF+28wuq1ysQn uSD2Y0giE280QNemlkNvye9VZknTiOUieskYC1V3QJaBQAV5en6nkIAe7uqiqCLhrt mUkKMIsdwp2sb53L0mv2+cSODXYEWx0K90sZvijICv468sWS3A+Ynxrqtt63ytDkV8 yhsbMb6VpK0Z65qpY5eEO1a/Rg7FAIduhyJiDJUAf8yS3oYXDz1JaniMNH3hUGV1es l/fiebGHKum/cnD7KwGoTq93HgL5+Cc97RfwK5hsm6VaaEkUYYnWcQK4zFUjP0fz+Q z/UR827HKTyXg== Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-68bf123af64so764868b3a.2 for ; Thu, 24 Aug 2023 23:18:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944326; x=1693549126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xhXV4Hk839H5iwPbE5GVmiOWTcXerJNJbhtO2vylqqU=; b=UOIXudKSPdzQXP1g6CKHN6XloeCBvRh31vceU6cdTQLsyMdvsit0iX2zvdgtEgiJcR 8GxsiW49xtqC/a1gPUsD3AKWYQ4F55axMpVnKC/0xwnreQgfwsRVZ7aCZPxTjt0QDz+s sjYvpQbMKIrRoxOoEwwnWcju9F+XJ46BW7902QSXo133b5V5aX2GhtQzobiJLAPpC1Hf mEcG8ebYX2rlm0wwRDZXCz0wDSElEX672G1K568Y1KGVR5uo/5IIspWFL08TRjsLWiWA VSp1coFGLRoLaifVo9TlFBtYkZR3Ix93CupGW7AlWzPJaIVHBbKD/qkIZSVZcihiU3G9 vxqQ== X-Gm-Message-State: AOJu0Yz37uwqmFY65Cew9Ukgoj7stONTwyt2DGD6rUWHICJRPStXc7Kd slYuq2F6wftCYu1WibFxTXLvnEzeLeAF5J+FMdUsp/zNzfz/Sj1T1A83U6BOYkTGVIX1ljBoeKC nj27Ku9Jrf2pcGB7akZhcWRHor1G8Sv0ziNPt2W3r5uh6GmFnNQ3VhpM= X-Received: by 2002:a05:6a00:1492:b0:68a:4312:e0d6 with SMTP id v18-20020a056a00149200b0068a4312e0d6mr16749686pfu.10.1692944326124; Thu, 24 Aug 2023 23:18:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGniWfVtJQHjdNDn4PNQLHuV54v4uGD4AqF7Y+o4DoMquLGCBzSPEVA38syPKdmBazjc2+rYA== X-Received: by 2002:a05:6a00:1492:b0:68a:4312:e0d6 with SMTP id v18-20020a056a00149200b0068a4312e0d6mr16749676pfu.10.1692944325787; Thu, 24 Aug 2023 23:18:45 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id u4-20020aa78484000000b00660d80087a8sm728664pfn.187.2023.08.24.23.18.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:45 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 2/3] kexec, KEYS: make the code in bzImage64_verify_sig generic Date: Fri, 25 Aug 2023 14:18:38 +0800 Message-Id: <20230825061839.52444-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061839.52444-1-chengen.du@canonical.com> References: <20230825061839.52444-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Coiby Xu commit 278311e417be ("kexec, KEYS: Make use of platform keyring for signature verify") adds platform keyring support on x86 kexec but not arm64. The code in bzImage64_verify_sig uses the keys on the .builtin_trusted_keys, .machine, if configured and enabled, .secondary_trusted_keys, also if configured, and .platform keyrings to verify the signed kernel image as PE file. Cc: kexec@lists.infradead.org Cc: keyrings@vger.kernel.org Cc: linux-security-module@vger.kernel.org Reviewed-by: Michal Suchanek Signed-off-by: Coiby Xu Signed-off-by: Mimi Zohar (backported from commit c903dae8941deb55043ee46ded29e84e97cd84bb) [chengen - not to adopt the refined function, kexec_image_verify_sig] Signed-off-by: Chengen Du --- arch/x86/kernel/kexec-bzimage64.c | 20 +------------------- include/linux/kexec.h | 7 +++++++ kernel/kexec_file.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 170d0fd68b1f..f299b48f9c9f 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 @@ -528,28 +527,11 @@ static int bzImage64_cleanup(void *loader_data) return 0; } -#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; -} -#endif - const struct kexec_file_ops kexec_bzImage64_ops = { .probe = bzImage64_probe, .load = bzImage64_load, .cleanup = bzImage64_cleanup, #ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG - .verify_sig = bzImage64_verify_sig, + .verify_sig = kexec_kernel_verify_pe_sig, #endif }; diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 88c289ce3039..6a2e02276801 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -19,6 +19,7 @@ #include #include +#include #ifdef CONFIG_KEXEC_CORE #include @@ -194,6 +195,12 @@ int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, #endif int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf); +#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 + extern int kexec_add_buffer(struct kexec_buf *kbuf); int kexec_locate_mem_hole(struct kexec_buf *kbuf); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 1fb7ff690577..f187ee019b91 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -159,6 +159,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 kimage_validate_signature(struct kimage *image) { From patchwork Fri Aug 25 06:18:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=LrpjLx8F; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RX8sv195Yz1yfF for ; Fri, 25 Aug 2023 16:18:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qZQ9j-0004Vo-Ju; Fri, 25 Aug 2023 06:18:51 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qZQ9h-0004UO-P7 for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:49 +0000 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7DAB43F657 for ; Fri, 25 Aug 2023 06:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944329; bh=Blhm7j1vN0p2mklUlbMbck557sKGQI6k4zXSwtZsUtk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LrpjLx8FE4nnoh8d7R8VQKDzi2ST5jwW9FSIdZY04BvLWWGMa+t1ncrIKEclAYVMk 9akiPac+n7G15Hm/t7w2cpaFmkwNlwdTUyylxflO53K+K2QRTN71s1YFfvRJiL5Wo6 Kf5Wv5wFp8ojkBp6SxTMFcYu6bKBZO94NPiLx1gnlSirnyE5PDnM4VhuS8LedQtxlP UNLp71kEMGc/FpyeWwSsbV+jvzp8F7PrRwC5zx6npSBzAhTUzyAiufLRJ6ORP3bZjH h7m8N09m+bQ/3dheNBI8GQvIKGzW9EEtK5IUK+/5yd3D8h9hYIZbKAAp4qEU0CsHY4 2oNp7InJo1+Ww== Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-68a400a6e38so766691b3a.0 for ; Thu, 24 Aug 2023 23:18:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944328; x=1693549128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Blhm7j1vN0p2mklUlbMbck557sKGQI6k4zXSwtZsUtk=; b=L3/03ydjHAIVBvEUPs+/5moT8WWSZC3crE2l9XVR7Wb4aE0ew1RQLGEnGKpy929+6/ SDiBRNgHqj8wg6IW/xV8GZAYFnGVdxpStt0ycjLW4wBMJU3SmppQK2PVm3Th2zRUMrmV AzNZpjWovzaC/B4FaQUyh2oBNPKqHyZ/ztr7Ig/OSoxh0SgRsvLbwivuFCuDrJ7WeZt6 4vcJvJPg7OmU+zg+ujHgEHS4sJ0FuiTTQx6dNrOzt8F6xNQNuqZZfla0/y+vZQpvbpGN hLYRt5J7PLSuNHxnlfXDATiMOR9KzBUW8ow3VjpeSxIn7Gc5Y9iGdgAXNxPDBiaqyHKK rswA== X-Gm-Message-State: AOJu0YyehEhpzXa245HTneBc8+PauWkBagOQwxYz8SteKuL0MRG2WN7W P51AXJ2ENucCVhOYH/vv3T5Uc647kEogZ2MFQktC8DBRmbIPOtZjvcybTMkl2lfJZnblQ4hhihS P9Bnt7YNg750f0+ykgx4hYiOkueQ7LBPhGZyOhu7j34eALxzpOQs2FdE= X-Received: by 2002:a05:6a00:15d4:b0:68b:e29c:b62 with SMTP id o20-20020a056a0015d400b0068be29c0b62mr6650938pfu.28.1692944327821; Thu, 24 Aug 2023 23:18:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyL1+ZxRbgdDkMXg2gmPmnunfc1VjEkrY+Id3rkPsYag2LyB9Mi8okp3VOZCYeFLVNH8NJNQ== X-Received: by 2002:a05:6a00:15d4:b0:68b:e29c:b62 with SMTP id o20-20020a056a0015d400b0068be29c0b62mr6650929pfu.28.1692944327543; Thu, 24 Aug 2023 23:18:47 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id u4-20020aa78484000000b00660d80087a8sm728664pfn.187.2023.08.24.23.18.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:46 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature Date: Fri, 25 Aug 2023 14:18:39 +0800 Message-Id: <20230825061839.52444-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061839.52444-1-chengen.du@canonical.com> References: <20230825061839.52444-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Coiby Xu Currently, when loading a kernel image via the kexec_file_load() system call, arm64 can only use the .builtin_trusted_keys keyring to verify a signature whereas x86 can use three more keyrings i.e. .secondary_trusted_keys, .machine and .platform keyrings. For example, one resulting problem is kexec'ing a kernel image would be rejected with the error "Lockdown: kexec: kexec of unsigned images is restricted; see man kernel_lockdown.7". This patch set enables arm64 to make use of the same keyrings as x86 to verify the signature kexec'ed kernel image. Fixes: 732b7b93d849 ("arm64: kexec_file: add kernel signature verification support") Cc: stable@vger.kernel.org # 105e10e2cf1c: kexec_file: drop weak attribute from functions 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 Signed-off-by: Mimi Zohar (cherry picked from commit 0d519cadf75184a24313568e7f489a7fc9b1be3b) Signed-off-by: Chengen Du --- 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 };