Re: [PATCH bpf-next 1/3] bpf: Add bpf_path_getattr()
From: bot+bpf-ci
Date: Thu Oct 29 2026 - 07:01:41 EST
> bpf: Add bpf_path_getattr()
TL;DR: Design nit only: bpf_path_getattr() near-copies the mount ID and
mount-root handling from vfs_statx_path(), so the two may drift; suggests a
shared helper in fs/stat.c and avoiding VFS-private headers.
> diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
> index 35ccd98a4de6..95d7b0de2453 100644
> --- a/fs/bpf_fs_kfuncs.c
> +++ b/fs/bpf_fs_kfuncs.c
[ ... ]
> @@ -1,23 +1,127 @@
> #include <linux/xattr.h>
>
> +#include "internal.h"
> +#include "mount.h"
> +
[ ... ]
> + if (request_mask & STATX_MNT_ID_UNIQUE) {
> + out->mnt_id = real_mount(path->mnt)->mnt_id_unique;
> + stat.result_mask |= STATX_MNT_ID_UNIQUE;
> + } else {
> + out->mnt_id = real_mount(path->mnt)->mnt_id;
> + stat.result_mask |= STATX_MNT_ID;
> + }
> + out->size = stat.size;
> + out->attributes = stat.attributes & ~STATX_ATTR_CHANGE_MONOTONIC;
> + if (path_mounted(path))
> + out->attributes |= STATX_ATTR_MOUNT_ROOT;
> + out->attributes_mask = stat.attributes_mask | STATX_ATTR_MOUNT_ROOT;
this isn't a bug, but could the mount ID and STATX_ATTR_MOUNT_ROOT handling
be shared with vfs_statx_path() through a small helper in fs/stat.c?
This block looks like a near-verbatim copy of the post-getattr part of
vfs_statx_path(), plus the STATX_ATTR_CHANGE_MONOTONIC masking from
cp_statx().
The kernel-doc says 'Results follow statx(2)', so a later change to
vfs_statx_path() (a new mount attribute, a different mount ID rule) would
have to be mirrored here by hand.
The copy is also why this file now includes the VFS-private headers:
#include "internal.h"
#include "mount.h"
just to reach real_mount() and path_mounted(). A helper in fs/stat.c that
applies the mount ID and mount-root fields to a kstat would keep the two
in sync and keep struct mount inside fs/.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/40857522501