From: Song Liu <songliubraving@meta.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Song Liu <song@kernel.org>, bpf <bpf@vger.kernel.org>,
Linux-Fsdevel <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kernel Team <kernel-team@meta.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
KP Singh <kpsingh@kernel.org>,
Matt Bobrowski <mattbobrowski@google.com>,
Amir Goldstein <amir73il@gmail.com>,
"repnop@google.com" <repnop@google.com>,
Josef Bacik <josef@toxicpanda.com>
Subject: Re: [RFC bpf-next fanotify 2/5] samples/fanotify: Add a sample fanotify fastpath handler
Date: Wed, 30 Oct 2024 20:30:30 +0000 [thread overview]
Message-ID: <D21DC5F6-A63A-4D94-A73D-408F640FD075@fb.com> (raw)
In-Reply-To: <5b8318018dd316f618eea059f610579a205c05db.camel@kernel.org>
Hi Jeff,
Thanks for your review!
I will update 1/2 based on the feedback. (Replying here to save everyone
an email..)
> On Oct 30, 2024, at 6:03 AM, Jeff Layton <jlayton@kernel.org> wrote:
[...]
>> +
>> +static int sample_fp_handler(struct fsnotify_group *group,
>> + struct fanotify_fastpath_hook *fp_hook,
>> + struct fanotify_fastpath_event *fp_event)
>> +{
>> + const struct qstr *file_name = fp_event->file_name;
>> + struct sample_fp_data *fp_data;
>> + struct prefix_item *item;
>> +
>> + if (!file_name)
>> + return FAN_FP_RET_SEND_TO_USERSPACE;
>> + fp_data = fp_hook->data;
>> +
>> + list_for_each_entry(item, &fp_data->item_list, list) {
>> + if (strstr(file_name->name, item->prefix) == (char *)file_name->name)
>> + return FAN_FP_RET_SKIP_EVENT;
>> + }
>> +
>> + return FAN_FP_RET_SEND_TO_USERSPACE;
>> +}
>
> The sample is a little underwhelming and everyone hates string parsing
> in the kernel ;). It'd be nice to see a more real-world use-case for
> this.
>
> Could this be used to implement subtree filtering? I guess you'd have
> to walk back up the directory tree and see whether it had a given
> ancestor?
If the subtree is all in the same file system, we can attach fanotify to
the whole file system, and then use some dget_parent() and follow_up()
to walk up the directory tree in the fastpath handler. However, if there
are other mount points in the subtree, we will need more logic to handle
these mount points.
@Christian, I would like to know your thoughts on this (walking up the
directory tree in fanotify fastpath handler). It can be expensive for
very very deep subtree.
How should we pass in the subtree? I guess we can just use full path in
a string as the argument.
Thanks,
Song
next prev parent reply other threads:[~2024-10-30 20:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 23:12 [RFC bpf-next fanotify 0/5] Fanotify " Song Liu
2024-10-29 23:12 ` [RFC bpf-next fanotify 1/5] fanotify: Introduce fanotify " Song Liu
2024-10-30 12:45 ` Jeff Layton
2024-11-07 10:48 ` Jan Kara
2024-11-07 19:13 ` Song Liu
2024-11-11 14:09 ` Jan Kara
2024-10-29 23:12 ` [RFC bpf-next fanotify 2/5] samples/fanotify: Add a sample " Song Liu
2024-10-30 0:11 ` Al Viro
2024-10-30 1:48 ` Al Viro
2024-10-30 2:07 ` Song Liu
2024-10-30 2:35 ` Song Liu
2024-10-30 13:03 ` Jeff Layton
2024-10-30 20:30 ` Song Liu [this message]
2024-10-31 0:23 ` Jeff Layton
2024-10-31 1:52 ` Song Liu
2024-11-06 19:40 ` Amir Goldstein
2024-11-06 22:10 ` Song Liu
2024-11-07 10:41 ` Jan Kara
2024-11-07 19:39 ` Song Liu
2024-11-07 11:19 ` Amir Goldstein
2024-11-07 19:39 ` Song Liu
2024-10-29 23:12 ` [RFC bpf-next fanotify 3/5] bpf: Make bpf inode storage available to tracing programs Song Liu
2024-10-29 23:12 ` [RFC bpf-next fanotify 4/5] fanotify: Enable bpf based fanotify fastpath handler Song Liu
2024-10-29 23:12 ` [RFC bpf-next fanotify 5/5] selftests/bpf: Add test for BPF " Song Liu
2024-11-07 11:10 ` Amir Goldstein
2024-11-07 19:53 ` Song Liu
2024-11-07 20:33 ` Amir Goldstein
2024-11-07 20:48 ` Song Liu
2024-11-08 8:18 ` Amir Goldstein
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=D21DC5F6-A63A-4D94-A73D-408F640FD075@fb.com \
--to=songliubraving@meta.com \
--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=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=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--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®