Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp690812pxa; Tue, 11 Aug 2020 12:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7fp788QDGIAn7aPMDabixn0nxsjONAgVC9ZdRI3TgrJp1GIrXktPpJXaNokD2CgUowrt2 X-Received: by 2002:a17:906:c108:: with SMTP id do8mr28718626ejc.88.1597174207403; Tue, 11 Aug 2020 12:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597174207; cv=none; d=google.com; s=arc-20160816; b=vOcy/KYjnRIE6AZ5EvWmuataeNB3oQElZcilCb/8ArjqCkzxOT6juvfnPI8HhHy5fO rpnTBUND2FmFrp7TkEA+a0Ypxsm99qC10WyfgnpIvR8SUM91oH7F48R44p6n6TyN4VT1 k9EYYhtw09MwV7Y996lIhSsIUml8eT6hq6lWzmdKH/jnr4Qu9vG5JxaBkobf4JWzI+42 pzoCCev/6aHXpmnO+5deDQct9wwAeQSv4au9J9I/FLhnLHleb328zKwhoBxv87GFRU8/ 1N52pSMzLFoDSln6753ci10xDPgLgWzl2mtQPRrCEGiXnZRebWZ6IdKPfr0rxe6pEs9B bktw== 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=jJ2rgICpl7Ac8oj5RgbaV+jcSTEuj2wOFf50Lb2rAUs=; b=TyWDdNKVNOlz1oAkBJAh7mgdJbiTO6WaYFZVoGZ1bL/KqH/8dWq5cjobTpWJHzHTGw 2/PfT3ah91lNw71Bx/IgmY+QKQPwEI1OYGd6G9zQ/7JI8un5MM052n0DgNDbfDYZL4Pi uDeMHGNsmxpxmb4oBqHBonWUFTfqVNfyH25uQj0BA0qUi+9AFewdHs/gl1P/wvrH3j/U XDD2RGSWpvqS5B+Xzd7K+6MpQam6IY2aZfRV+ZTu6BsMVtXQeqOacWDg/iTdp8SMrwT4 iY1XbYFM6wL2yQ8wE54IeKOXI4wEJuwXKz0LzaQuGAHw0KJ6gCFFgR6HzpaLlDdo1jMx 3yNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=l51wiNdG; 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 ce22si7596375edb.148.2020.08.11.12.29.43; Tue, 11 Aug 2020 12:30:07 -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=l51wiNdG; 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 S1726554AbgHKT0t (ORCPT + 99 others); Tue, 11 Aug 2020 15:26:49 -0400 Received: from linux.microsoft.com ([13.77.154.182]:44148 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgHKT0s (ORCPT ); Tue, 11 Aug 2020 15:26:48 -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 277AD20B4908; Tue, 11 Aug 2020 12:26:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 277AD20B4908 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1597174007; bh=jJ2rgICpl7Ac8oj5RgbaV+jcSTEuj2wOFf50Lb2rAUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l51wiNdGi8pI/2ncryg66PgtYZzWL2/t5aAvy/pkofTt061C9sCIth86D0pAWX2mU dWd5TtUkYfs2QSCz6naMLnNfPILoREyX9UptZPz+XzwqO9SorxiW9V8vbO3FpnRk3D hgA5sqkOogvZEy1gfNUNzK7kAkv1PLBiUuIEvR00= 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 v2 2/2] ima: Fail rule parsing when asymmetric key measurement isn't supportable Date: Tue, 11 Aug 2020 14:26:21 -0500 Message-Id: <20200811192621.281675-3-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811192621.281675-1-tyhicks@linux.microsoft.com> References: <20200811192621.281675-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 Reviewed-by: Lakshmi Ramasubramanian --- 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 ea224f00b305..fe1df373c113 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