From: Mimi Zohar <zohar@linux.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Roberto Sassu <roberto.sassu@huaweicloud.com>,
Christian Brauner <brauner@kernel.org>,
Seth Forshee <sforshee@kernel.org>,
miklos@szeredi.hu, linux-unionfs@vger.kernel.org,
linux-kernel@vger.kernel.org, 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 <roberto.sassu@huawei.com>,
Eric Snowberg <eric.snowberg@oracle.com>
Subject: Re: [RFC][PATCH] overlayfs: Redirect xattr ops on security.evm to security.evm_overlayfs
Date: Thu, 14 Dec 2023 14:36:54 -0500 [thread overview]
Message-ID: <a9e016feca137d05dc1f4ead72b24992ac2017be.camel@linux.ibm.com> (raw)
In-Reply-To: <CAOQ4uxgra3KNthC_Od8r3fYDPO4AiVUF3u=aUfpUpQzOeeCFvg@mail.gmail.com>
On Thu, 2023-12-14 at 20:06 +0200, Amir Goldstein wrote:
> > > > There is another problem, when delayed copy is used. The content comes
> > > > from one source, metadata from another.
> > > >
> > > > I initially created test-file-lower on the lower directory
> > > > (overlayfs/data), before mounting overlayfs. After mount on
> > > > overlayfs/mnt:
> > > >
> > > > # getfattr -m - -e hex -d overlayfs/mnt/test-file-lower
> > > > # file: overlayfs/mnt/test-file-lower
> > > > security.evm=0x02c86ec91a4c0cf024537fd24347b780b90973402e
> > > > security.ima=0x0404f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
> > > > security.selinux=0x73797374656d5f753a6f626a6563745f723a756e6c6162656c65645f743a733000
> > > >
> > > > # chcon -t unconfined_t overlayfs/mnt/test-file-lower
> > > >
> > > > After this, IMA creates an empty file in the upper directory
> > > > (overlayfs/root/data), and writes security.ima at file close.
> > > > Unfortunately, this is what is presented from overlayfs, which is not
> > > > in sync with the content.
> > > >
> > > > # getfattr -m - -e hex -d overlayfs/mnt/test-file-lower
> > > > # file: overlayfs/mnt/test-file-lower
> > > > security.evm=0x021d71e7df78c36745e3b651ce29cb9f47dc301248
> > > > security.ima=0x04048855508aade16ec573d21e6a485dfd0a7624085c1a14b5ecdd6485de0c6839a4
> > > > security.selinux=0x73797374656d5f753a6f626a6563745f723a756e636f6e66696e65645f743a733000
> > > >
> > > > # sha256sum overlayfs/mnt/test-file-lower
> > > > f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 overlayfs/mnt/test-file-lower
> > > >
> > > > # sha256sum overlayfs/root/data/test-file-lower
> > > > 8855508aade16ec573d21e6a485dfd0a7624085c1a14b5ecdd6485de0c6839a4 overlayfs/root/data/test-file-lower (upperdir)
> > > >
> > > > We would need to use the lower security.ima until the copy is made, but
> > > > at the same time we need to keep the upper valid (with all xattrs) so
> > > > that IMA can update the next time overlayfs requests that.
> > > >
> > >
> > > Yap.
> > >
> > > As Seth wrote, overlayfs is a combination of upper and lower.
> > > The information that IMA needs should be accessible from either lower
> > > or upper, but sometimes we will need to make the right choice.
> > >
> > > The case of security.ima is similar to that of st_blocks -
> > > it is a data-related metadata, so it needs to be taken from the lowerdata inode
> > > (not even the lower inode). See example of getting STATX_BLOCKS
> > > in ovl_getattr().
> > >
> > > I would accept a patch that special cases security.ima in ovl_xattr_get()
> > > and gets it from ovl_i_path_lowerdata(), which would need to be
> > > factored out of ovl_path_lowerdata().
> > >
> > > I would also accept filtering out security.{ima,evm} from
> > >
> > > But I would only accept it if I know that IMA is not trying to write the
> > > security.ima xattr when closing an overlayfs file, only when closing the
> > > real underlying upper file.
> >
> > I don't see how that would be possible. As far as I'm aware, the
> > correlation is between the overlay and the underlying lower/uppper
> > file, not the other way around. How could a close on the underlying
> > file trigger IMA on an overlay file?
> >
>
> Well, you are right. it cannot.
>
> What I meant is that close of overlayfs file should NOT open and read
> the overlayfs file and recalculate security.ima to store in overlayfs inode
> because close of overlayfs file will follow a close of the upper file that
> should recalculate and store security.ima in the upper inode.
>
> It is possible that a close of an overlayfs file will update the security
> state of the overlayfs inode by copying the security state from the
> upper inode.
Thank you for the explanation.
Basically IMA should differentiate between file close on the underlying
upper/lower file and the overlay file. Since IMA doesn't define
inode_copy_up_xattr, security.ima will be copied up. Re-calculating
security.ima on the overlay is unnecessary.
> But then again, I could be misunderstanding the IMA workflows
> and it could be more complicated than I try to present it.
> This is the reason that I requested the documentation of how
> IMA+overlayfs is *expected* to work.
Ok
Mimi
next prev parent reply other threads:[~2023-12-14 19:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 17:23 [RFC][PATCH] overlayfs: Redirect xattr ops on security.evm to security.evm_overlayfs Roberto Sassu
2023-12-08 21:55 ` Amir Goldstein
2023-12-08 22:01 ` Christian Brauner
2023-12-11 14:56 ` Roberto Sassu
2023-12-11 15:36 ` Seth Forshee
2023-12-11 15:41 ` Roberto Sassu
2023-12-11 17:15 ` Seth Forshee
2023-12-11 18:24 ` Amir Goldstein
2023-12-11 18:01 ` Christian Brauner
2023-12-12 10:24 ` Roberto Sassu
2023-12-12 10:44 ` Amir Goldstein
2023-12-12 13:13 ` Roberto Sassu
2023-12-12 15:27 ` Mimi Zohar
2023-12-14 13:42 ` Roberto Sassu
2023-12-14 15:09 ` Amir Goldstein
2023-12-14 16:09 ` Mimi Zohar
2023-12-14 18:06 ` Amir Goldstein
2023-12-14 19:36 ` Mimi Zohar [this message]
2023-12-12 16:20 ` Roberto Sassu
2023-12-11 18:31 ` Amir Goldstein
2023-12-12 12:41 ` Roberto Sassu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9e016feca137d05dc1f4ead72b24992ac2017be.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=eric.snowberg@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=roberto.sassu@huaweicloud.com \
--cc=sforshee@kernel.org \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).