From: Tingmao Wang <m@maowtm.org>
To: "Song Liu" <song@kernel.org>, "Mickaël Salaün" <mic@digikod.net>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>
Cc: Tingmao Wang <m@maowtm.org>,
amir73il@gmail.com, andrii@kernel.org, ast@kernel.org,
bpf@vger.kernel.org, daniel@iogearbox.net, eddyz87@gmail.com,
gnoack@google.com, jack@suse.cz, jlayton@kernel.org,
josef@toxicpanda.com, kernel-team@meta.com, kpsingh@kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, martin.lau@linux.dev,
mattbobrowski@google.com, repnop@google.com
Subject: Re: [PATCH v3 bpf-next 0/5] bpf path iterator
Date: Sun, 8 Jun 2025 18:32:56 +0100 [thread overview]
Message-ID: <20250608173437.73874-1-m@maowtm.org> (raw)
In-Reply-To: <dbc7ee0f1f483b7bc2ec9757672a38d99015e9ae.1749402769@maowtm.org>
Update bpf_fs_kfuncs to match path_walk_parent changes.
It compiles, but I've not tested this yet.
Signed-off-by: Tingmao Wang <m@maowtm.org>
---
fs/bpf_fs_kfuncs.c | 55 +++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index 8c618154df0a..6599342dd0de 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -327,23 +327,18 @@ __bpf_kfunc_end_defs();
/* open-coded path iterator */
struct bpf_iter_path {
- __u64 __opaque[2];
-} __aligned(8);
-
-struct bpf_iter_path_kern {
- struct path path;
+ __u64 __opaque[sizeof(struct parent_iterator) / sizeof(__u64)];
} __aligned(8);
__bpf_kfunc_start_defs();
-__bpf_kfunc int bpf_iter_path_new(struct bpf_iter_path *it,
- struct path *start,
+__bpf_kfunc int bpf_iter_path_new(struct bpf_iter_path *it, struct path *start,
__u64 flags)
{
- struct bpf_iter_path_kern *kit = (void *)it;
+ struct parent_iterator *pit = (void *)it;
- BUILD_BUG_ON(sizeof(*kit) > sizeof(*it));
- BUILD_BUG_ON(__alignof__(*kit) != __alignof__(*it));
+ BUILD_BUG_ON(sizeof(*pit) > sizeof(*it));
+ BUILD_BUG_ON(__alignof__(*pit) != __alignof__(*it));
if (flags) {
/*
@@ -351,45 +346,51 @@ __bpf_kfunc int bpf_iter_path_new(struct bpf_iter_path *it,
* kit->path so that it be passed to path_put() safely.
* Note: path_put() is no-op for zero'ed path.
*/
- memset(&kit->path, 0, sizeof(struct path));
+ memset(pit, 0, sizeof(*pit));
return -EINVAL;
}
- kit->path = *start;
- path_get(&kit->path);
-
- return 0;
-}
-
-__bpf_kfunc struct path *bpf_iter_path_next(struct bpf_iter_path *it)
-{
- struct bpf_iter_path_kern *kit = (void *)it;
- struct path root = {};
-
/*
- * "root" is zero'ed. Therefore, unless the loop is explicitly
+ * "root" is NULL. Therefore, unless the loop is explicitly
* terminated, bpf_iter_path_next() will continue looping until
* we've reached the global root of the VFS.
*
* If a root of walk is needed, the user can check "path" against
* that root on each iteration.
*/
- if (!path_walk_parent(&kit->path, &root)) {
+ path_walk_parent_start(pit, start, NULL, false);
+
+ return 0;
+}
+
+__bpf_kfunc struct path *bpf_iter_path_next(struct bpf_iter_path *it)
+{
+ struct parent_iterator *pit = (void *)it;
+ struct path p;
+
+ switch (path_walk_parent(pit, &p)) {
+ case PATH_WALK_PARENT_UPDATED:
+ return &pit->path;
+ case PATH_WALK_PARENT_ALREADY_ROOT:
/*
* Return NULL, but keep valid kit->path. _destroy() will
* always path_put(&kit->path).
*/
return NULL;
+ default:
+ WARN_ONCE(
+ 1,
+ "did not expect any other return from path_walk_parent");
}
- return &kit->path;
+ return &pit->path;
}
__bpf_kfunc void bpf_iter_path_destroy(struct bpf_iter_path *it)
{
- struct bpf_iter_path_kern *kit = (void *)it;
+ struct parent_iterator *pit = (void *)it;
- path_put(&kit->path);
+ path_walk_parent_end(pit);
}
__bpf_kfunc_end_defs();
--
2.49.0
prev parent reply other threads:[~2025-06-08 17:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 21:30 Song Liu
2025-06-06 21:30 ` [PATCH v3 bpf-next 1/5] namei: Introduce new helper function path_walk_parent() Song Liu
2025-06-10 17:18 ` Mickaël Salaün
2025-06-10 17:26 ` Song Liu
2025-06-10 22:26 ` Tingmao Wang
2025-06-10 22:34 ` Tingmao Wang
2025-06-10 23:08 ` Song Liu
2025-06-11 0:23 ` Tingmao Wang
2025-06-10 23:34 ` NeilBrown
2025-06-11 0:56 ` Song Liu
2025-06-11 15:42 ` Mickaël Salaün
2025-06-11 16:31 ` Song Liu
2025-06-11 17:50 ` Tingmao Wang
2025-06-11 18:08 ` Song Liu
2025-06-12 9:01 ` Jan Kara
2025-06-12 9:49 ` Jan Kara
2025-06-12 12:31 ` Christian Brauner
2025-06-16 0:24 ` Ref-less parent walk from Landlock (was: Re: [PATCH v3 bpf-next 1/5] namei: Introduce new helper function path_walk_parent()) Tingmao Wang
2025-06-17 6:20 ` Song Liu
2025-06-06 21:30 ` [PATCH v3 bpf-next 2/5] landlock: Use path_walk_parent() Song Liu
2025-06-08 18:45 ` Tingmao Wang
2025-06-06 21:30 ` [PATCH v3 bpf-next 3/5] bpf: Introduce path iterator Song Liu
2025-06-06 21:30 ` [PATCH v3 bpf-next 4/5] selftests/bpf: Add tests for bpf " Song Liu
2025-06-06 21:30 ` [PATCH v3 bpf-next 5/5] selftests/bpf: Path walk test Song Liu
2025-06-08 17:32 ` [PATCH v3 bpf-next 0/5] bpf path iterator Tingmao Wang
2025-06-09 6:23 ` Song Liu
2025-06-09 8:08 ` Tingmao Wang
2025-06-11 11:36 ` Christian Brauner
2025-06-11 15:39 ` Mickaël Salaün
2025-06-08 17:32 ` Tingmao Wang [this message]
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=20250608173437.73874-1-m@maowtm.org \
--to=m@maowtm.org \
--cc=amir73il@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--cc=mic@digikod.net \
--cc=repnop@google.com \
--cc=song@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®