Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2735408ybz; Mon, 27 Apr 2020 03:37:04 -0700 (PDT) X-Google-Smtp-Source: APiQypIaDmMni68U/KOdu/+h1I0EXNC08IFtJZPRFVJ43qVRYl9DPXtpne2MapDmET+GQEk0n8pF X-Received: by 2002:a17:906:3e44:: with SMTP id t4mr19344165eji.337.1587983824164; Mon, 27 Apr 2020 03:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587983824; cv=none; d=google.com; s=arc-20160816; b=O1cNHKbBjf7aLpn5MErioDO6vt5Zjcz/P+T1lJyKjchds6Ly4HaJ2MKQKpKvD8ReJe RM9R1RM+8RGx0Xx34JvsV1QnlvJuo3ilonrxr8+MOV7SJ0a06XPeWumJEIZBiNItxzWy E00SheJJJT1NZ6S2iFBzousiD2FmVNn6fNy4UiudcpwnsZEJ6Kbejlop9rb5x369938d Wh+hYfo/MJ998QFK/N2nZPpMeCEIYGC1RUAKdGL5LmrZSJiXjrieWD60F96utj8fi6i0 cB2ro86hjl3hz6JXQTndXh9nC35Ndciw5aQ82ewu+fUAg/ZNr42mObLjppRzREqixTFX ZWMg== 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=BisP3uvnhfpGOviBOh5mrBPUZIcVTO3qMR+RMX28Xkc=; b=eVIGs/1O3Tvg98FfN5dVCF5o3jJOMm1njEq7j+vtb8RyJ+f2kx5WnUhzOmEBocEfuV k1cbOcFjaRVmXPzF+VyVwKvPH6WZKlSRoAXVVgLARai2TXbsLr98dKtcDqhgnaiDDMti ldtZ1yT2JX24YqvfP7vqnCpQJDg+VG77LUJn4cHNhUmuaLM0jQ19+yvGEVSVhBBLE0Xy FkHGTYx9nCPXsxgAw31fqEf+qnrTNlGqKuZ2ZWLwOXag8DAWi8/RM1d/gXbKZFqFdjo8 o+saxCqKRM7yvymwe7Pzdds8dz55vBqxPHqgEbNr5FIZQ+k8CWie4M4lGwU9reGsmi7F Vrjw== 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 v5si5263022edi.519.2020.04.27.03.36.41; Mon, 27 Apr 2020 03:37:04 -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 S1727102AbgD0KeA (ORCPT + 99 others); Mon, 27 Apr 2020 06:34:00 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2110 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726504AbgD0Kd7 (ORCPT ); Mon, 27 Apr 2020 06:33:59 -0400 Received: from lhreml730-chm.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id CDDD2F1A32276893828B; Mon, 27 Apr 2020 11:33:57 +0100 (IST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by lhreml730-chm.china.huawei.com (10.201.108.81) 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:33:57 +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:33:56 +0200 From: Roberto Sassu To: , CC: , , , , , "Roberto Sassu" , Subject: [PATCH v2 6/6] ima: Fix return value of ima_write_policy() Date: Mon, 27 Apr 2020 12:31:28 +0200 Message-ID: <20200427103128.19229-1-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 This patch fixes the return value of ima_write_policy() when a new policy is directly passed to IMA and the current policy requires appraisal of the file containing the policy. Currently, if appraisal is not in ENFORCE mode, ima_write_policy() returns 0 and leads user space applications to an endless loop. Fix this issue by denying the operation regardless of the appraisal mode. Changelog v1: - deny the operation in all cases (suggested by Mimi, Krzysztof) Cc: stable@vger.kernel.org # 4.10.x Fixes: 19f8a84713edc ("ima: measure and appraise the IMA policy itself") Signed-off-by: Roberto Sassu --- security/integrity/ima/ima_fs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c index 8b030a1c5e0d..e3fcad871861 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c @@ -338,8 +338,7 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf, integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL, "policy_update", "signed policy required", 1, 0); - if (ima_appraise & IMA_APPRAISE_ENFORCE) - result = -EACCES; + result = -EACCES; } else { result = ima_parse_add_rule(data); } -- 2.17.1