From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DF26C433F5 for ; Mon, 14 Feb 2022 09:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245580AbiBNJto (ORCPT ); Mon, 14 Feb 2022 04:49:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343994AbiBNJqf (ORCPT ); Mon, 14 Feb 2022 04:46:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 365C86AA6D; Mon, 14 Feb 2022 01:40:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A2C9611DF; Mon, 14 Feb 2022 09:40:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76699C340EF; Mon, 14 Feb 2022 09:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831604; bh=n1qsIm72eVmDCyK2h8ZoQhDWe6tCmwaW4bloGcFk00g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TyHoLvy9V7BLZkEnTEn3OKb32zXUWyGBlrJMWfP7LUWMX5hyzBS6TMr/4MAMq8nao cUSaH0SCXOS28yzz2/GLvgIGbLt+5FSJaEVOQnaMKXYkpI0+Vlz1YcInBasAaLjOSt duPmVkesE1TpbmevbwIoN0Z57vjVDx0E5zJcRjBc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Berger , Christian Brauner , Mimi Zohar Subject: [PATCH 5.10 004/116] ima: Do not print policy rule with inactive LSM labels Date: Mon, 14 Feb 2022 10:25:03 +0100 Message-Id: <20220214092458.828412636@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Berger commit 89677197ae709eb1ab3646952c44f6a171c9e74c upstream. 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: 483ec26eed42 ("ima: ima/lsm policy rule loading logic bug fixes") Signed-off-by: Stefan Berger Cc: # v5.6+ Acked-by: Christian Brauner [zohar@linux.ibm.com: Updated "Fixes" tag] Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/ima/ima_policy.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1636,6 +1636,14 @@ int ima_policy_show(struct seq_file *m, 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)