Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2631713pxa; Mon, 17 Aug 2020 14:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy3V9tehUhBXqiBI7IIz9oqJ/TWGS7VHVQ9VP7cgzu9D2e30vcYJ9dQC45yZ6ZRDIpKd+E X-Received: by 2002:a17:907:11d0:: with SMTP id va16mr17800453ejb.426.1597701515961; Mon, 17 Aug 2020 14:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701515; cv=none; d=google.com; s=arc-20160816; b=lyhuEVIX4q5Thtdoz92RqtCSx6kKnFqglQBElLr3U0+LWko1Hc7m9pDHssZ/qbz3Y2 rTnc9uusq1dMb9trz/gAd9j2RRJBaGawlp4/YIVKVzGnQNVigUc8Ub5qwNM8UtkwN7YY Rtybczvi68ik+h792Pu5tfddo338uRhhnVC7Rg4+D7Tt3Q/X1/1QZqq2wqvfJ/SHChiG wYzjTXKmcjFfX0gxe8oWHqvvknO19iQZBAtb0GU1WqX5XwtV4gRMuMiz+bxvwprhiFLV arODrkzP6GDQmfskCcHouybMEzxeRFEKajZj5Kyzi59aQEBZ7EFMPtIdiQFwGdrUaUtI J71w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a37g+8it3drbH/1k1QpSqq8Q37uezjcaJFu9KFNQOnw=; b=i6I8Wzop5TUYHymXIn60AcfPb/D/dgg6xEyS0WyU0JekEknop1ZsqKfeSozzG9Agq2 o0MQz0vldgTNDIjdsl8ZPjrMVyPLcuhsTk+dJqaLTgmHE9jtBtoXQsN8uIvjhhVcWTFk gDkG4cUKbSUlfsK1enO7q4ddCr0VtGjOs7zCdSQHWTm19GAGYglaalkznfUWmdlqeDOC X/sG/nhvuH/e22Ov5kT0rBOnbgFQsxAy+oAfizTC2tX+mV1YiN0ZLHJUSzzbJuHCDGEN 2lF3ZubUjfLaxZG7P/MWk8KdMoJjE36UVQ0XTr5QuWbeEuRgc+ApO9RTA/ekxX1cBvPR eR+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o3I6CmBD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si1465163edj.391.2020.08.17.14.58.12; Mon, 17 Aug 2020 14:58:35 -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=@kernel.org header.s=default header.b=o3I6CmBD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730304AbgHQPdI (ORCPT + 99 others); Mon, 17 Aug 2020 11:33:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:48720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729778AbgHQP3h (ORCPT ); Mon, 17 Aug 2020 11:29:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8548D23C32; Mon, 17 Aug 2020 15:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678177; bh=byHwtIwlZgL0WdEMuf+rCeZTZK2eJE6pssQD0B2LeE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o3I6CmBDJ3l4L4NjNHEEWxCOvCBldf9PcktTOmNzoR7RxE7vKTtsTcR8xawnXgsnN VpBSf9zrdkhPo1Zfvg6sbacezUKTbskDMGj8KannDjWWE8eW8RBn0zkJGdEy7gGFU5 E2fuxJ8CrqykRD74n3XWb5dIIbvq3CODuvQ0kjjk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyler Hicks , Lakshmi Ramasubramanian , Mimi Zohar , Sasha Levin Subject: [PATCH 5.8 244/464] ima: Fail rule parsing when the KEY_CHECK hook is combined with an invalid cond Date: Mon, 17 Aug 2020 17:13:17 +0200 Message-Id: <20200817143845.485575843@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tyler Hicks [ Upstream commit eb624fe214a2e156ddafd9868377cf91499f789d ] The KEY_CHECK function only supports the uid, pcr, and keyrings conditionals. Make this clear at policy load so that IMA policy authors don't assume that other conditionals are supported. Fixes: 5808611cccb2 ("IMA: Add KEY_CHECK func to measure keys") Signed-off-by: Tyler Hicks Reviewed-by: Lakshmi Ramasubramanian Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_policy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index a77e0b34e72f7..3e3e568c81309 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1023,6 +1023,13 @@ static bool ima_validate_rule(struct ima_rule_entry *entry) if (entry->action & ~(MEASURE | DONT_MEASURE)) return false; + if (entry->flags & ~(IMA_FUNC | IMA_UID | IMA_PCR | + IMA_KEYRINGS)) + return false; + + if (ima_rule_contains_lsm_cond(entry)) + return false; + break; default: return false; -- 2.25.1