From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 891E32620DE for ; Tue, 23 Jun 2026 21:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782250298; cv=none; b=noUY0KuD5pgh1vBMyt7PNdyK+cGTnXW5zIfnyH3ZWscNNa3S9rFXkpQh1woP6zJcQs+qESk7v7qyZZOVubR3j2GJQDM2HAW7C/BTZ3bFbBKeAMMAu4Mru2ebVJ21e1RZZjq01luRxVJgzLIkdiAa0ha7wNXSbZ5Mh/zPeGnuhlA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782250298; c=relaxed/simple; bh=0ANTKXSFW/fZWU4QCXe+CkXZkYewYK5/ubk2dOFWLzM=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=ogppO27XfHvG6oG4WM3LCaIAgva5+AlgKLyiOsM/ODasWCMTgP2fISwCECrHV3xr6uMY6UNnaRMoIwxKA1jLWlPec1SjGgnzwyQKoazFRab2KM8yYpFZFLsIBmeZuc4DfKm5MRPG7q+YidDTdKlzeCtrDebMEoJqxA9SGfzv8Z4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=LRu+spQi; arc=none smtp.client-ip=74.125.82.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="LRu+spQi" Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-13810b63a1aso779563c88.1 for ; Tue, 23 Jun 2026 14:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1782250296; x=1782855096; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SUP7w+eH6fgvtXB7JUmSeEA4Y7fDi9ONBSL+3HNE0xA=; b=LRu+spQiQlCKjapBDCH/q9E+g+ouG0zIn107PC1X9voBjykgyfkUM585GQgKX1GsxY w8wrY4LU52mh83UJv43cCUoDqmjjZahhvQBC0TNkQ1WPupLq5Z69UzexKV8HUYOwxQg+ ydQ5i7V2mRDV0lzNguNgo2QqdYnqEtgjMhOUZCTbOgT4OoiX43jPBzY1Fmwv1DdPrJnF kVv0jvgkq0ZMbBvLXVkrX8b7aSSpWr7da6i/Skkl50/CzR98vlxcpZ7T7KKWxPbaopm+ GTNfznSWVG63h5MubChbddJy448AcSfd3Fumn35MgGXXJQ64hwp1NwcalLHiofjUyVMl ZN1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782250296; x=1782855096; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SUP7w+eH6fgvtXB7JUmSeEA4Y7fDi9ONBSL+3HNE0xA=; b=hnh9IlYj7zJby78ZlATCjGm60XVLSWm6MiF1O2mnV3BvPE8mQNxgvTIgnLn7AtHDzX R6TGzcN++B/JYVqTI+tSwIuw2afm5B4Ds6r+eFTre+eDpBImv93MPiNlHLnkzYyrmP3C QJ1qmdALEOeepgLgfkB8a1UDD1808E86/eO3BIplsOSXTeb2hEb++VyYBPStCZ8eudXn hXEGcGmZW4gSmBbC5qjPrcXvYUti8tYB7xM722M1kqEK3IzjplKkJPMiRmnh45S9RPOw ZzVXrBEu9TYcsdkCfDGsTxSKuTUiG6M4ZnuFyjLaVHagTZsXTYLnbaRNhZWjqlkHFj6g u4dA== X-Forwarded-Encrypted: i=1; AHgh+Rr5qFhLUhqwVsI4PYP/+cvGGjFIwunBU45a5GaUzAwE2GK4Ejw0gAdqJPv/0i1/J8eMGbho4lexqbjMW/Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0aE2LSbj5RWafh1UAu4FJkWZvcYvjqFMjdDxud2iUhHOlL5AY Th52mV+NR+/9JSelRcNlSSqWc8tlyKO5B0heSvCjR4g2G7vXttlDquzMTOBVSsPBH9I= X-Gm-Gg: AfdE7ck+Ky5sD1N/WrJxgvu4WEZBDjQwX9EApD7+3abWl9tNpKddkYrwl+Eaf6QF/9D CI0IaKwHq0DD2g7mUYuNUjPKU7wvYjsSJ9skS1hCkxg7YrHca1l9VaWEUsZPCDTEi6EQ2q2QlvK MNZn/Y0SITrxPEgCXvRbpCJZyAWz2jFZ9mJQFX9xpYdGAPY50iQf6XDyvkOvhHCMgr8I2lDGLk/ pO8MwqoU0xWz7fsqEo8vYojnmXMWVCStGfMTTB+rclEZ7nlZ8w79/etW3kkqeXLOr/c9K/Uv0JG xHequtl67N1qHsQEKz0swgELt2/IQ//elTO7sRVTT24hKKWxxClwas6GTAin6nJALyE1dzPrISm 0glpQ7XaExwKvv9y2qZ0YcVrQeVwlKA/8H7F6q32QOJ5L6r16vsmSz+AEFlkZ7QeLPxBs/A== X-Received: by 2002:a05:7300:a494:b0:30c:56a0:ce3f with SMTP id 5a478bee46e88-30c56a0d1c5mr4096393eec.2.1782250295582; Tue, 23 Jun 2026 14:31:35 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::2526]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c1ba1c32csm20670452eec.6.2026.06.23.14.31.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 14:31:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 Jun 2026 17:31:33 -0400 Message-Id: To: "Christian Brauner" , Cc: "Alexander Viro" , "Jan Kara" , "Amir Goldstein" , , Subject: Re: [PATCH v2] bpf: have bpf_real_data_inode() take a struct file From: "Emil Tsalapatis" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260623-work-bpf-real_inode-v2-1-8e8b57dd25f7@kernel.org> In-Reply-To: <20260623-work-bpf-real_inode-v2-1-8e8b57dd25f7@kernel.org> On Tue Jun 23, 2026 at 5:32 AM EDT, Christian Brauner wrote: > bpf_real_data_inode() must be usable from the bprm_check_security, > mmap_file and file_mprotect hooks for systemd's RestrictFilesystemAccess > BPF LSM program, so have it take a struct file instead of a dentry. > > Amir Goldstein suggests: > > While doing so, rename it from bpf_real_inode() to > bpf_real_data_inode(). For a regular file on a union/overlay > filesystem it resolves to the underlying inode that hosts the data, > but for a non-regular file it returns the overlay inode. The new name > makes the "inode hosting the data" intent explicit and avoids the > ambiguity of "the real inode backing a file". Document the > non-regular-file behavior in the kfunc too. > > Both the signature change and the rename are safe because the kfunc > landed this cycle and has no released users. > > Fixes: 9af8c8a54f6e ("bpf: add bpf_real_inode() kfunc") > Signed-off-by: Christian Brauner (Amutable) Reviewed-by: Emil Tsalapatis > --- > Changes in v2: > - Rename bpf_real_inode() -> bpf_real_data_inode() (Amir); the new name > makes the "inode hosting the data" intent explicit. > - Document that the kfunc returns the overlay inode for non-regular files= . > - Link to v1: https://patch.msgid.link/20260622-work-bpf-real_inode-v1-1-= 4014eb4cbefd@kernel.org > --- > fs/bpf_fs_kfuncs.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > > diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c > index 768aca2dc0f0..f1863a891db6 100644 > --- a/fs/bpf_fs_kfuncs.c > +++ b/fs/bpf_fs_kfuncs.c > @@ -360,18 +360,23 @@ __bpf_kfunc int bpf_cgroup_read_xattr(struct cgroup= *cgroup, const char *name__s > #endif /* CONFIG_CGROUPS */ > =20 > /** > - * bpf_real_inode - get the real inode backing a dentry > - * @dentry: dentry to resolve > + * bpf_real_data_inode - get the real inode hosting a file's data > + * @file: file to resolve > * > - * If the dentry is on a union/overlay filesystem, return the underlying= , real > - * inode that hosts the data. Otherwise return the inode attached to th= e > - * dentry itself. > + * Resolve @file to the inode that hosts its data. For a regular file on= a > + * union/overlay filesystem this is the underlying (upper or lower) inod= e that > + * stores the data, not the overlay inode. > * > - * Return: The real inode backing the dentry, or NULL for a negative den= try. > + * Data resolution only applies to regular files. For a non-regular file= (e.g. > + * a device node, fifo or socket) on a union/overlay filesystem the over= lay > + * inode itself is returned; for any file on a non-union filesystem the = inode > + * attached to @file is returned. > + * > + * Return: The inode hosting @file's data, or NULL. > */ > -__bpf_kfunc struct inode *bpf_real_inode(struct dentry *dentry) > +__bpf_kfunc struct inode *bpf_real_data_inode(struct file *file) > { > - return d_real_inode(dentry); > + return d_real_inode(file_dentry(file)); > } > =20 > __bpf_kfunc_end_defs(); > @@ -384,7 +389,7 @@ BTF_ID_FLAGS(func, bpf_get_dentry_xattr, KF_SLEEPABLE= ) > BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE) > BTF_ID_FLAGS(func, bpf_set_dentry_xattr, KF_SLEEPABLE) > BTF_ID_FLAGS(func, bpf_remove_dentry_xattr, KF_SLEEPABLE) > -BTF_ID_FLAGS(func, bpf_real_inode, KF_SLEEPABLE | KF_RET_NULL) > +BTF_ID_FLAGS(func, bpf_real_data_inode, KF_SLEEPABLE | KF_RET_NULL) > BTF_KFUNCS_END(bpf_fs_kfunc_set_ids) > =20 > static int bpf_fs_kfuncs_filter(const struct bpf_prog *prog, u32 kfunc_i= d) > > --- > base-commit: 5b33fc6492a7b7a62359157db0f92f5b6e9af690 > change-id: 20260622-work-bpf-real_inode-c3202dbaf0ab