Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1153538ybt; Wed, 8 Jul 2020 23:21:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDX++2tTE6FbHP5E+p1xnAGKY1ZmPTFedscfB7e84LrO751+mt4rNfgT4s7DnhRfSE1yzk X-Received: by 2002:a50:ed15:: with SMTP id j21mr45331651eds.246.1594275660677; Wed, 08 Jul 2020 23:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594275660; cv=none; d=google.com; s=arc-20160816; b=tAQnbN/yrD8OIfUnaOKwH855X7wmu/w6LD93nPPY1PXhPLed3TnkS1tDTyhdxbpejG Mpq/97kft5TkmfSn2y+srrSeKbyMA6u5OFgMzCQbLT3Xfcaaqrdk1V+rnMvIXTBassTF he86GaQX7WGy2G3d6dpijICaHk0YEQfkcV69eruV1xcvcgFYTKG/cCo3eogzSVaK0grU ymdKgyT4CV+snDhPAwywSuS2HA8zvcRnS74hnfIL1ou9IUuO9fq0vo5NjIIUnqgA6VAX tAOoMWn812E1hhIRYrtKMO/cccGyVrqtzh3ckHHhHp3Scbp477zHvFbyEW6E2AM6KSJc IOPw== 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=swamC2p17c6UKzr2WevLUTCfz2mHFf5f2mrMDFbXG8M=; b=PEHxmamk/JwuusKfPaDWBylX7aUGSQv328xfqbKZWKOkgJXQRNsDzSMOG1Htt906nS CW3mQwHsebXcZTTyFIO9FYTBXq7TvXOUBCQ/LuqS6u3O/R2kPUSbOS+Tlvos2UV4UP11 fe3gYFPt/Vz1bRJ+Nn05Qsbin/WhN5U5C1eeZwCdSiZyk+YXIk8i2aHBayWKCrJdBVoK OYeN4ktSOYAtOUwIyccOM6Gur21rtKKgoWjLcMUHv8kQeRYWv+OANhRcVDM4gtlYCggV Yaa9fhyHdC5gqXKZ0FwTF6Shfu0rVf2AMu4q0CkBWBsa176psDYb2jrEv2B5KLfzy9cI IF7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=rRADIsmh; 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 z3si1304951ejc.547.2020.07.08.23.20.37; Wed, 08 Jul 2020 23:21:00 -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=rRADIsmh; 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 S1726630AbgGIGUO (ORCPT + 99 others); Thu, 9 Jul 2020 02:20:14 -0400 Received: from linux.microsoft.com ([13.77.154.182]:38084 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgGIGUK (ORCPT ); Thu, 9 Jul 2020 02:20:10 -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 5EFC920B4908; Wed, 8 Jul 2020 23:20:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5EFC920B4908 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1594275610; bh=swamC2p17c6UKzr2WevLUTCfz2mHFf5f2mrMDFbXG8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRADIsmhSYlLAiAJQcVPCqnYL6wmzgpKYtO/Dz5lZF93n2jW9H5eYRZN5lngLAYUH VUKbzAf1KQ7TTYCPIFqUtM/dCJT/3wf1FN3/h4R8i0M2wcUTIwm0gCYjbmiupKmW+l JyRbR4xc18NzQUyh4ecdxDFUsXfJj1tG5xQotZHQ= From: Tyler Hicks To: Mimi Zohar , Dmitry Kasatkin Cc: James Morris , "Serge E . Hallyn" , Lakshmi Ramasubramanian , Prakhar Srivastava , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Nayna Jain Subject: [PATCH v3 07/12] ima: Fail rule parsing when appraise_flag=blacklist is unsupportable Date: Thu, 9 Jul 2020 01:19:06 -0500 Message-Id: <20200709061911.954326-8-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709061911.954326-1-tyhicks@linux.microsoft.com> References: <20200709061911.954326-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 The "appraise_flag" option is only appropriate for appraise actions and its "blacklist" value is only appropriate when CONFIG_IMA_APPRAISE_MODSIG is enabled and "appraise_flag=blacklist" is only appropriate when "appraise_type=imasig|modsig" is also present. Make this clear at policy load so that IMA policy authors don't assume that other uses of "appraise_flag=blacklist" are supported. Fixes: 273df864cf74 ("ima: Check against blacklisted hashes for files with modsig") Signed-off-by: Tyler Hicks Cc: Nayna Jain --- * v3 - New patch security/integrity/ima/ima_policy.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 81da02071d41..9842e2e0bc6d 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1035,6 +1035,11 @@ static bool ima_validate_rule(struct ima_rule_entry *entry) return false; } + /* Ensure that combinations of flags are compatible with each other */ + if (entry->flags & IMA_CHECK_BLACKLIST && + !(entry->flags & IMA_MODSIG_ALLOWED)) + return false; + return true; } @@ -1371,8 +1376,14 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) result = -EINVAL; break; case Opt_appraise_flag: + if (entry->action != APPRAISE) { + result = -EINVAL; + break; + } + ima_log_string(ab, "appraise_flag", args[0].from); - if (strstr(args[0].from, "blacklist")) + if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) && + strstr(args[0].from, "blacklist")) entry->flags |= IMA_CHECK_BLACKLIST; break; case Opt_permit_directio: -- 2.25.1