Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp334480ybg; Tue, 28 Jul 2020 07:15:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiG80s++adaT/dvuhUnYS8jcIWdbl5JCnUkIxDDSZ0wN22enIeaJmTw37VIfj3er1Jf8Yy X-Received: by 2002:a05:6402:3113:: with SMTP id dc19mr26075291edb.20.1595945739530; Tue, 28 Jul 2020 07:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595945739; cv=none; d=google.com; s=arc-20160816; b=yCLTWmKy1ohD0r8wgoB/alCcJG77YCAfHhPmmDt0CBqpcIM475fVV/HFOv9rUrRryQ H4aIayJCbiQGWnSalIZXdCprm9cpghhbQgZJmy3gX+ERvG9gQfB4IvMZFiw+pciO/K12 9UnmVr1qw5wLTqT0GxDN+z4ej0J5eKHpgEFpg5VQGo/3FJIQCD69mSQmA2GIYCzf2pRb EWAjNlViyRggGFbf0uaB6LhPqCQ4RyVSyDUu1vs0veSwO1wEBcrRh3WMbot0dcheUOSz wCHeCfokiD9TluFXU93/gpSn9vEWZNUv2PbliJVH5kBfDFXNxsPxSjhuT0+dMSbnY+Gt bQMw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=TdiXmpRni8ubU9ZDCDtSAAikTrjb8aB1OWY4V4JuSWY=; b=w9u1GS6XgwnNhyzZO7pTtGgwUA0s5dFYNbfOoz07ABCXVHbefiTEPdBr8T0CXXABW0 sLlP4Viqggn45+KqjLy+hOo3ptd9vFt6b7Qvx3tcFJoos4i/b5P7nnnFb11WmGDv0UV1 mJO0khrSe5lyp5scfVsCRFPrg/qrVp1jzVuXGIG3ltj5Yg2EtZl/RZYV/5ovCbqw9AsF PCgfct5qEOl8bbmKO1yNh8N+LGEy9PVk5B5NLnrago7Qd3ZdGGBPcbnZLG+cXBxRHwA5 gdEuxYeOlekG5dPIos3fPkO2ZcwJefY7K2/cz32AAT8spgPh9oenoOxxvJ2vpnWxKiWf wC1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Evf1Ur3A; 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 mc26si2492935ejb.333.2020.07.28.07.15.17; Tue, 28 Jul 2020 07:15:39 -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=Evf1Ur3A; 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 S1730319AbgG1OOS (ORCPT + 99 others); Tue, 28 Jul 2020 10:14:18 -0400 Received: from linux.microsoft.com ([13.77.154.182]:47082 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730065AbgG1OOS (ORCPT ); Tue, 28 Jul 2020 10:14:18 -0400 Received: from [192.168.0.104] (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 50F4120B4908; Tue, 28 Jul 2020 07:14:17 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 50F4120B4908 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1595945657; bh=TdiXmpRni8ubU9ZDCDtSAAikTrjb8aB1OWY4V4JuSWY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Evf1Ur3ATOtpFVAItqhYZ14GV7dEE7G0F8scuvuWY+5YXZid01YBRNk2ADH4dmMxu MzpX0tGWkm375WpScdzy6AkFVS+xpwbJwwNwYVykTP3DSzpCzRVc3V587YZxWplxwU El9Q8CuUBJizQUwxUGDf2TmNl07aAb69+70sBYck= Subject: Re: [PATCH 2/2] ima: Fail rule parsing when asymmetric key measurement isn't supportable To: Tyler Hicks , Mimi Zohar , Dmitry Kasatkin Cc: James Morris , "Serge E . Hallyn" , Tushar Sugandhi , Nayna Jain , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org References: <20200727140831.64251-1-tyhicks@linux.microsoft.com> <20200727140831.64251-3-tyhicks@linux.microsoft.com> From: Lakshmi Ramasubramanian Message-ID: Date: Tue, 28 Jul 2020 07:14:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200727140831.64251-3-tyhicks@linux.microsoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/27/20 7:08 AM, Tyler Hicks wrote: > 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; > } > Reviewed-by: Lakshmi Ramasubramanian