From: Alexander Mikhalitsyn <alex@amutable.com>
To: Christian Brauner <brauner@kernel.org>,
Amir Goldstein <amir73il@gmail.com>,
linux-fsdevel@vger.kernel.org
Cc: Chris Down <chris@chrisdown.name>,
Miklos Szeredi <mszeredi@redhat.com>,
linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v2 07/13] ima,evm: use d_real_metadata_inode()
Date: Wed, 25 Nov 2026 13:52:00 +0100 [thread overview]
Message-ID: <c4b406a5bb8968e4fd73bb984c55f8aafb4ce355.camel@amutable.com> (raw)
In-Reply-To: <20261116-work-ovl-d_real-v2-7-90564c4ae347@kernel.org>
On Mon, 2026-11-16 at 10:44 +0100, Christian Brauner wrote:
> d_real() is about to be able to fail. D_REAL_METADATA never has to
> look
> anything up but we don't want to promise that it never fails. So
> switch
> the open-coded d_inode(d_real(..., D_REAL_METADATA)) in
> process_measurement() and evm_calc_hmac_or_hash() over to
> d_real_metadata_inode() and deal with errors.
>
> evm_calc_hmac_or_hash() returns the error so EVM fails to verify the
> metadata. process_measurement() passes the error on to
> evm_metadata_changed() which treats it like changed metadata and
> resets
> the EVM status. That is needed as evm_verify_hmac() would otherwise
> hand
> out a cached INTEGRITY_PASS without looking at the metadata again.
>
> This is a no-op as long as overlayfs can't fail D_REAL_METADATA.
>
> Suggested-by: Amir Goldstein <amir73il@gmail.com>
> Link:
> https://lore.kernel.org/all/CAOQ4uxjoHbevvu8auB4m8AVcY9H6uHdDAP6mfi9OOMh+3775xA@mail.gmail.com
Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> ---
> security/integrity/evm/evm_crypto.c | 5 ++++-
> security/integrity/evm/evm_main.c | 9 +++++----
> security/integrity/ima/ima_main.c | 6 +++---
> 3 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/security/integrity/evm/evm_crypto.c
> b/security/integrity/evm/evm_crypto.c
> index 1c41af2f91a60..17d528771d8fe 100644
> --- a/security/integrity/evm/evm_crypto.c
> +++ b/security/integrity/evm/evm_crypto.c
> @@ -231,7 +231,7 @@ static int evm_calc_hmac_or_hash(struct dentry
> *dentry,
> uint8_t type, struct evm_digest
> *data,
> struct evm_iint_cache *iint)
> {
> - struct inode *inode = d_inode(d_real(dentry,
> D_REAL_METADATA));
> + struct inode *inode = d_real_metadata_inode(dentry);
> struct xattr_list *xattr;
> struct shash_desc *desc;
> size_t xattr_size = 0;
> @@ -241,6 +241,9 @@ static int evm_calc_hmac_or_hash(struct dentry
> *dentry,
> bool ima_present = false;
> u64 i_version = 0;
>
> + if (IS_ERR(inode))
> + return PTR_ERR(inode);
> +
> if (!(inode->i_opflags & IOP_XATTR) ||
> inode->i_sb->s_user_ns != &init_user_ns)
> return -EOPNOTSUPP;
> diff --git a/security/integrity/evm/evm_main.c
> b/security/integrity/evm/evm_main.c
> index ac8328812e6ef..71faf156f9d6b 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -763,11 +763,11 @@ static void evm_reset_status(struct inode
> *inode)
> /**
> * evm_metadata_changed: Detect changes to the metadata
> * @inode: a file's inode
> - * @metadata_inode: metadata inode
> + * @metadata_inode: metadata inode, or an ERR_PTR() if it can't be
> resolved
> *
> * On a stacked filesystem detect whether the metadata has changed.
> If this is
> - * the case reset the evm_status associated with the inode that
> represents the
> - * file.
> + * the case, or if the metadata inode can't be resolved, reset the
> evm_status
> + * associated with the inode that represents the file.
> */
> bool evm_metadata_changed(struct inode *inode, struct inode
> *metadata_inode)
> {
> @@ -775,7 +775,8 @@ bool evm_metadata_changed(struct inode *inode,
> struct inode *metadata_inode)
> bool ret = false;
>
> if (iint) {
> - ret = (!IS_I_VERSION(metadata_inode) ||
> + ret = (IS_ERR(metadata_inode) ||
> + !IS_I_VERSION(metadata_inode) ||
> integrity_inode_attrs_changed(&iint-
> >metadata_inode,
>
> metadata_inode));
> if (ret)
> diff --git a/security/integrity/ima/ima_main.c
> b/security/integrity/ima/ima_main.c
> index e463cfc1e3f43..016de5a66eced 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -357,10 +357,10 @@ static int process_measurement(struct file
> *file, const struct cred *cred,
> }
>
> /*
> - * Reset the EVM status when metadata changed.
> + * Reset the EVM status when metadata changed or the
> inode
> + * hosting it can't be resolved.
> */
> - metadata_inode = d_inode(d_real(file_dentry(file),
> - D_REAL_METADATA));
> + metadata_inode =
> d_real_metadata_inode(file_dentry(file));
> if (evm_metadata_changed(inode, metadata_inode))
> iint->flags &= ~(IMA_APPRAISED |
> IMA_APPRAISED_SUBMASK);
next prev parent reply other threads:[~2026-11-25 12:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:43 [PATCH v2 00/13] fs: let d_real() fail Christian Brauner
2026-11-16 9:43 ` [PATCH v2 01/13] ovl: don't warn when the lazy lowerdata lookup fails in ovl_d_real() Christian Brauner
2026-11-25 12:44 ` Alexander Mikhalitsyn
2026-11-16 9:43 ` [PATCH v2 02/13] fs: add d_real_data_inode() and d_real_metadata_inode() Christian Brauner
2026-11-25 12:45 ` Alexander Mikhalitsyn
2026-11-16 9:44 ` [PATCH v2 03/13] tracing/uprobes: handle errors from resolving the real inode Christian Brauner
2026-11-18 1:30 ` Masami Hiramatsu (Google)
2026-11-18 16:41 ` Christian Brauner
2026-11-16 9:44 ` [PATCH v2 04/13] bpf: handle errors from resolving the real inode in uprobe_multi Christian Brauner
2026-11-16 9:44 ` [PATCH v2 05/13] selftests/bpf: handle d_real_data_inode() errors in bpf_testmod Christian Brauner
2026-11-16 9:44 ` [PATCH v2 06/13] ima: handle errors from resolving the real inode Christian Brauner
2026-11-24 18:57 ` Mimi Zohar
2026-11-16 9:44 ` [PATCH v2 07/13] ima,evm: use d_real_metadata_inode() Christian Brauner
2026-11-25 12:52 ` Alexander Mikhalitsyn [this message]
2026-11-16 9:44 ` [PATCH v2 08/13] ipe: handle errors from resolving the real inode Christian Brauner
2026-11-25 12:53 ` Alexander Mikhalitsyn
2026-11-16 9:44 ` [PATCH v2 09/13] bpf: return NULL from bpf_real_data_inode() on errors Christian Brauner
2026-11-16 9:44 ` [PATCH v2 10/13] ovl: return the error from the lazy lowerdata lookup in ovl_d_real() Christian Brauner
2026-11-16 9:44 ` [PATCH v2 11/13] fs: remove d_real_inode() Christian Brauner
2026-11-25 12:49 ` Alexander Mikhalitsyn
2026-11-16 9:44 ` [PATCH v2 12/13] selftests/ftrace: add uprobe tests on overlayfs Christian Brauner
2026-11-18 1:51 ` Masami Hiramatsu (Google)
2026-11-16 9:44 ` [PATCH v2 13/13] selftests/bpf: add uprobe_multi test on overlayfs without data Christian Brauner
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=c4b406a5bb8968e4fd73bb984c55f8aafb4ce355.camel@amutable.com \
--to=alex@amutable.com \
--cc=amir73il@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=chris@chrisdown.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=mszeredi@redhat.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