From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Ibrahim Jirdeh <ibrahimjirdeh@meta.com>,
josef@toxicpanda.com, lesha@meta.com,
linux-fsdevel@vger.kernel.org, sargun@meta.com
Subject: Re: [PATCH] fanotify: support custom default close response
Date: Mon, 30 Jun 2025 17:56:00 +0200 [thread overview]
Message-ID: <CAOQ4uxirFm8_U7z4ke5Z4iNbatSbXoz1YK_2eGL=1JQQOtt75Q@mail.gmail.com> (raw)
In-Reply-To: <tq6g6bkzojggcwu3bxkj57ongbvyynykylrtmlphqa7g7wb6f2@7gid5uogbfc4>
On Mon, Jun 30, 2025 at 5:36 PM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 24-06-25 08:30:03, Amir Goldstein wrote:
> > On Mon, Jun 23, 2025 at 9:26 PM Ibrahim Jirdeh <ibrahimjirdeh@meta.com> wrote:
> > >
> > > Currently the default response for pending events is FAN_ALLOW.
> > > This makes default close response configurable. The main goal
> > > of these changes would be to provide better handling for pending
> > > events for lazy file loading use cases which may back fanotify
> > > events by a long-lived daemon. For earlier discussion see:
> > > https://lore.kernel.org/linux-fsdevel/6za2mngeqslmqjg3icoubz37hbbxi6bi44canfsg2aajgkialt@c3ujlrjzkppr/
> >
> > These lore links are typically placed at the commit message tail block
> > if related to a suggestion you would typically use:
> >
> > Suggested-by: Amir Goldstein <amir73il@gmail.com>
> > Link: https://lore.kernel.org/linux-fsdevel/CAOQ4uxi6PvAcT1vL0d0e+7YjvkfU-kwFVVMAN-tc-FKXe1wtSg@mail.gmail.com/
> > Signed-off-by: Ibrahim Jirdeh <ibrahimjirdeh@meta.com>
> >
> > This way reviewers whose response is "what a terrible idea!" can
> > point their arrows at me instead of you ;)
> >
> > Note that this is a more accurate link to the message where the default
> > response API was proposed, so readers won't need to sift through
> > this long thread to find the reference.
>
> I've reread that thread to remember how this is supposed to be used. After
> thinking about it now maybe we could just modify how pending fanotify
> events behave in case of group destruction? Instead of setting FAN_ALLOW in
> fanotify_release() we'd set a special event state that will make fanotify
> group iteration code bubble up back to fsnotify() and restart the event
> generation loop there?
>
> In the usual case this would behave the same way as setting FAN_ALLOW (just
> in case of multiple permission event watchers some will get the event two
> times which shouldn't matter). In case of careful design with fd store
> etc., the daemon can setup the new notification group as needed and then
> close the fd from the old notification group at which point it would
> receive all the pending events in the new group. I can even see us adding
> ioctl to the fanotify group which when called will result in the same
> behavior (i.e., all pending permission events will get the "retry"
> response). That way the new daemon could just take the old fd from the fd
> store and call this ioctl to receive all the pending events again.
>
> No need for the new default response. We probably need to provide a group
> feature flag for this so that userspace can safely query kernel support for
> this behavior but otherwise even that wouldn't be really needed.
>
> What do you guys think?
With proper handover I am not sure why this is needed, because:
- new group gets fd from store and signals old group
- old group does not take any new event, completes in-flight events,
signals back new group and exists
- new group starts processing events
- so why do we need a complex mechanism in kernel to do what can easily
be done in usersapce?
Also, regardless I think that we need the default response, because:
- groups starts, set default response to DENY and handsover fd to store
- if group crashes unexpectedly, access to all files is denied, which is
exactly what we needed to do with the "moderated" mount
- it is similar to access to FUSE mount when server is down
For a requirement that non-populated content MUST NOT be
accessed, the default response is a very easy way to achieve it.
Thanks,
Amir.
>
> Honza
>
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
next prev parent reply other threads:[~2025-06-30 15:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 19:25 [PATCH] fanotify: support custom default close response Ibrahim Jirdeh
2025-06-24 6:30 ` Amir Goldstein
2025-06-26 21:19 ` Ibrahim Jirdeh
2025-06-30 15:36 ` Jan Kara
2025-06-30 15:56 ` Amir Goldstein [this message]
2025-07-02 16:15 ` Jan Kara
2025-07-02 16:56 ` Amir Goldstein
2025-07-03 7:08 ` Ibrahim Jirdeh
2025-07-03 8:27 ` Amir Goldstein
2025-07-03 14:43 ` Jan Kara
2025-07-03 16:09 ` Amir Goldstein
2025-07-11 22:30 ` Ibrahim Jirdeh
2025-07-12 8:08 ` Amir Goldstein
2025-07-14 7:01 ` Ibrahim Jirdeh
2025-07-14 15:59 ` Amir Goldstein
2025-07-14 16:57 ` Ibrahim Jirdeh
2025-07-14 17:25 ` Jan Kara
2025-07-14 19:59 ` Amir Goldstein
2025-07-15 12:11 ` Jan Kara
2025-07-15 14:50 ` Amir Goldstein
2025-07-16 8:55 ` Jan Kara
2025-07-16 10:31 ` Amir Goldstein
2025-07-21 12:56 ` Jan Kara
2025-06-24 11:11 ` kernel test robot
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='CAOQ4uxirFm8_U7z4ke5Z4iNbatSbXoz1YK_2eGL=1JQQOtt75Q@mail.gmail.com' \
--to=amir73il@gmail.com \
--cc=ibrahimjirdeh@meta.com \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=lesha@meta.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sargun@meta.com \
/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;
as well as URLs for NNTP newsgroup(s).