Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1248377pxa; Thu, 20 Aug 2020 06:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlzGyQeaFBpgGI3GSLDDqUQZDP0MjoLN2TxkghgiXkYOK4fsoJsOR0RDqI4GDo8Z4nte4n X-Received: by 2002:a05:6402:1c88:: with SMTP id cy8mr3086771edb.24.1597931016295; Thu, 20 Aug 2020 06:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931016; cv=none; d=google.com; s=arc-20160816; b=yb7hPRSmOGOw0Seb/q/VZW32y4f3PH05aTqHsUNqjErhzLfKWaGyShlnQUH18dkPjZ Agpie9pel3l4ZjW+tR2w8/rYh/26HXFNd5ZdRcEy0c3sZ1jnfkYASJvwnxXz6/AEB2/T VRyGGo04eueFy8TZasIHN8/ZeUA0aBdDKi+Qmq7LGJUH9grvYHf7LTxUK36yyLH0CiXb PlBiHB9KiAXhPsL77BByhXuLRGQIXTm43KX/MmhtkiuMNrdGXD6bVaId7Jhces43cUtP he7vAzJX02sIL2AVTVGFMgdDsu9lFo67LRhsqkH4hC1d2G0ZRj/Wdd6nooIGkDz5X+sn joaA== 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=eHA+Yap0/Ds0Vj/Q+MMH4GOkkYzcowXIWo6K6ltFBQY=; b=Ig3HtxlE2eZqdR95ufevXv6mIHmgYZ8rX2BewVHqhCGQ0HR5ho4GeKyUu7F5BpYEWa MWvpcq6oVy3XMlNKf5OFGs1DJ0dM4lahE6+Vm4n64uwgaB392rC6vsPn0lBW21/mvDay 8zlrZ/WYtXMpm7wb22lfWeyKgjnrlDAYEdK5LVbneMuBWBF0ciTWkMbm7g7n9bpx+/uY dZoaaBahg7XMH0BZEWKN/J592Ndyb6XOKwPEBR45o3G/rfiGxOcXDqr7eaOoB28kwZQj mfpzC5BbPovg9JOAIhgE7r6b3yM++EyeM7k+uiKfQ9oe3a3G7FpbLtBwTI3rABCKwsC0 YsQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lnc2GzkO; 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 dk2si1372138edb.542.2020.08.20.06.43.10; Thu, 20 Aug 2020 06:43:36 -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=lnc2GzkO; 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 S1730560AbgHTNjq (ORCPT + 99 others); Thu, 20 Aug 2020 09:39:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:41348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728174AbgHTJah (ORCPT ); Thu, 20 Aug 2020 05:30: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 19D96206FA; Thu, 20 Aug 2020 09:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915833; bh=MDDyBPpHCPkjL6gnxEy7Y1yVEhWZUKASThmRxTHfrlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnc2GzkOfn5PUZAyg9fT9nAbjc/QbuSdr71FsXLEhuo4J9N+keMvTjsFefQi6uOde rZVLaMb8al1W4MaLLxlaE2xqcO1KOZYMKPtROHi9jwLtdphbVWYbGtmrjD5HrDtdeX QesFdtK3U44eda3wB6e06099bVEGpDmH5ixWzmwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyler Hicks , Nayna Jain , Mimi Zohar , Sasha Levin Subject: [PATCH 5.8 149/232] ima: Fail rule parsing when appraise_flag=blacklist is unsupportable Date: Thu, 20 Aug 2020 11:20:00 +0200 Message-Id: <20200820091620.030559584@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@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 5f3e92657bbfb63ad3109433d843c89996114b03 ] Verifying that a file hash is not blacklisted is currently only supported for files with appended signatures (modsig). In the future, this might change. For now, 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 Reivewed-by: Nayna Jain Tested-by: Nayna Jain Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_policy.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 3e3e568c81309..a59bf2f5b2d4f 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,9 +1376,17 @@ 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; + else + result = -EINVAL; break; case Opt_permit_directio: entry->flags |= IMA_PERMIT_DIRECTIO; -- 2.25.1