From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next 2/3] bpf: Add a bpf_get_inode_xattr kfunc
Date: Thu, 03 Dec 2026 14:01:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-247912@kernel.org> (raw)
In-Reply-To: <20261203134411.1092433-3-a.s.protopopov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bpf: bpf_get_inode_xattr() ignores hashed aliases via
d_find_any_alias()
--
commit 411b1cdf4c29cccf8363d8423d9bb02ec61b59b9
Author: Anton Protopopov <a.s.protopopov@gmail.com>
bpf: Add a bpf_get_inode_xattr kfunc
This commit adds the sleepable bpf_get_inode_xattr() kfunc to read an
extended attribute from an inode by looking up one of its dentries with
d_find_any_alias().
> diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
> index 1b973bd4e5355..654340a0bc70e 100644
> --- a/fs/bpf_fs_kfuncs.c
> +++ b/fs/bpf_fs_kfuncs.c
> @@ -169,6 +169,35 @@ __bpf_kfunc int bpf_get_file_xattr(struct file *file, const char *name__str,
[ ... ]
> +__bpf_kfunc int bpf_get_inode_xattr(struct inode *inode, const char *name__str,
> + struct bpf_dynptr *value_p)
> +{
> + struct dentry *dentry;
> + int ret;
> +
> + dentry = d_find_any_alias(inode);
> + if (!dentry)
> + return -ENOENT;
> + ret = bpf_get_dentry_xattr(dentry, name__str, value_p);
> + dput(dentry);
> + return ret;
> +}
[Severity: Medium]
Should this try d_find_alias() before falling back to d_find_any_alias()?
d_find_any_alias() returns the first alias on inode->i_dentry without
skipping unhashed or disconnected dentries. Path-based filesystems rely on
the dentry in their xattr callbacks; for example, cifs_xattr_get() builds
the server path from it via build_path_from_dentry().
When an inode has an open unlinked hard link ahead of a live hard link on
inode->i_dentry, bpf_get_inode_xattr() passes the unhashed alias to
__vfs_getxattr() and spuriously fails even though a hashed alias exists.
Trying d_find_alias(inode) first and falling back to d_find_any_alias(inode)
on NULL, as inode_doinit_with_dentry() in security/selinux/hooks.c does,
avoids this while still handling unlinked open files.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203134411.1092433-1-a.s.protopopov@gmail.com?part=2
next prev parent reply other threads:[~2026-12-03 14:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 13:44 [PATCH v1 bpf-next 0/3] bpf: Use the xattr kfuncs on six more inode hooks Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 1/3] bpf: Let sleepable LSM programs attach to " Anton Protopopov
2026-12-03 13:54 ` sashiko-bot
2026-12-03 15:34 ` Anton Protopopov
2026-12-03 18:46 ` Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 2/3] bpf: Add a bpf_get_inode_xattr kfunc Anton Protopopov
2026-12-03 14:01 ` sashiko-bot [this message]
2026-12-03 14:42 ` Anton Protopopov
2026-12-03 13:44 ` [PATCH v1 bpf-next 3/3] selftests/bpf: Test xattr kfuncs on the new sleepable inode hooks Anton Protopopov
2026-12-03 13:45 ` sashiko-bot
2026-12-03 14:25 ` Anton Protopopov
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=sashiko-outbox-247912@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.