From patchwork Fri Aug 25 06:17:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825789 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=HhnpayIx; 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 4RX8sJ3lhmz1yhF for ; Fri, 25 Aug 2023 16:18:26 +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 1qZQ9C-0004DB-EE; Fri, 25 Aug 2023 06:18:18 +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 1qZQ8x-0004Au-D8 for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:03 +0000 Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.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 3A7943F21F for ; Fri, 25 Aug 2023 06:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944283; bh=6Y6DW6tjWxFBE3SIocym4gt9wPSOsc1Gap+Rv5x+pNc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HhnpayIxQKvae0PddkMIoZZGQbTOAVUawpwh7LAtMcRJIs+XJDQyfwYXJG4kZZ7ng aXVfp3IRZS0Ew1w6ZGW1y/5zQ/FgSlbfNQaMF39PBf2O+3s6eV3yUb6gv/zz1Cv4bI 3Ln/6HgPkcC+EsT3ZUT7ZWqkSvLIfkimMYKPhoAxnDeEdEPM2rHFdfqJkTuUPC2gmp xm81f6iDL0dqluBn5hKPKsyAjFrHNNu3Cxjo5y9L0SVEBXySL6w7FHenthZldPpP4r 5cQaDNzcFnTd4iQZbjQq/7TRdNZ+tMSEw+1VPY7Q6OzV2NsXkKqdnL3QonPSF/XBr2 df0AI/xoWmYfw== Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3a81038bc0dso653810b6e.3 for ; Thu, 24 Aug 2023 23:18:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944281; x=1693549081; 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=6Y6DW6tjWxFBE3SIocym4gt9wPSOsc1Gap+Rv5x+pNc=; b=lYfiIpWOTfG8V13WhHlcEtHgR5pQK9C/Od8HwpzO55j3r/su3Kipt8xMT6v1O8Ca+H VGJD06w3yyTSghWMVsDLJ92R5Esrz61NA2ri2RPCB8ZSvHYiojKKFZRc2C92W8i0qnta 76p6KRQweCQp6sB0EW1fmIVxOrwKJQ8aRgIA1aPvJizg7mhS+mhKKVZqEnZ/6+1Hu8QP bwfTZIxER6XL4okUftoNBOIwsqNUwwbJXGBmtqR/7k0Pu4Y83iLmbU687Y2FcS56trIL AGMtOyX/NqTjvLKO6NvjEMXR7pTnfqoqoWoC872S1WQ0Xmvd50TBKPUZJFZMhMf9marq bBPg== X-Gm-Message-State: AOJu0YxDX3tlKOg59ufxyVkgOT9J3hyUxafqzIkJyxDxKYWx1w5euOpK +TnCX5WKlLIoT0R8in/NqHzB28oq6IX8Cdk58fOI7X93PhkWwMi3pzhi7/4fgRgSC+dnKfwvPVL v2/fs4Ciw22uwYNCXCG4qYMC6EF3g1GLF8HObcTSlHHeitrJ7taSngQk= X-Received: by 2002:a05:6808:10c1:b0:3a7:30cb:c092 with SMTP id s1-20020a05680810c100b003a730cbc092mr2551828ois.48.1692944281619; Thu, 24 Aug 2023 23:18:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2CFyZ/0NRaV6X3NqAsQz5/nGWDLsQLYlatvK0MwmFMQK40P85jhFzd3X2trl3G8YsZTevpg== X-Received: by 2002:a05:6808:10c1:b0:3a7:30cb:c092 with SMTP id s1-20020a05680810c100b003a730cbc092mr2551817ois.48.1692944281389; Thu, 24 Aug 2023 23:18:01 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id f4-20020aa782c4000000b0068a0922b1f0sm728969pfn.137.2023.08.24.23.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:01 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 1/3] UBUNTU: [Config]: Enable CONFIG_KEXEC_IMAGE_VERIFY_SIG Date: Fri, 25 Aug 2023 14:17:53 +0800 Message-Id: <20230825061755.52217-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061755.52217-1-chengen.du@canonical.com> References: <20230825061755.52217-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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/debian.master/config/annotations b/debian.master/config/annotations index e5731b2e3a9e..31caf0427389 100644 --- a/debian.master/config/annotations +++ b/debian.master/config/annotations @@ -12450,7 +12450,7 @@ CONFIG_ARM_MODULE_PLTS policy<{'armhf': 'n'}> CONFIG_UACCESS_WITH_MEMCPY policy<{'armhf': 'n'}> # Menu: Processor type and features >> Architecture: arm64 -CONFIG_KEXEC_IMAGE_VERIFY_SIG policy<{'arm64': 'n'}> +CONFIG_KEXEC_IMAGE_VERIFY_SIG policy<{'arm64': 'y'}> CONFIG_UNMAP_KERNEL_AT_EL0 policy<{'arm64': 'y'}> CONFIG_HARDEN_EL2_VECTORS policy<{'arm64': 'y'}> CONFIG_ARM64_SSBD policy<{'arm64': 'y'}> @@ -12462,8 +12462,6 @@ CONFIG_ARM64_MODULE_PLTS policy<{'arm64': 'y'}> CONFIG_ARM64_PSEUDO_NMI policy<{'arm64': 'y'}> CONFIG_ARM64_DEBUG_PRIORITY_MASKING policy<{'arm64': 'n'}> CONFIG_RANDOMIZE_MODULE_REGION_FULL policy<{'arm64': 'y'}> -# -CONFIG_KEXEC_IMAGE_VERIFY_SIG flag # Menu: Processor type and features >> Architecture: powerpc CONFIG_PPC_TRANSACTIONAL_MEM policy<{'ppc64el': 'y'}> From patchwork Fri Aug 25 06:17:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825788 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=s7iaraHD; 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 4RX8sJ3wvWz1yhS for ; Fri, 25 Aug 2023 16:18:26 +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 1qZQ92-0004BS-Vj; Fri, 25 Aug 2023 06:18:08 +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 1qZQ8z-0004B5-5N for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:05 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 CA6443F657 for ; Fri, 25 Aug 2023 06:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944284; bh=4t95vam0HPY4OBGRwRMYppsinb7wDUI0CZnz6m4TqsY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s7iaraHDJONX0G8jU0KAR9+13QSLaQmsa8YvQd682tIPSjAn9mbZsoz35doAck9je 8xn5kMNFNjZD2h8wfhPnQ3IZy9FVhunUNMDucRFAorMa+GtOOsvXtXnNowKsRfLxu1 HwFmWM2Sugs5TiQUiVNZWgdnQD4sMajh8tE7Y6gtQpHK2cPz9tQSMzeslXT+iG8tw5 4V9i88bP4I54VxPvYrcdd2F7CToMWT9ztEf7YPa82lrmhhd21NdecivmNuchgm0w82 n3+iLvdpPda3SSDb8Pq4IT3iVlL37gbecVvmeP8MAsv8PmZFZmnkWxtUnmCk4gKeub gyP7wndZm81qA== Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-56f924de34fso409956a12.2 for ; Thu, 24 Aug 2023 23:18:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944283; x=1693549083; 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=4t95vam0HPY4OBGRwRMYppsinb7wDUI0CZnz6m4TqsY=; b=JE7WI6U7QDSXB43T/V2Sicss0xNYHPAhTqzgDi8ngioYJyiD0W3uRjJYPnIagJkTHu MLjEdItJr43GaOpBjZ3rer9NA+xeyPVMMnKY3sfoUvriZmJztAaVPRl8gbUvbC49aDha CXSKqXwT0XhZ9EQBOeQtwvT2arSP/ZrOMd14IcPZyajasAZmL8ZZ6ikYVFFW1T9s3bBb TdaZSmqNt6gEd0fRO4UOCK5wNdFwi8HKTmKFxSITqu+so5bI+UXtSUVFx2P3zLA4d/VN NDKc7bCAhIDJ3+C0/1uH1qYPsAqizTc+O+kmrj4zaF3btlQfU/50se/L/xkgQDokOziH ARpQ== X-Gm-Message-State: AOJu0YxwgsUm09hMX9HHscnlky59bLuLWCjPTX5gnlDRPnXLYFJE4zLd tiF4CxrQxPQytuCzYXFfH+tGWTNhBOni++8qVwWL8GvOc1MqYTDOqYmibcExNXdqQP7e12v6U8j 5dBifgdAav1eVowfVAn/SWRS1CDpj2fnhQ+LulMQ0W6uCTS9DqLJox30= X-Received: by 2002:a05:6a21:1f03:b0:134:2e3c:9845 with SMTP id ry3-20020a056a211f0300b001342e3c9845mr13391446pzb.22.1692944282959; Thu, 24 Aug 2023 23:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IED6cG2NWu5tjyM3ZleSmF+3UcUHfpNVApAyQETbn++mE3eLerRUs+eidDYEil7APqUnE6TQg== X-Received: by 2002:a05:6a21:1f03:b0:134:2e3c:9845 with SMTP id ry3-20020a056a211f0300b001342e3c9845mr13391436pzb.22.1692944282578; Thu, 24 Aug 2023 23:18:02 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id f4-20020aa782c4000000b0068a0922b1f0sm728969pfn.137.2023.08.24.23.18.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:02 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 2/3] kexec, KEYS: make the code in bzImage64_verify_sig generic Date: Fri, 25 Aug 2023 14:17:54 +0800 Message-Id: <20230825061755.52217-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061755.52217-1-chengen.du@canonical.com> References: <20230825061755.52217-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 - fix header context and adopt same changes / 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 b8b3b84308ed..1b3f8759b52a 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 @@ -538,28 +537,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 64f23bab6255..28b39cfc2fd8 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -19,6 +19,7 @@ #include #include +#include #ifdef CONFIG_KEXEC_CORE #include @@ -187,6 +188,12 @@ int __weak arch_kexec_kernel_image_probe(struct kimage *image, void *buf, unsigned long buf_len); void * __weak arch_kexec_kernel_image_load(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 + 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 5b58149bcd90..fdf62a61b6ab 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -149,6 +149,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:17:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1825790 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=DL/5hABQ; 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 4RX8sJ3gdxz1yg8 for ; Fri, 25 Aug 2023 16:18:26 +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 1qZQ97-0004CM-5u; Fri, 25 Aug 2023 06:18:13 +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 1qZQ90-0004BC-1h for kernel-team@lists.ubuntu.com; Fri, 25 Aug 2023 06:18:06 +0000 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (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 DE5523F21F for ; Fri, 25 Aug 2023 06:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692944285; bh=FwzQ89OeTEEURSfGAWWGjBoKgZwoTM7dj9qFPi5TnYg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DL/5hABQ+5m75CzQN0J7sybdn5st6+csicBsjx6iPNLAMfHsHZ6MMxf2YC9GbDqLk cRnxlbuNEPwC5SlJqXpKDcqf3IKywnrxH5ai7h2a5jfYfd6xLTYzZrE9q5nF7GsUGd EGvPY6YHZgk558CTzWubBeRQnNcLnW+kecR7TNIbQdXmwT3CEk5UbJZnCQPmqR6+UV /HDy+eEh4EbvKmHsm768W1iViDwobQU4SCBFqL38whpCho32IuOtepyqGiFSR43OWv SvF+T6ci4I7ZnPpE6Yq9QZwFHM3a0UCnhfEJDc0bob3Oe7SBAeg8C6oxS0EdIWUXA9 +cRl1w1zLjoKA== Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-1bf00c27c39so735869fac.2 for ; Thu, 24 Aug 2023 23:18:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692944284; x=1693549084; 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=FwzQ89OeTEEURSfGAWWGjBoKgZwoTM7dj9qFPi5TnYg=; b=TjYKtprBkPm5JxMLxNIogKEz5t3RY2LTUVp+6e4Fd6AAPp8WPWG+2qhXsh4z+OK8zp lNUWkI2/yKAR/J32+7lRU0oFshyJHrflVnXreX95g69sFxxUwLB8DuDYDJBVSNvWdoSk 9n5dhnCP8+iphgax/7hoAfw17HOBwcxKOp5HLOCEdykz/A6aUNnPICPKuHosiVJ1I3nS RsKMBn0n2tbyFgQxoH8JdMB6bxxqFSlpf0AIi60/KeNYc4l8SW6S+CfH4P8cGc3qT0Uw F01TVMYMnJZAsgaOq68ol+OqlJ8mHNJHdTxoVrD7jEz3R742OtA419mUeLzleLII17ze A4Fw== X-Gm-Message-State: AOJu0YywxL2j2S9uH9+fTBp4ve45UHAqStD6yueBuADg5ScyQtWr0s18 AtcGohMXPwB1+TJlIXEoKkG4oION4igjbk7Sh60ax++rZ4FetFCTEvTrmyipouSflfkFE7f6m1+ 40yHOu5ta7Q1nTE0JQ9Y8hVctZo9q3NUVZroxYdcabG0sA8dtOTBev+4= X-Received: by 2002:a05:6870:a706:b0:17f:7388:4c69 with SMTP id g6-20020a056870a70600b0017f73884c69mr2425731oam.30.1692944284403; Thu, 24 Aug 2023 23:18:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiC6ePCnQbuRduwaPzmhm5in2rryVWV5nM0nduCCShtpbSU3XUmx8tNqbEgHtCRYKAJzKl7w== X-Received: by 2002:a05:6870:a706:b0:17f:7388:4c69 with SMTP id g6-20020a056870a70600b0017f73884c69mr2425724oam.30.1692944284031; Thu, 24 Aug 2023 23:18:04 -0700 (PDT) Received: from chengendu.. (111-248-109-24.dynamic-ip.hinet.net. [111.248.109.24]) by smtp.gmail.com with ESMTPSA id f4-20020aa782c4000000b0068a0922b1f0sm728969pfn.137.2023.08.24.23.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 23:18:03 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 3/3] arm64: kexec_file: use more system keyrings to verify kernel image signature Date: Fri, 25 Aug 2023 14:17:55 +0800 Message-Id: <20230825061755.52217-4-chengen.du@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825061755.52217-1-chengen.du@canonical.com> References: <20230825061755.52217-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 (backported from commit 0d519cadf75184a24313568e7f489a7fc9b1be3b) [chengen - fix context and adopt same changes] 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 29a9428486a5..8a72d16aa5e3 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 @@ -113,18 +112,10 @@ static void *image_load(struct kimage *image, return ERR_PTR(ret); } -#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 };