From patchwork Fri Jun 19 14:33:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 224008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 249C5C433E2 for ; Fri, 19 Jun 2020 15:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9C74206FA for ; Fri, 19 Jun 2020 15:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592581179; bh=xwksin7kz1AKu1fmQXMrhEaDDAygzDT86oLp9iMnLtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UvhxJL6pL+NymDbMGiEdClY1h6kimVf+Kp9uAGWNNSAs0djc10iNe3UkCVMzMS0Dj LqpqlaRlApuTvvebzYX3qqk4nuuIozpwy7zH80TITmx6GUvgmV2F5Vy+35gFrF3kAX 298bM4uQdzPmf9M5ak2b/M4WVdT4fAIAwT2wC++o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391519AbgFSPji (ORCPT ); Fri, 19 Jun 2020 11:39:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393674AbgFSP3G (ORCPT ); Fri, 19 Jun 2020 11:29:06 -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 47D8521941; Fri, 19 Jun 2020 15:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580544; bh=xwksin7kz1AKu1fmQXMrhEaDDAygzDT86oLp9iMnLtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TrwAiAqf4IpIH/LVcvO3KLJO4HNpnNr6pmgz6WcxNLt3Nk8jt4AameNz4MZYeM7oO FKV6geR/UI7coEQdpIshbRxLYlNIexWikp47PCClynfNAmYJBRDm6GgpwXgo5kmVro 5zXWAiPv9PCwt1qg4GnRG7TOT1mFC7rEKjm2Joyc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roberto Sassu , Krzysztof Struczynski , Mimi Zohar , Sasha Levin Subject: [PATCH 5.7 291/376] ima: Set again build_ima_appraise variable Date: Fri, 19 Jun 2020 16:33:29 +0200 Message-Id: <20200619141724.115890770@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Krzysztof Struczynski [ Upstream commit b59fda449cf07f2db3be3a67142e6c000f5e8d79 ] After adding the new add_rule() function in commit c52657d93b05 ("ima: refactor ima_init_policy()"), all appraisal flags are added to the temp_ima_appraise variable. Revert to the previous behavior instead of removing build_ima_appraise, to benefit from the protection offered by __ro_after_init. The mentioned commit introduced a bug, as it makes all the flags modifiable, while build_ima_appraise flags can be protected with __ro_after_init. Cc: stable@vger.kernel.org # 5.0.x Fixes: c52657d93b05 ("ima: refactor ima_init_policy()") Co-developed-by: Roberto Sassu Signed-off-by: Roberto Sassu Signed-off-by: Krzysztof Struczynski Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_policy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 7414443c19bf..e493063a3c34 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -643,8 +643,14 @@ static void add_rules(struct ima_rule_entry *entries, int count, list_add_tail(&entry->list, &ima_policy_rules); } - if (entries[i].action == APPRAISE) - temp_ima_appraise |= ima_appraise_flag(entries[i].func); + if (entries[i].action == APPRAISE) { + if (entries != build_appraise_rules) + temp_ima_appraise |= + ima_appraise_flag(entries[i].func); + else + build_ima_appraise |= + ima_appraise_flag(entries[i].func); + } } }