Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2732977ybz; Mon, 27 Apr 2020 03:34:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLPJBKEwkBf48CJVBs2M7dtPsoZ32TRCzNej2OK+OihM/0NMCQWMFPSndfRX1ylwOVHZB7w X-Received: by 2002:a05:6402:6c4:: with SMTP id n4mr17285468edy.368.1587983652133; Mon, 27 Apr 2020 03:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587983652; cv=none; d=google.com; s=arc-20160816; b=VLiBoja6TpsPrDY6JgbFtte7fAvHB60GZXnbyEhtVT9wbju1STN2BJUmi2m746lX+U 92t/dPbsC6Ds9eswcaxaCTj9wduD8ZrItNexF7bSex93VAkQjN9i57FtkqWc1EJwLA0M xfd2u+vy2tHfYQMhq6cVHU9eJn+ibIkXjwhbeytUisImsYasgA2ZjB8HBM+zGFErEmJe bHxG6NybgEj45hkDA0oTqhnfImxwpOERo39DBafG7CpH/tgcMRqfz+R1LRRLlPofwanM xoRC83CQYYGPzFHumOfHkzerhW1GpSLHZMTGOKqWzHBsPLxFJ/bmVQwQ/H3m1lC/XQ5Z poOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=WGcCil9treLP1yNO+qgbRApKt/ssdbPbMOJfQAeYN+g=; b=WXrAUd0FSNiNmpuqUK6m3IgPkoKx9tcVq7Dhu5+P7KOwDnlaBJHKj45z/OOftUAfjr rqLTugXa+FEIeWCoXeC7qFHeXeR+d5/wsz1RsDzAMqBA0IByGn5AVeUoOrYV33oba4Ef D+zShhiIoDEhapnbVnBhwr75kgcHXoxlgHhx8jX9KGSFf3kUSU01PDpJOcrdR7yAa0sL 3v5c9sJL7fbmhscRJ6uQ1AvIBZXb2UDIi1ebokVqw/NionjsyRbzwv7j5X9BpHvJdPxI /3TE4Lf73BKZwHuH/eZIotJvK7RxWhnggjNgPH9LB7Jyla3IWHlppo1b871NIQ4S2TzC p86g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw21si8237354ejb.158.2020.04.27.03.33.48; Mon, 27 Apr 2020 03:34:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgD0Kb4 (ORCPT + 99 others); Mon, 27 Apr 2020 06:31:56 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2109 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727058AbgD0Kbo (ORCPT ); Mon, 27 Apr 2020 06:31:44 -0400 Received: from lhreml726-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 06CEB882E7E7C5ABDB47; Mon, 27 Apr 2020 11:31:43 +0100 (IST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by lhreml726-chm.china.huawei.com (10.201.108.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Mon, 27 Apr 2020 11:31:42 +0100 Received: from roberto-HP-EliteDesk-800-G2-DM-65W.huawei.com (10.204.65.160) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Mon, 27 Apr 2020 12:31:41 +0200 From: Roberto Sassu To: , CC: , , , , , , Roberto Sassu Subject: [PATCH v2 5/6] ima: Set again build_ima_appraise variable Date: Mon, 27 Apr 2020 12:28:59 +0200 Message-ID: <20200427102900.18887-5-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200427102900.18887-1-roberto.sassu@huawei.com> References: <20200427102900.18887-1-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.204.65.160] X-ClientProxiedBy: lhreml710-chm.china.huawei.com (10.201.108.61) To fraeml714-chm.china.huawei.com (10.206.15.33) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Krzysztof Struczynski 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. Changelog v1: - set build_ima_appraise instead of removing it (suggested by Mimi) 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 --- 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 ea9b991f0232..ef7f68cc935e 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); + } } } -- 2.17.1