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 };