Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6599225ybx; Mon, 11 Nov 2019 11:35:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxBK2b1bMB62I0XIG/qs7eqesvgagVtUlMcGM9QHFfTOo/1zt9Cio/Q2fBkGtxQMx5OnKFv X-Received: by 2002:a50:984b:: with SMTP id h11mr28827729edb.248.1573500932854; Mon, 11 Nov 2019 11:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573500932; cv=none; d=google.com; s=arc-20160816; b=o2G0vld84Lt0lp8OlF8WBY1dMWDrVzWAudicFpGu61L2FvIQmFItQRl/M3fWtU8fZ2 /rNWQJa+Oi3gaivm20/MDU6wsS7GWYdDfo9qrsDvQLtee1ThJgUptLO2w7ux7FcOiN/g YK7Z9xbtD/i5GTPPbwXBOPB4OcAxrb0iYwcoGxUlVc3jdHYHL4P6KZNMHgstOv4CmvtO b6ca9EOnLthwK8VHEvHAqmfzIoPanYfxWveM66aw81fZ5fqzEtp8/7a87uAtdlr5X0aG Rfyb/6TnBCKRIa1JFE1UWeMdMZD4QZBdKEGxweg1jwF9+JO+0tdght3a9a0CtCf1UATA TqVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dkim-filter; bh=fGp7aGtfx5j4b2g0DCuVmlZ/hhAjByENcIbOKEQH7bo=; b=cx69IcIJLm9h22fKEBx5LvKfuWlmSCrf5kyDYj9Thpvpb23uMqgmCOaNJyntAIEajh KoUA11WPnRH+u2FdEQsGvjzCGSlrBSHXqJq+65E6yAWdKXJRSFTJeMlVFrwyD/1Gairb h3Hooj5oFo1gHpzn2gzIqDQgX9uxIOWaAKrdLuKafwXIxmRpq+0IJ4tTnHzq+x0Yqkw6 rsH43SDG3DSFIFHJwM+5SmBSQyvhqycDgUYYwJkTk4qiWs0JJDAkEFQxXMWJTVhWOro4 9UV7hfIkfRbic/cVAuapXhOarQLvLk2oubPYsDx1HOTFaGPC4uylcbijQdkm/3Zt5bTC NY6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=LMos4A8A; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si13065470eda.167.2019.11.11.11.35.08; Mon, 11 Nov 2019 11:35:32 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=LMos4A8A; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727507AbfKKTdK (ORCPT + 99 others); Mon, 11 Nov 2019 14:33:10 -0500 Received: from linux.microsoft.com ([13.77.154.182]:44802 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbfKKTdJ (ORCPT ); Mon, 11 Nov 2019 14:33:09 -0500 Received: from nramas-ThinkStation-P520.corp.microsoft.com (unknown [131.107.174.108]) by linux.microsoft.com (Postfix) with ESMTPSA id DC3CF2010C18; Mon, 11 Nov 2019 11:33:08 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DC3CF2010C18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1573500788; bh=fGp7aGtfx5j4b2g0DCuVmlZ/hhAjByENcIbOKEQH7bo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LMos4A8A+Tb+CnZj3jALtpTqB8SXPXDlhNB46x4eVrQMpbGZEW3aZ+0gz+mtBmPUU KDfmkq6/Uub1XOqXtp+4J5DcCj9ttrXH/spLmR40YuSLEWKv4lubloOo730Wd84X9Z f5grS9eVIe35NV5nDh63jTmFaL1gDazk0pMRRb/I= From: Lakshmi Ramasubramanian To: zohar@linux.ibm.com, dhowells@redhat.com, matthewgarrett@google.com, sashal@kernel.org, jamorris@linux.microsoft.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/10] IMA: Added KEYRING_CHECK func in IMA policy to measure keys Date: Mon, 11 Nov 2019 11:32:54 -0800 Message-Id: <20191111193303.12781-2-nramas@linux.microsoft.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111193303.12781-1-nramas@linux.microsoft.com> References: <20191111193303.12781-1-nramas@linux.microsoft.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IMA policy needs to support a func to enable measurement of asymmetric keys. This patch defines a new IMA policy func namely KEYRING_CHECK to measure asymmetric keys. Signed-off-by: Lakshmi Ramasubramanian --- Documentation/ABI/testing/ima_policy | 6 ++++++ security/integrity/ima/ima.h | 1 + security/integrity/ima/ima_policy.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy index 29aaedf33246..341df49b5ad1 100644 --- a/Documentation/ABI/testing/ima_policy +++ b/Documentation/ABI/testing/ima_policy @@ -30,6 +30,7 @@ Description: [FIRMWARE_CHECK] [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK] [KEXEC_CMDLINE] + [KEYRING_CHECK] mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND] [[^]MAY_EXEC] fsmagic:= hex value @@ -113,3 +114,8 @@ Description: Example of appraise rule allowing modsig appended signatures: appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig + + Example of measure rule using KEYRING_CHECK to measure + all keys: + + measure func=KEYRING_CHECK diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index df4ca482fb53..7f23405b2718 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -193,6 +193,7 @@ static inline unsigned long ima_hash_key(u8 *digest) hook(KEXEC_INITRAMFS_CHECK) \ hook(POLICY_CHECK) \ hook(KEXEC_CMDLINE) \ + hook(KEYRING_CHECK) \ hook(MAX_CHECK) #define __ima_hook_enumify(ENUM) ENUM, diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index f19a895ad7cd..9ca32ffaaa9d 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -373,7 +373,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode, { int i; - if (func == KEXEC_CMDLINE) { + if ((func == KEXEC_CMDLINE) || (func == KEYRING_CHECK)) { if ((rule->flags & IMA_FUNC) && (rule->func == func)) return true; return false; @@ -997,6 +997,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) entry->func = POLICY_CHECK; else if (strcmp(args[0].from, "KEXEC_CMDLINE") == 0) entry->func = KEXEC_CMDLINE; + else if (strcmp(args[0].from, "KEYRING_CHECK") == 0) + entry->func = KEYRING_CHECK; else result = -EINVAL; if (!result) -- 2.17.1