Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp53612ybh; Mon, 20 Jul 2020 10:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrmuupYqVcg5bgLu9Z2B7YLQW7E2jZ+GVTL13DWI8EqDu2EoLtyVLAxDgScHvHj/d/nQHs X-Received: by 2002:a17:906:2851:: with SMTP id s17mr22326087ejc.347.1595264820666; Mon, 20 Jul 2020 10:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595264820; cv=none; d=google.com; s=arc-20160816; b=Dyyf5yGksrJWZVaAwxk5p7vcBIj5mZPS1RRlR6xluexEp79EmfMmTZT8XKAHPI0C4o axH2bL2b0+fiER66WP76hFdb8iubtgyRGBR5a4DB0vS66cpRmpmVRrVYqWvI9EQ6epQ0 Rf112nynaWqlwH4KHZsMPe3iAQ312Ayt62DdW5E/WekRw/2GZSSnfQ5WsmkrjgLXLNdQ GHjNvKw6PWbilK0Quh7RXGXGpldWrmzWEVpT/zBSp7JeYftupcbGCoiJm4Cq/sPA9Iz8 tYZoxdAx/TLtSuPz53oDG0RbF5X/Me+iX2m535bTjeaqcJTZ0rgeO0cJsNkkHYeF/AVR EnDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=RwL5MGEtfU7GnPe6VEyO1rE3vOTFKWVNFu25ZEv0VAQ=; b=hoKNUASkjJRIfJou8UN7zKemAy16DD3mNcrY2vRAI6SWZkP+SjfIFswtVZbqq1MwTC vm7tg37yrke6YUekG3RX0OBPa9ANLPpfHTDh4AgvaZYNjDaSvaWCsz/4k6f6vTl80s4g 5j57NXRsOyMTQiM2gbDQ/Bxz78sd7mng/ihdwGxroxi7Lcq4GgFSzCJJ5YUUbpnJXYbJ WuBLIO8xoZiPdVwsL7CDhH/JfwMn/j5u5BA5H38AdNUohKvEO2Cqq0Jt4O0tfhK2J6dC BP84ZwGYpVatxz3vOiVHs2jXh+T2YYz3d+PzGa3Mbq5+RA91ofAUtB/F+Z0U3GmznPpD +bGw== ARC-Authentication-Results: i=1; mx.google.com; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si11108185ede.607.2020.07.20.10.06.37; Mon, 20 Jul 2020 10:07: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; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732319AbgGTRDP (ORCPT + 99 others); Mon, 20 Jul 2020 13:03:15 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45940 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726989AbgGTRDO (ORCPT ); Mon, 20 Jul 2020 13:03:14 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06KH1P4J136235; Mon, 20 Jul 2020 13:03:03 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 32d5h4uqu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2020 13:03:03 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06KH1rOx138946; Mon, 20 Jul 2020 13:03:02 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com with ESMTP id 32d5h4uqtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2020 13:03:02 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06KH0o6q009402; Mon, 20 Jul 2020 17:03:01 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma01dal.us.ibm.com with ESMTP id 32brq87gwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jul 2020 17:03:01 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06KH2xEv18874680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2020 17:02:59 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D619C7805E; Mon, 20 Jul 2020 17:02:59 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51ABA78064; Mon, 20 Jul 2020 17:02:58 +0000 (GMT) Received: from swastik.ibm.com (unknown [9.160.78.37]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 20 Jul 2020 17:02:58 +0000 (GMT) Subject: Re: [PATCH v3 07/12] ima: Fail rule parsing when appraise_flag=blacklist is unsupportable To: Tyler Hicks , Mimi Zohar Cc: Dmitry Kasatkin , 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 References: <20200709061911.954326-1-tyhicks@linux.microsoft.com> <20200709061911.954326-8-tyhicks@linux.microsoft.com> <76d2b27b-3b59-1852-046a-b1718c62b167@linux.vnet.ibm.com> <20200717181133.GM3673@sequoia> From: Nayna Message-ID: Date: Mon, 20 Jul 2020 13:02:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200717181133.GM3673@sequoia> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-20_09:2020-07-20,2020-07-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007200111 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/17/20 2:11 PM, Tyler Hicks wrote: > On 2020-07-17 13:40:22, Nayna wrote: >> On 7/9/20 2:19 AM, Tyler Hicks wrote: >>> 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; >> If IMA_APPRAISE_MODSIG is disabled, it will allow the following rule to >> load, which is not as expected. >> >> "appraise func=xxx_CHECK appraise_flag=blacklist appraise_type=imasig" >> >> Missing is the "else" condition to immediately reject the policy rule. > Thanks for the review. You're right. This change is needed: > > diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c > index 9842e2e0bc6d..cf3ddb38dfa8 100644 > --- a/security/integrity/ima/ima_policy.c > +++ b/security/integrity/ima/ima_policy.c > @@ -1385,6 +1385,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) > 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; > Reviewed-by: Nayna Jain Tested-by: Nayna Jain Thanks & Regards,       - Nayna