Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1004381imu; Wed, 16 Jan 2019 11:03:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qe2cjKuNJT0h2Du2V65lLgnb+06XylxkW6knQ4cqdcQa/GywjdUTTt3sCFWrZXdXNYYNy X-Received: by 2002:a62:7f93:: with SMTP id a141mr11345693pfd.96.1547665393418; Wed, 16 Jan 2019 11:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547665393; cv=none; d=google.com; s=arc-20160816; b=Ddk9kDRscXZeXpjBa8s/YpEibuE923usvCVyhV6fwKWcm6/BRjhVmRfumdD8ysBb1A 3Q+Ufcq/C341Lo3YicOre3g8whNBIcc2fUbEnWCTFHnLRbHWemwB3T884/rT7wWNnX7V N+42toNMzZOmK/MPN53FnjBk4XZtIuDpG7n2LSqcgqmgGCyOKSZUuym6Ary8/l/hp8Uf YZziBrdHWeup5ZRvUdeWO+KTLkfPVjB13hsVc8GeD1JQeqi7+h/3tNpm7Fkurg8nYPBQ Nf9lsOPQu0vE+hCTghD/cuKeWK3IDVHSC6q6hprTr+mzfqlQD0ul93viogmvfnTsBs0W bPaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4Qw02e+EkVmhXthuRFtUeg8bGP6Wmxylsbrl28xzeBo=; b=C9nZbP9s3cG94aQzOKCKwqJcLPnfkqjW/QEgkd0vjyYpTG0VHxLyudMxN5E7D7NxRW kyudOunH8U2ZI6komg7RyNsaxWLgr1CgMLIrEXTgKCSYvHUiRbqUIaTw5yWcvqx3cpca xi+ADy6CAl8TWU0WhrKr7pFkxezXX3P4RH7l/T7QUxOX7MbXR38a+a9WaJE9TrFsiBlb xmmabb6WD4Na9lKW58Yx/OasMrbZQpTDuJYbHrD+/lKUpaIerFb3V2Gr1F1emmTOwG1b NUVtFCSP9bBxQ4ATWJ02lAFxGovVpjgeHhkckoNvsxV+o2/79RWr+3rMNORii1eAgGRn HbFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89si7354665pfr.242.2019.01.16.11.02.57; Wed, 16 Jan 2019 11:03:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389576AbfAPKRi (ORCPT + 99 others); Wed, 16 Jan 2019 05:17:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26050 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389537AbfAPKRh (ORCPT ); Wed, 16 Jan 2019 05:17:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1F00811AC; Wed, 16 Jan 2019 10:17:36 +0000 (UTC) Received: from kasong-desktop-nay-redhat-com.nay.redhat.com (unknown [10.66.128.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7864610C7; Wed, 16 Jan 2019 10:17:31 +0000 (UTC) From: Kairui Song To: linux-kernel@vger.kernel.org Cc: dhowells@redhat.com, dwmw2@infradead.org, jwboyer@fedoraproject.org, keyrings@vger.kernel.org, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, bauerman@linux.ibm.com, ebiggers@google.com, nayna@linux.ibm.com, dyoung@redhat.com, linux-integrity@vger.kernel.org, kexec@lists.infradead.org, Kairui Song Subject: [PATCH v3 1/2] integrity, KEYS: add a reference to platform keyring Date: Wed, 16 Jan 2019 18:16:53 +0800 Message-Id: <20190116101654.7288-2-kasong@redhat.com> In-Reply-To: <20190116101654.7288-1-kasong@redhat.com> References: <20190116101654.7288-1-kasong@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 16 Jan 2019 10:17:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently when loading new kernel via kexec_file_load syscall, it is able to verify the signed PE bzimage against .builtin_trusted_keys or .secondary_trusted_keys. But the image could be signed with third part keys which will be provided by platform or firmware as EFI variable (eg. stored in MokListRT EFI variable), and the keys won't be available in keyrings mentioned above. After commit 9dc92c45177a ('integrity: Define a trusted platform keyring') a .platform keyring is introduced to store the keys provided by platform or firmware, this keyring is intended to be used for verifying kernel images being loaded by kexec_file_load syscall. And with a few following up commits, keys provided by firmware is being loaded into this keyring, and IMA-appraisal is able to use the keyring to verify kernel images. IMA is the currently the only user of that keyring. This patch exposes the .platform, and makes it useable for other components. For example, kexec_file_load could use this .platform keyring to verify the kernel image's image. Suggested-by: Mimi Zohar Signed-off-by: Kairui Song --- certs/system_keyring.c | 9 +++++++++ include/keys/system_keyring.h | 5 +++++ security/integrity/digsig.c | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 81728717523d..4690ef9cda8a 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -24,6 +24,9 @@ static struct key *builtin_trusted_keys; #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys; #endif +#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING +static struct key *platform_trusted_keys; +#endif extern __initconst const u8 system_certificate_list[]; extern __initconst const unsigned long system_certificate_list_size; @@ -265,4 +268,10 @@ int verify_pkcs7_signature(const void *data, size_t len, } EXPORT_SYMBOL_GPL(verify_pkcs7_signature); +#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING +void __init set_platform_trusted_keys(struct key *keyring) { + platform_trusted_keys = keyring; +} +#endif + #endif /* CONFIG_SYSTEM_DATA_VERIFICATION */ diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h index 359c2f936004..9e1b7849b6aa 100644 --- a/include/keys/system_keyring.h +++ b/include/keys/system_keyring.h @@ -61,5 +61,10 @@ static inline struct key *get_ima_blacklist_keyring(void) } #endif /* CONFIG_IMA_BLACKLIST_KEYRING */ +#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING + +extern void __init set_platform_trusted_keys(struct key* keyring); + +#endif /* CONFIG_INTEGRITY_PLATFORM_KEYRING */ #endif /* _KEYS_SYSTEM_KEYRING_H */ diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index f45d6edecf99..bfabc2a8111d 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c @@ -89,6 +89,12 @@ static int __integrity_init_keyring(const unsigned int id, key_perm_t perm, keyring[id] = NULL; } +#ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING + if (id == INTEGRITY_KEYRING_PLATFORM) { + set_platform_trusted_keys(keyring[id]); + } +#endif + return err; } -- 2.20.1