Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795610732; b=mN0gMelJxQBi2fy1ZJy2CQCppC5mlAWS34ID4m1UkXArrvkRUZh7eaS5uX2v1p9nIHzd vUy7euiqyHsv+MGB1aEIogapzZdkWLfqCHmgvKudMqW+uRJ0oeNieY7LolktjDmraSWpn kHn59lxWzlZDY9jk5G0sa0a/mO9H7C9tAa+nocIIcy8mmFGOTfYJwwhP3XxuhDaYvCj3P iE5mNPJAZodhCnalR3mm3Q3UOjbBr3Xm9Eqq+ihmfYuFqkuOmteKLFZ8MabYGcXyHmv6C Rt6Y6jXRUjQiREVhw+X/gayyiOIhvzRv2vDgLmMEc622prXTmTVz3gV64H/Dyo/ZkQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795610732; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=j8tGJOMZL0j/KUQBnDfeHMeTQs27ZK0iqIQ4+ayeZUU=; b=URUFr+X4JF/ATnkPnR0EB1JxmYnllcbazegrsDHTbooIa6ykcmksh2bD6/gySEDXek+D GWEgVZ22BTixS6cfmJSnbvmWCpp2GmA/F+bf2msEonvqbTBWkwhF7kMQTwLNzr7nHlovY OJ0ye7EMQHv8ywbwj+9AyTc5y9s0K/eV2BvDxZZI6eGmmqTWDN71VpKQZkYO3jNpVksIH qPg3tKlm6ZDh33dTiSLhcGBWO8onKSXlqTBj9JVu8frAiAEcMeWhKkXNGYAG2lNVVqcy1 MIJN1Gnubkgox8URbloZpJyh56rKa08pVH9alez0njZIkC2geBI0RMZJxMHA06KaBTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=amutable.com; spf=pass smtp.mailfrom=amutable.com; dkim=pass header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=Dn8fSjUJ; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3C1606A32C for ; Wed, 25 Nov 2026 12:45:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC3C1606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amutable.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amutable.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=Dn8fSjUJ Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4bb6c7b6dbdso53013055e9.0 for ; Wed, 25 Nov 2026 04:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amutable-com.20260707.gappssmtp.com; s=20260707; t=1795610730; x=1796215530; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=j8tGJOMZL0j/KUQBnDfeHMeTQs27ZK0iqIQ4+ayeZUU=; b=Dn8fSjUJZ0W18CxI0+QBCtqPSCauc1BDi2lAYnZcUk/CGqeLcNTTMRBQW33oo9lIRF +qyvu2+iBnTdmOFaW8crfcRdDgjN3stD2TkOd+qiSFU64QZ91RZmDEemG0ULNn1RY3iC YFRu8prBJbwhpYRseFCHzdI0Xy1Rs6KvgbX+GhlEhKqDdK0OiWEd9dn9waUHZAoXcjMT SsjAuOt7MYheWutuyfu5btVDQIYz6unWA7QWHe6zy/Iegke+cOWGKKoWX05Ks4iYqUbX fZKTbaTyilEi/ETmhcznlr4c5D33jgH/U5Dd3FRA2SHdt5WUlH57N475qAk82MjsS/J+ uPnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795610730; x=1796215530; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=j8tGJOMZL0j/KUQBnDfeHMeTQs27ZK0iqIQ4+ayeZUU=; b=PI3DXfsOdD9nZkRZxhSsbirs5Cj+EopqD9aBcPev/AojuYN8L/meZu26ZsraC1vwh9 cabv3WlQJT33YZw4r0WaBDme4KBcmTJ8hRVVBSwVpz9JF/mWlhDdXKopfcBfkUyKJyRg XWlSrpRqE/scSYjIMSTWdp6qxtvRTU8LocTAt1Ii0F+Oz/3GJqf/0ysc1RQxIsA96M52 ak/ChVbqYDGtYRukOBkmAKf2kXNNanH/8EuHEYRoa4qbhXvfp9PrwVC594/spTuUsjun 62MmInSpinXBenIImkgAxqsrZEVh95ukmQsqHJdS4brjTbUNZbo+hUEIOxKBnLZcs73p TdRA== X-Forwarded-Encrypted: i=1; AL+hErFDZjHwdIXxBeGcxk1UKNpbUlRmVFrPiz+Lul+x2VcSRT2NWMIzeIEZuYXRxBmCi+BsI14=@vger.kernel.org X-Gm-Message-State: APuU4Z81FRoxVb7/gX6UN9fL5yYzXk4sltDKbte1nX1JGbIqFm4wa4vL tMeg1RE4DImlaF5fwPiZWuRa1bT1pH4DujiW6MlCsw6VPkmnMM0ofhc40ivLyY6DLL+O X-Gm-Gg: AZFdTZd+zGHGmD3eKKnqHiqU00xhc3X3VhzV6tuJSz2+Sm0mJ0w69FqjQ1tiSR8uxCE Pv3CbOydOC/q6UxuTXhgRB2+2HApa2iywLNTRj3Ry8PmKV/5Wkf175yp1jNtDs2UYo5lS9qqMNh J/JDhFm/hVaU6Eurem40/t3cVtu3/cH3fUQE1x0/P41xNANTaRuhO8zTEtZnYygPgbFsmWegPiL TTNXKncn7wrP16KwEJEEmh26+xBAchieYtt5oT9io+6sjX9fMbCP+lSC3NoQrHZGdSDc1sYxs6l bBS3k5XKN9v1AW9qJuwdodBLZD3+9O3MLLSQ5aROFWYzUznCLw+v5Xjcv3+enhYENVg0zhuIV2Z 4xcZ+rTpqcgLKopidkOs1THncoAM+lShChTdmV13FZ8mVMXbd3ouRTonrjUbEWJ9E9dhRjhnZN5 5kjFJxFkTMoNpFTVcNiL/UJwxXkJ84N6HhLy4thMLNJLlRFg4BnrZ1S7/pNr9Xyvg4aFe45UfTW XZnMTIZmZcdqP8TwPMGQI0o8KoGHksnfHx1zILQ6fxXpfgNyJksdwwk6l5jaDBDVHIW9b10u6by 2QBbC2USgiYxQfB5jr5TgDdW6CvVqwjkHwO8hl6wxYRSpqZ26zo5Gyv/ZSGS3euZXUuSeU+d4OI XZC9z/qSCD6zuKDH8aZC3UdH+hjS5/UUSNOswzwm5DstdLqgiNKQmlw== X-Received: by 2002:a05:600c:8184:b0:4a3:5a7b:6002 with SMTP id 5b1f17b1804b1-4bb8881e969mr338093175e9.28.1795610730212; Wed, 25 Nov 2026 04:45:30 -0800 (PST) Received: from ?IPv6:2003:cf:572c:2800:c235:97b:8b16:8928? (p200300cf572c2800c235097b8b168928.dip0.t-ipconnect.de. [2003:cf:572c:2800:c235:97b:8b16:8928]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bba3d3679bsm34001885e9.2.2026.11.25.04.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 04:45:29 -0800 (PST) Message-ID: <9f460569c2d4236f470231a5cce0b6086c612e19.camel@amutable.com> Subject: Re: [PATCH v2 02/13] fs: add d_real_data_inode() and d_real_metadata_inode() From: Alexander Mikhalitsyn To: Christian Brauner , Amir Goldstein , linux-fsdevel@vger.kernel.org Cc: Chris Down , Miklos Szeredi , 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 Date: Wed, 25 Nov 2026 13:45:27 +0100 In-Reply-To: <20261116-work-ovl-d_real-v2-2-90564c4ae347@kernel.org> References: <20261116-work-ovl-d_real-v2-0-90564c4ae347@kernel.org> <20261116-work-ovl-d_real-v2-2-90564c4ae347@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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. >=20 > 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. >=20 > Teach d_real() to fail and teach all callers to handle errors. This > adds > two helpers for the callers to switch over to: >=20 > - d_real_data_inode() returns the inode hosting the data or an > ERR_PTR() > =C2=A0 if that can't be resolved. >=20 > - d_real_metadata_inode() returns the inode hosting the metadata or > an > =C2=A0 ERR_PTR(). overlayfs never has to look anything up for the metadat= a > =C2=A0 but we don't want to promise that it never fails. So callers handl= e > =C2=A0 errors for it as well. >=20 > d_real() can't fail yet so this is a pure preparation. d_real_inode() > stays around until all callers are converted. >=20 > No functional changes. >=20 > Suggested-by: Amir Goldstein > Link: > https://lore.kernel.org/all/CAOQ4uxhGxpBtMZ5kfuzR1tQAewiecoX7UjXQRo91QjJH= H9T_Yw@mail.gmail.com > Reviewed-by: Amir Goldstein Reviewed-by: Alexander Mikhalitsyn > Signed-off-by: Christian Brauner (Amutable) > --- > =C2=A0include/linux/dcache.h | 45 > +++++++++++++++++++++++++++++++++++++++++++++ > =C2=A01 file changed, 45 insertions(+) >=20 > 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 @@ > =C2=A0#define __LINUX_DCACHE_H > =C2=A0 > =C2=A0#include > +#include > =C2=A0#include > =C2=A0#include > =C2=A0#include > @@ -660,6 +661,50 @@ static inline struct inode *d_real_inode(const > struct dentry *dentry) > =C2=A0 return d_inode(d_real((struct dentry *) dentry, > D_REAL_DATA)); > =C2=A0} > =C2=A0 > +/** > + * 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 =3D 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 =3D d_real(dentry, D_REAL_METADATA); > + if (IS_ERR(real)) > + return ERR_CAST(real); > + return d_inode(real); > +} > + > =C2=A0struct name_snapshot { > =C2=A0 struct qstr name; > =C2=A0 union shortname_store inline_name;