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 452FAC43217 for ; Mon, 14 Feb 2022 10:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344698AbiBNKAz (ORCPT ); Mon, 14 Feb 2022 05:00:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345589AbiBNJ47 (ORCPT ); Mon, 14 Feb 2022 04:56:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B05A83036; Mon, 14 Feb 2022 01:45:41 -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 E8A4D61237; Mon, 14 Feb 2022 09:45:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0853C340E9; Mon, 14 Feb 2022 09:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831940; bh=c6PIy4SprYdVh444PBOUULKcNofHrxD6+9VvMSku1TU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0yMobZ+ie1sMnjaXbYNqkhJz//cSyajfhFvfV2Xdxo/qW0qnkxeWx3npptiGzNA7 JVv5TcIJB4VbOql8x+M0JhZg09dS8VS+H8xh7BPQR4WkcHrCrSS7Oe6UX4oga444gW jHcJMMpSs8HYKoPrC+u/vzX5PCC0l/nbxtTniPFk= 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.15 005/172] ima: Do not print policy rule with inactive LSM labels Date: Mon, 14 Feb 2022 10:24:23 +0100 Message-Id: <20220214092506.545330621@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092506.354292783@linuxfoundation.org> References: <20220214092506.354292783@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 @@ -1852,6 +1852,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)