Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4625277imu; Tue, 15 Jan 2019 03:20:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4sIlm/RlQhRR5snaNoC7MHOoxpJdIcABqKZLR4faMMmQ9+iw+tFzJVsWaQasMt/Cg1Thgl X-Received: by 2002:a63:88c7:: with SMTP id l190mr3397836pgd.110.1547551202066; Tue, 15 Jan 2019 03:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547551202; cv=none; d=google.com; s=arc-20160816; b=Y9mLZN/q2dyzLaatYxcQYCf8SXAMC+5daLy0pGPm/7olLi0kASkYRBYfPtmF0B4Ueo PALrTLzRGU9YV6jC+xixkIewVdrdNvlQhnRAtgFwINqJTamhsg3t5U4oWp6Qbi7pBXuM sHqAVZ8yD57lWqiiSQBc958xA67yNo5ccOKaNjWFFKpBW2NnJsS/rwl3fYfsLqbDI8v0 h/BcWdzShOsV3bM1NDtfMUN33gfgTu4+rdLcFzQHVfxh1pndtPsAlLoRX39kzyn1GsY0 z9Vs1fQJ2C2ooVyS2ulqTfWlGmQZhPaPqa1/OLPaAx1UO8BQYdPc5Bw9xYqQnHL5Jjab RdOA== 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=a8PUaRvVS2Cc08x6Ah+cstRAFHGE4gi7iM8U4eOowDxkmhOrbPvTSlrleMaYrDn9qO rfQjgRgpFe+ILx1EiHoi9XADTqHxhGf1aAQKEVut3HuzaopiX/62zBzM8dK8PABkp26I r1Fmav7jMkEA3KNQm5YBtu9PoOHFC7uF/78GzQj4GEwI5O1auPdavDUGjfESB1UJcpAK uctJikFawScUzMACQKuQuovnRoAhriWL4tGyq+uS6pSpZGv9kl18EPe6ZPhxyTbtEyin JBqw4BOXHC7vDzh4qM+Ohi76h9b0CW77Ikbvhs/C/OYcgXy+eNZ/nK/c5seeLtzdvIVt n2AA== 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 w185si2071796pgb.588.2019.01.15.03.19.45; Tue, 15 Jan 2019 03:20:02 -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 S1728780AbfAOJqx (ORCPT + 99 others); Tue, 15 Jan 2019 04:46:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41290 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfAOJqw (ORCPT ); Tue, 15 Jan 2019 04:46:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 478703DE03; Tue, 15 Jan 2019 09:46:52 +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 0736719940; Tue, 15 Jan 2019 09:46:42 +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: [RFC PATCH v2 1/2] integrity, KEYS: add a reference to platform keyring Date: Tue, 15 Jan 2019 17:45:41 +0800 Message-Id: <20190115094542.17129-2-kasong@redhat.com> In-Reply-To: <20190115094542.17129-1-kasong@redhat.com> References: <20190115094542.17129-1-kasong@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 15 Jan 2019 09:46:52 +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