From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E772CDC; Mon, 11 Dec 2023 07:42:07 -0800 (PST) Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4Splxf4jp1zB03Fq; Mon, 11 Dec 2023 23:28:06 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id B5020140489; Mon, 11 Dec 2023 23:41:59 +0800 (CST) Received: from [127.0.0.1] (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwDnInO+LXdlFG9ZAg--.22283S2; Mon, 11 Dec 2023 16:41:59 +0100 (CET) Message-ID: <6e05677355d6d134dddd11da56709b424b631079.camel@huaweicloud.com> Subject: Re: [RFC][PATCH] overlayfs: Redirect xattr ops on security.evm to security.evm_overlayfs From: Roberto Sassu To: Seth Forshee Cc: Christian Brauner , Amir Goldstein , miklos@szeredi.hu, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, paul@paul-moore.com, stefanb@linux.ibm.com, jlayton@kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, Roberto Sassu Date: Mon, 11 Dec 2023 16:41:46 +0100 In-Reply-To: References: <20231208172308.2876481-1-roberto.sassu@huaweicloud.com> <20231208-tauziehen-zerfetzt-026e7ee800a0@brauner> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID:LxC2BwDnInO+LXdlFG9ZAg--.22283S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFWfXryxCw1xWw4ktw1fWFg_yoW8C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th Forshee wrote: > On Mon, Dec 11, 2023 at 03:56:06PM +0100, Roberto Sassu wrote: > > Ok, I will try. > >=20 > > I explain first how EVM works in general, and then why EVM does not > > work with overlayfs. > >=20 > > EVM gets called before there is a set/removexattr operation, and after, > > if that operation is successful. Before the set/removexattr operation > > EVM calculates the HMAC on current inode metadata (i_ino, i_generation, > > i_uid, i_gid, i_mode, POSIX ACLs, protected xattrs). Finally, it > > compares the calculated HMAC with the one in security.evm. > >=20 > > If the verification and the set/removexattr operation are successful, > > EVM calculates again the HMAC (in the post hooks) based on the updated > > inode metadata, and sets security.evm with the new HMAC. > >=20 > > The problem is the combination of: overlayfs inodes have different > > metadata than the lower/upper inodes; overlayfs calls the VFS to > > set/remove xattrs. >=20 > I don't know all of the inner workings of overlayfs in detail, but is it > not true that whatever metadata an overlayfs mount presents for a given > inode is stored in the lower and/or upper filesystem inodes? If the > metadata for those inodes is verified with EVM, why is it also necessary > to verify the metadata at the overlayfs level? If some overlayfs > metadata is currently omitted from the checks on the lower/upper inodes, > is there any reason EVM couldn't start including that its checksums? Currently, the metadata where there is a misalignment are: i_generation, s_uuid, (i_ino?). Maybe there is more? If metadata are aligned, there is no need to store two separate HMACs. Thanks Roberto > Granted that there could be some backwards compatibility issues, but > maybe inclusion of the overlayfs metadata could be opt-in. >=20 > Thanks, > Seth