Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2932744pxy; Mon, 3 May 2021 11:10:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyNdMNWBKljY7PZo5SS/nciam8+2bE9Z7BZ3dkMFTmyS4M3q/dshiKmB7vzkDr57Tx6i23 X-Received: by 2002:a17:90a:6687:: with SMTP id m7mr23089430pjj.75.1620065423824; Mon, 03 May 2021 11:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620065423; cv=none; d=google.com; s=arc-20160816; b=FB4QkImZ0cmoKE0PVWL/erOI1RMw5hGsLrmcjOU7S+8uEyAFnIBA3OLfmleqqv4Xvr lZkg1C04aoHZ5dmNhNNJBJwNnNIm9Xx+jQaNQgl0k/NBAC1HXksBzYhlZwaEju20t/D3 mPEeQoxTTe3Ybrb2gb3x76FiXmQvuPWrP9AE9CfaMwDKP+lPdZ8ofQs88qbU877/HRPg KGTd/NPVtJjlrsCOJb2P4zCaoyRFmVo9ognJ15SoeizxvqRxxfylYxr/Bx2AZvpu2geM hzU/aPx/HYSYl/QWwqLb5Kib81WE20ntN6s7zDEEIO/CmOr3m0dPBZr0WzGcwwJowy1j +yXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=yKi5wNKPsx4+rxe9pz387O2M33CwAtdTgPEWK53zR8k=; b=Rf/Z07IS7eIzRC4ED9COY2qYI9R40wo0royeYISx5z63mCuFbrg+wxWAAzWKAExRJ5 LW+bx78zr+2Ib//dGEGT07WajMZmcjiVBJLV3M+XOsgVs/wKhXZjTP8CSjUE9Xh1qmhs fFkk+8LnViOFhWaokz89UcDsVnT6cuPa+Nmz+C2cO/oLKRr88lfPT+bTIhyHuUeyS4FD CpdhR5A4gDI90dG/6IJ/HXhKe6I0wYcL6YETM2vtwxiDtKW/wit8MYwtRe1A1wVpMkdd gaAJ3REuCnRlFpVNG/UPYE9ttn/X2mgffLs3BK7MYD0mviH8AmtHUvuJr6Fy+ZxVHZTh jSmQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si377696pgv.298.2021.05.03.11.10.11; Mon, 03 May 2021 11:10:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbhECPdu convert rfc822-to-8bit (ORCPT + 99 others); Mon, 3 May 2021 11:33:50 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2990 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhECPdr (ORCPT ); Mon, 3 May 2021 11:33:47 -0400 Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FYmxL2qmLz6snwd; Mon, 3 May 2021 23:24:54 +0800 (CST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 3 May 2021 17:32:52 +0200 Received: from fraeml714-chm.china.huawei.com ([10.206.15.33]) by fraeml714-chm.china.huawei.com ([10.206.15.33]) with mapi id 15.01.2176.012; Mon, 3 May 2021 17:32:52 +0200 From: Roberto Sassu To: Mimi Zohar , "mjg59@google.com" CC: "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Christian Brauner , Andreas Gruenbacher Subject: RE: [PATCH v5 09/12] evm: Allow setxattr() and setattr() for unmodified metadata Thread-Topic: [PATCH v5 09/12] evm: Allow setxattr() and setattr() for unmodified metadata Thread-Index: AQHXK5xeSg6sM/30eEKbqlkQ5rVFkKrRv8yAgABEE/D//+S7AIAAIuSw Date: Mon, 3 May 2021 15:32:52 +0000 Message-ID: References: <20210407105252.30721-1-roberto.sassu@huawei.com> <20210407105252.30721-10-roberto.sassu@huawei.com> <8493d7e2b0fefa4cd3861bd6b7ee6f2340aa7434.camel@linux.ibm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.221.98.153] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Mimi Zohar [mailto:zohar@linux.ibm.com] > Sent: Monday, May 3, 2021 5:26 PM > On Mon, 2021-05-03 at 15:11 +0000, Roberto Sassu wrote: > > > From: Mimi Zohar [mailto:zohar@linux.ibm.com] > > > Sent: Monday, May 3, 2021 3:00 PM > > > On Wed, 2021-04-07 at 12:52 +0200, Roberto Sassu wrote: > > > > > > > diff --git a/security/integrity/evm/evm_main.c > > > b/security/integrity/evm/evm_main.c > > > > @@ -389,6 +473,11 @@ static int evm_protect_xattr(struct > > > user_namespace *mnt_userns, > > > > if (evm_status == INTEGRITY_FAIL_IMMUTABLE) > > > > return 0; > > > > > > > > + if (evm_status == INTEGRITY_PASS_IMMUTABLE && > > > > + !evm_xattr_change(mnt_userns, dentry, xattr_name, xattr_value, > > > > + xattr_value_len)) > > > > + return 0; > > > > + > > > > > > If the purpose of evm_protect_xattr() is to prevent allowing an invalid > > > security.evm xattr from being re-calculated and updated, making it > > > valid, INTEGRITY_PASS_IMMUTABLE shouldn't need to be conditional. > Any > > > time there is an attr or xattr change, including setting it to the > > > existing value, the status flag should be reset. > > > > > > I'm wondering if making INTEGRITY_PASS_IMMUTABLE conditional would > > > prevent the file from being resigned. > > > > > > > if (evm_status != INTEGRITY_PASS) > > > > integrity_audit_msg(AUDIT_INTEGRITY_METADATA, > > > d_backing_inode(dentry), > > > > dentry->d_name.name, > > > "appraise_metadata", > > > > > > This would then be updated to if not INTEGRITY_PASS or > > > INTEGRITY_PASS_IMMUTABLE. The subsequent "return" would need to > be > > > updated as well. > > > > I agree on the first suggestion, to reduce the number of log messages. > > For the second, if you meant that we should return 0 if the status is > > INTEGRITY_PASS_IMMUTABLE, I thought we wanted to deny xattr > > changes when there is an EVM portable signature. > > Why? I must be missing something. As long as we're not relying on the > cached status, allowing the file metadata to be updated shouldn't be an > issue. We may want to prevent accidental changes, for example. Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Li Jian, Shi Yanli