From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5376C433FE for ; Thu, 12 May 2022 07:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350621AbiELHBw (ORCPT ); Thu, 12 May 2022 03:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350652AbiELHBo (ORCPT ); Thu, 12 May 2022 03:01:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E82D4990D for ; Thu, 12 May 2022 00:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652338898; 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=h0Alj0t096FzvHDlGiZ3qyd8ZJw6mVhfYxd8+w8Uk2sKO3GWAHC0DK1CInnIfSn98sXyZ3 G+/2m7v6gHj6RasFK9+Vsx1wBlsglXR6Xws+ZbXffc4op5BEB8DkFtFGWBvhZgauXay7KA 8QB9Qyz8zcNUQKVVXLJyS5fnEnMqOBQ= 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-482-3NUJCFz_MtmuoxRf2Dat6g-1; Thu, 12 May 2022 03:01:37 -0400 X-MC-Unique: 3NUJCFz_MtmuoxRf2Dat6g-1 Received: by mail-pg1-f200.google.com with SMTP id y17-20020a637d11000000b003ab06870074so2191561pgc.15 for ; Thu, 12 May 2022 00:01:36 -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=6CaSCYdJ2sPJUeRUA5Z90/rT2q/IaZ/azZsXC5QaZGv8L3IRPN34zjCuVjCx6/MUuo ZMDycmRnoj2/33ZhSWbQxOaDonxedGA0E58GJluR3lxKW/9mskHsO3GN57SLxkjSiDgN fhwtTt/dLoLtfMLjh1TRzGs2hkZT4OXmBrnl9RO8o2c81myQc3gGVT5Y4n8j35pOZ5ts JdyDQBBOym60wLScx7BQyPZ3Sx5a8rtatiB8GnSauZB5H6kgz4m44TtcRjkRZorFKl+v Fl1yFsdmLiZEgnNfshuf7aMF4aW/fn3/9kpvJQtt+wBjLJAjNdAaN42QeH2flWxFikWu wVyw== X-Gm-Message-State: AOAM5312bCS5b/pBmx3eIQXV2b6gVJ7eoTbl2vqYPkEZO7EFtYuTarj1 6dw6B3Af6A2n7oprBwqbdxcTlmfw3S9XJ7TLVnzDuK9lHSaryGUu0EcEV8oeA9k5d9SpWgAfig2 sx2/zEaR19yWJWK79lmw= X-Received: by 2002:a17:90b:50b:b0:1dc:a0b1:c783 with SMTP id r11-20020a17090b050b00b001dca0b1c783mr9496044pjz.49.1652338895888; Thu, 12 May 2022 00:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL7dbJyojSNiYp6yhVPBLmJfJDRySqPe4tUcXYdPqOzrvmcXE2jXe5MahLEz2xxAmrohNavg== 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 Precedence: bulk List-ID: X-Mailing-List: keyrings@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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2A30C433EF for ; Thu, 12 May 2022 07:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wpOpj1pbdLj1QBxcqOEqdr9yjUKRDb/IaafkiZ0VURg=; b=xQThol5QJDe8PE ImChS661xFeMRQABZ8eBBwpcSTG8tDpSAUyWLUZUhmHe2UtCMEnbw50sqGjXgr9SDKa5AapBME8kx 5OQ0GQnXjI9t8R3a0Hv+s9OPdZx74QJ446ndF6B2XerehQyJlTElDNyM044mYZe73rT9cUT6zejA4 FUvAvQ19fNAxt2QIWSLtwIAc81JHXLO/8Kz26Owxb0eL7wGu0Ah2MApUoHkCRrGE7UCyr0yFGV32J 3rFvY4K8YWvqIrDZPM/HKTmSLZCkQ5/2Q4pKLxk6FbrNZyntakEw1NJaAPZeygptZgcTBrItPZPG/ fRQSAqLDNtgYc6u42Gew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1np2q1-00AcQ0-9K; Thu, 12 May 2022 07:02:18 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1np2pQ-00AcCD-SA for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 07:01:42 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mevjy/DGPy4eqIk5EbdLPFrJaGfCXH1nWhTn6iIdPnc=; b=O2rx0WXyvhXEblqk5hUkuT4qEv0Jofa4iWZuG8f6M2H1uz/x1sjzeB8dGJIWc/cspFmWhA lqgrrOK4caL76aGLYsszDNbLIYzsT+Jsgyzx9d9BHge7a7+/0ztc/uM+n+f+OYuU9Ibz0G LjRITJ4Gid/QgZEr6BiyM5nCU001fBE= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-1WKNDDaGOSmb8JxFFAwI2Q-1; Thu, 12 May 2022 03:01:37 -0400 X-MC-Unique: 1WKNDDaGOSmb8JxFFAwI2Q-1 Received: by mail-pf1-f199.google.com with SMTP id c15-20020aa7880f000000b0051078df6964so2226092pfo.4 for ; Thu, 12 May 2022 00:01:36 -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=HkE4Y9Rz6bqb1cmfGyxwvkG7F8qJtBEi8VCAdvluuAHfQHyOKbO1NG390I3jNwRYsZ pETHYCfmAr1HD8ibScL1bgU6HCsdk62pxYcRIoXArubHSeI/Veyu+OjSzMywu/rxpYmn 1P0AueBlrAGTWOw4YUqFLPkuN/9y0cN1g/djBhZVe3zMVQquOUfyk1/xgA+zmuegj6G2 5sp+sPwAluv6VUK87BV4xpZWCaj4UJf166HRj+OL4rfvOag7a+QeGftV3b6AF0btx1bh 7g3gZHieS1YxIytPlfAp2x1xYoqLHVREPDGNgd7GLQZnDHBgLeYgmjw86r92RQ3mO3cG jDEg== X-Gm-Message-State: AOAM533i3M5NDVjuLmXxTfHgzyptTRZq3qvloGDNpoAMB7+TP0mwf3fh Zyx6/VvnalGy6VDoIBuMjuFoCIN2LvPnbUhpHbjOlPqfjI8gHyu1LfdEOYpA5VHh9gPH/DqeYlu 0EZF6N0liJYBm94E9EToXpui8lpXFdIwyJxc= X-Received: by 2002:a17:90b:50b:b0:1dc:a0b1:c783 with SMTP id r11-20020a17090b050b00b001dca0b1c783mr9496048pjz.49.1652338895889; Thu, 12 May 2022 00:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL7dbJyojSNiYp6yhVPBLmJfJDRySqPe4tUcXYdPqOzrvmcXE2jXe5MahLEz2xxAmrohNavg== 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=coxu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220512_000141_019619_B5FD320A X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Coiby Xu Date: Thu, 12 May 2022 15:01:22 +0800 Subject: [PATCH v8 3/4] arm64: kexec_file: use more system keyrings to verify kernel image signature In-Reply-To: <20220512070123.29486-1-coxu@redhat.com> References: <20220512070123.29486-1-coxu@redhat.com> Message-ID: <20220512070123.29486-4-coxu@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kexec@lists.infradead.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 at vger.kernel.org # 34d5960af253: kexec: clean up arch_kexec_kernel_verify_sig Cc: stable at vger.kernel.org # 83b7bb2d49ae: kexec, KEYS: make the code in bzImage64_verify_sig generic Acked-by: Baoquan He Cc: kexec at lists.infradead.org Cc: keyrings at vger.kernel.org Cc: linux-security-module at 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