Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4889835pjb; Mon, 27 Jul 2020 07:41:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoe7KyLDRwgnzXzl1AHaUyxDnTt6GZN2DzfLQ3fjvUeeO3znYmINXtW6TsqVY7ctjdfmsW X-Received: by 2002:a17:907:7202:: with SMTP id dr2mr14234358ejc.36.1595860891605; Mon, 27 Jul 2020 07:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860891; cv=none; d=google.com; s=arc-20160816; b=TU7/SZjGJ6QK4yQZlsxfCL0yle8cPDFhjU6/gw0kbEzMfLXuuDdLVcPHYLEGoJC5Um FK9tD7lDQUVPRg1PvKZfpbEe+7spgvhavtKsRfxir/Cg64mr+v3FioWOcWYGuXkAnGjD iuHJOb+sxbg9lxxm8ZNKz/w4Vjida50XzsCbBL01RwEQ5YEDSRQPv/58BMviYrsS2Cvp UiQk7fQhGwzKd8VKgSwC1JBh1tXGUv2gBoTFH6HUJsmXwX1xPnqXAlbLU6fZDQg891dh rwQctlGGLY0QAqZBbXIAh3PZ/YwPYQfGLgYtlf2PoPe1thkAjoDvAvgTC1FH0DVc3Xwv SBIA== 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 :dkim-signature:dkim-filter; bh=TojaKA1D2bkgSvEtbI6kYJOINajUXiJCFMf+z5sO/JQ=; b=JvLDPH55fXFhgT+vbMrUtszIr348u1JRsveKCd26Y98ecocKKiKMYxQXf7C14r81Ah k4oPPimqB0YbgcElaYq8N8ez1dYYGpG72za0Qt3i0BI0Mh+TxOQFt5GLxF7Z3uY/ZM02 1Ia7je9d0oPDvTeNvckkoYq30Y4v/AE2ZDuj986N7HBbxFXzZVuQrgJepv3Pk9hVv0pl B7+vmtvT8ltCEoU8b6+PHMAf5jKymj1L41CmvFhzwrcxfD8qcRJUpmU6fJiUc2VZHhDs 9fVLDcxXN0IL1iHHlTpaCBOtgotYEyuxCUXugtOMsb1m4C5Ll1MbqICpyN5ADn29fOCO 3EMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=lz5Tn0sm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id s5si4846917edc.388.2020.07.27.07.41.05; Mon, 27 Jul 2020 07:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=lz5Tn0sm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1733021AbgG0OkE (ORCPT + 99 others); Mon, 27 Jul 2020 10:40:04 -0400 Received: from linux.microsoft.com ([13.77.154.182]:53218 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728947AbgG0OJU (ORCPT ); Mon, 27 Jul 2020 10:09:20 -0400 Received: from sequoia.work.tihix.com (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 1D0C420B490C; Mon, 27 Jul 2020 07:09:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1D0C420B490C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1595858959; bh=TojaKA1D2bkgSvEtbI6kYJOINajUXiJCFMf+z5sO/JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lz5Tn0sm1IzQZ1ivUGl55HsNtgLm9JrFalLP6KB8PaOGy/cMdp//VBy2HXc3Kvj8e 513MuEEb5DlQ32PSGav+mjEkH0LFKHp7NdtnSxjQ9/s+EIlXcGDy8kLQc9eJiAMn/t Hyu2V1PUciKf3kn07uOQVVZsHW09V9z4pxJ8H+uo= From: Tyler Hicks To: Mimi Zohar , Dmitry Kasatkin Cc: James Morris , "Serge E . Hallyn" , Lakshmi Ramasubramanian , Tushar Sugandhi , Nayna Jain , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 2/2] ima: Fail rule parsing when asymmetric key measurement isn't supportable Date: Mon, 27 Jul 2020 09:08:31 -0500 Message-Id: <20200727140831.64251-3-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200727140831.64251-1-tyhicks@linux.microsoft.com> References: <20200727140831.64251-1-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Measuring keys is currently only supported for asymmetric keys. In the future, this might change. For now, the "func=KEY_CHECK" and "keyrings=" options are only appropriate when CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS is enabled. Make this clear at policy load so that IMA policy authors don't assume that these policy language constructs are supported. Fixes: 2b60c0ecedf8 ("IMA: Read keyrings= option from the IMA policy") Fixes: 5808611cccb2 ("IMA: Add KEY_CHECK func to measure keys") Suggested-by: Nayna Jain Signed-off-by: Tyler Hicks --- security/integrity/ima/ima_policy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index c328cfa0fc49..05f012fd3dca 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1233,7 +1233,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, "KEY_CHECK") == 0) + else if (IS_ENABLED(CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS) && + strcmp(args[0].from, "KEY_CHECK") == 0) entry->func = KEY_CHECK; else result = -EINVAL; @@ -1290,7 +1291,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) case Opt_keyrings: ima_log_string(ab, "keyrings", args[0].from); - if (entry->keyrings) { + if (!IS_ENABLED(CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS) || + entry->keyrings) { result = -EINVAL; break; } -- 2.25.1