Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1660040pxb; Wed, 2 Feb 2022 09:37:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXfa7C2Ag0Wqqov5vQDBr5wOWoQkdkcSjJKTqH7uqMvCxekNy6yQ8cnp3Aiv41/HFIarnu X-Received: by 2002:a17:902:f68e:: with SMTP id l14mr31636875plg.164.1643823478141; Wed, 02 Feb 2022 09:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643823478; cv=none; d=google.com; s=arc-20160816; b=rlAoPJIIusYHsUpTFL84C+KcisfBjFB+NTGPFQtzcbgGT2ZreMPOQ1zYsBHf/pUANR M7dMPdgWM59e5TuZVWeyL5vO7bFSJg6ux7icZICc/jcazNxLlzlJ11ZdC/WD+pMcjG5j tKvmU6wrIrhlmpJdEIXdKhlP+84LE1ak7BSmHKJSUS+JDTman2TM3KZrMN/jJqp82ZAR DI5T/FHdDHRvnTY/DiuFXwzQzrDHF1wtkQ8bYNnKr14roTWhrHI8hQD3tcVC92AzHcPI SwlqVwY1zvbKkCzkvlZkHhM1TXoJHTU03B2txxg7HfeOoNpP5IgIjhwjtJKVOUbyH7/u uavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z61o7XFNtLtEoY0IRwR7hf+c1pRZ1yg1bG/PraBIWHc=; b=aNDRazEcsWP81UlrD6jM49Io+pJXuyFf7JIYHAlECZj4V7WWG9Q82Ieur4J51wuOTi lw2rhH+pUFqwLwYvehB2QU9X04pPnzuZlHf9yG69XkEjT4msd4KqfVb9YZcuC3e1vs37 u3E+YmnQBuuf8N2B0emZGK8J41et2Q5+IqoRJvMz3szL9Z+3KDuapz5YIhbSSKQXmxVs YnbMdGd+21UQ2OZv7jMk23b0m25pkkowsgloZEseJ/uStlLxRvB0aEQt+I02OkCpl+3U pgS54QlwExcq62yoLbUFeTWUMQWdWl8eD4Yf7/hx/kEUGjQvC0uxM6LTsvBDRH0Wkrbo /RwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=W3hf6tz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g70si1854709pgc.721.2022.02.02.09.37.45; Wed, 02 Feb 2022 09:37:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=W3hf6tz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242921AbiBAUkI (ORCPT + 99 others); Tue, 1 Feb 2022 15:40:08 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30018 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240598AbiBAUiS (ORCPT ); Tue, 1 Feb 2022 15:38:18 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 211Js69b031070; Tue, 1 Feb 2022 20:37:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Z61o7XFNtLtEoY0IRwR7hf+c1pRZ1yg1bG/PraBIWHc=; b=W3hf6tz3UQY8BjnY/rm0RslrZvTs5LTGewmv2Uj1Y5MBtWBL9EMXUNem817w5Coirq/S Uzbs2qHRg1HvGk261zHG+D27k4j+HeGmbj9fwk5Rh/rLhAJCv/jwtQ8pLdh/lYtw8G9J zI5cd8Zkit+Syu25iBSPjv1+QkwRKJ3CoMfS4lgk7AiUe8usZ0N5xL/Q/tBn4xsEJ0mj hL5Jlge/+SvHJRvKKFPbc81VrD2O98G8wLcR7MTkpuz2jSi5L8K1vtgQaGZQLB1jHsWR 3+jkhFwmpweK3MhfY4pCBbh0DH6aD3whAcDmvKV3yN2HdcbSkc3WRBzUJC5FEGuP1bQU KQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dybe58pvy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:52 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 211KLph7024770; Tue, 1 Feb 2022 20:37:51 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dybe58pvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:51 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 211KWMRd028009; Tue, 1 Feb 2022 20:37:50 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 3dy0swgmm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Feb 2022 20:37:50 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 211KbnAS14746100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Feb 2022 20:37:49 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56886B205F; Tue, 1 Feb 2022 20:37:49 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A789B206B; Tue, 1 Feb 2022 20:37:49 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 1 Feb 2022 20:37:49 +0000 (GMT) From: Stefan Berger To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, serge@hallyn.com, christian.brauner@ubuntu.com, containers@lists.linux.dev, dmitry.kasatkin@gmail.com, ebiederm@xmission.com, krzysztof.struczynski@huawei.com, roberto.sassu@huawei.com, mpeters@redhat.com, lhinds@redhat.com, lsturman@redhat.com, puiterwi@redhat.com, jejb@linux.ibm.com, jamjoom@us.ibm.com, linux-kernel@vger.kernel.org, paul@paul-moore.com, rgb@redhat.com, linux-security-module@vger.kernel.org, jmorris@namei.org, Stefan Berger Subject: [PATCH v10 02/27] ima: Do not print policy rule with inactive LSM labels Date: Tue, 1 Feb 2022 15:37:10 -0500 Message-Id: <20220201203735.164593-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220201203735.164593-1-stefanb@linux.ibm.com> References: <20220201203735.164593-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WrZdQUFmuUGFFjnwdNXFBN21dRdeGRZo X-Proofpoint-ORIG-GUID: WIxt4MwYIU1MqaZQa24XpHhQskfp8ZFp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-01_09,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202010114 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before printing a policy rule scan for inactive LSM labels in the policy rule. Inactive LSM labels are identified by args_p != NULL and rule == NULL. Fixes: b16942455193 ("ima: use the lsm policy update notifier") Signed-off-by: Stefan Berger --- security/integrity/ima/ima_policy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 320ca80aacab..2a1f6418b10a 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1967,6 +1967,14 @@ int ima_policy_show(struct seq_file *m, void *v) rcu_read_lock(); + /* Do not print rules with inactive LSM labels */ + for (i = 0; i < MAX_LSM_RULES; i++) { + if (entry->lsm[i].args_p && !entry->lsm[i].rule) { + rcu_read_unlock(); + return 0; + } + } + if (entry->action & MEASURE) seq_puts(m, pt(Opt_measure)); if (entry->action & DONT_MEASURE) -- 2.31.1