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 02/13] fs: add d_real_data_inode() and d_real_metadata_inode()
Date: Wed, 25 Nov 2026 13:45:27 +0100 [thread overview]
Message-ID: <9f460569c2d4236f470231a5cce0b6086c612e19.camel@amutable.com> (raw)
In-Reply-To: <20261116-work-ovl-d_real-v2-2-90564c4ae347@kernel.org>
On Mon, 2026-11-16 at 10:43 +0100, Christian Brauner wrote:
> Currently, d_real() can't fail. When overlayfs fails to look up the
> data
> of a metacopy file in a data-only layer it hands back the overlayfs
> dentry and callers silently work with the overlayfs inode. That's
> more
> problematic than current callers realize.
>
> For trace_uprobe and bpf's uprobe_multi it means uprobe_register()
> fails
> with an -EIO that has nothing to do with the actual problem. For IMA
> it
> means the stacked change detection is skipped and for IPE the file is
> evaluated against an inode that has none of the properties of the
> real
> file.
>
> Teach d_real() to fail and teach all callers to handle errors. This
> adds
> two helpers for the callers to switch over to:
>
> - d_real_data_inode() returns the inode hosting the data or an
> ERR_PTR()
> if that can't be resolved.
>
> - d_real_metadata_inode() returns the inode hosting the metadata or
> an
> ERR_PTR(). overlayfs never has to look anything up for the metadata
> but we don't want to promise that it never fails. So callers handle
> errors for it as well.
>
> d_real() can't fail yet so this is a pure preparation. d_real_inode()
> stays around until all callers are converted.
>
> No functional changes.
>
> Suggested-by: Amir Goldstein <amir73il@gmail.com>
> Link:
> https://lore.kernel.org/all/CAOQ4uxhGxpBtMZ5kfuzR1tQAewiecoX7UjXQRo91QjJHH9T_Yw@mail.gmail.com
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> ---
> include/linux/dcache.h | 45
> +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/include/linux/dcache.h b/include/linux/dcache.h
> index 84b0cfe4ed0e7..a75016a713d4a 100644
> --- a/include/linux/dcache.h
> +++ b/include/linux/dcache.h
> @@ -3,6 +3,7 @@
> #define __LINUX_DCACHE_H
>
> #include <linux/atomic.h>
> +#include <linux/err.h>
> #include <linux/list.h>
> #include <linux/math.h>
> #include <linux/rculist.h>
> @@ -660,6 +661,50 @@ static inline struct inode *d_real_inode(const
> struct dentry *dentry)
> return d_inode(d_real((struct dentry *) dentry,
> D_REAL_DATA));
> }
>
> +/**
> + * d_real_data_inode - Return the real inode hosting the data
> + * @dentry: The dentry to query
> + *
> + * If @dentry is a regular file on a union/overlay, then return the
> + * underlying, real inode that hosts its data. Otherwise return
> d_inode().
> + *
> + * The union/overlay may have to look up the data first. This can
> sleep and it
> + * can fail, e.g., because the data is missing or because its verity
> digest
> + * doesn't match.
> + *
> + * Return: The real inode hosting the data of @dentry, or an
> ERR_PTR() if it
> + * can't be resolved.
> + */
> +static inline struct inode *d_real_data_inode(struct dentry *dentry)
> +{
> + struct dentry *real;
> +
> + real = d_real(dentry, D_REAL_DATA);
> + if (IS_ERR(real))
> + return ERR_CAST(real);
> + return d_inode(real);
> +}
> +
> +/**
> + * d_real_metadata_inode - Return the real inode hosting the
> metadata
> + * @dentry: The dentry to query
> + *
> + * If @dentry is a regular file on a union/overlay, then return the
> + * underlying, real inode that hosts its metadata. Otherwise return
> d_inode().
> + *
> + * Return: The real inode hosting the metadata of @dentry, or an
> ERR_PTR() if
> + * it can't be resolved.
> + */
> +static inline struct inode *d_real_metadata_inode(struct dentry
> *dentry)
> +{
> + struct dentry *real;
> +
> + real = d_real(dentry, D_REAL_METADATA);
> + if (IS_ERR(real))
> + return ERR_CAST(real);
> + return d_inode(real);
> +}
> +
> struct name_snapshot {
> struct qstr name;
> union shortname_store inline_name;
next prev parent reply other threads:[~2026-11-25 12:45 UTC|newest]
Thread overview: 37+ 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-16 9:49 ` sashiko-bot
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-16 9:49 ` sashiko-bot
2026-11-25 12:45 ` Alexander Mikhalitsyn [this message]
2026-11-16 9:44 ` [PATCH v2 03/13] tracing/uprobes: handle errors from resolving the real inode Christian Brauner
2026-11-16 9:53 ` sashiko-bot
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:49 ` sashiko-bot
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:49 ` sashiko-bot
2026-11-16 9:44 ` [PATCH v2 06/13] ima: handle errors from resolving the real inode Christian Brauner
2026-11-16 9:53 ` sashiko-bot
2026-11-24 18:57 ` Mimi Zohar
2026-11-30 14:23 ` Christian Brauner
2026-11-16 9:44 ` [PATCH v2 07/13] ima,evm: use d_real_metadata_inode() Christian Brauner
2026-11-16 9:52 ` sashiko-bot
2026-11-25 12:52 ` Alexander Mikhalitsyn
2026-11-16 9:44 ` [PATCH v2 08/13] ipe: handle errors from resolving the real inode Christian Brauner
2026-11-16 9:49 ` sashiko-bot
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:51 ` sashiko-bot
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:58 ` sashiko-bot
2026-11-16 9:44 ` [PATCH v2 11/13] fs: remove d_real_inode() Christian Brauner
2026-11-16 9:50 ` sashiko-bot
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-16 9:53 ` sashiko-bot
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
2026-11-16 9:53 ` sashiko-bot
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=9f460569c2d4236f470231a5cce0b6086c612e19.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.