From: Miklos Szeredi <miklos@szeredi.hu>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Miklos Szeredi <mszeredi@redhat.com>,
linux-fsdevel@vger.kernel.org, Ian Kent <raven@themaw.net>,
Eric Sandeen <sandeen@redhat.com>
Subject: Re: [RFC PATCH] fanotify: add watchdog for permission events
Date: Tue, 9 Sep 2025 16:34:27 +0200 [thread overview]
Message-ID: <CAJfpeguWVBKk8QcFChAAbdwpJK7iRqaEnW2gtHBTvR45O3mveg@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxi6GjWynhY5A_TxRMzX84PJp-KsHq=NOK=wSzbqqb_Ejg@mail.gmail.com>
On Fri, 4 Jul 2025 at 12:22, Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Fri, Jul 4, 2025 at 11:56 AM Jan Kara <jack@suse.cz> wrote:
> >
> > On Thu 03-07-25 15:05:37, Miklos Szeredi wrote:
> > > This is to make it easier to debug issues with AV software, which time and
> > > again deadlocks with no indication of where the issue comes from, and the
> > > kernel being blamed for the deadlock. Then we need to analyze dumps to
> > > prove that the kernel is not in fact at fault.
> >
> > I share the pain. I had to do quite some of these analyses myself :).
> > Luckily our support guys have trained to do the analysis themselves over
> > the years so it rarely reaches my table anymore.
> >
> > > With this patch a warning is printed when permission event is received by
> > > userspace but not answered for more than 20 seconds.
> > >
> > > The timeout is very coarse (20-40s) but I guess it's good enough for the
> > > purpose.
> >
> > I'm not opposed to the idea (although I agree with Amir that it should be
> > tunable - we have /proc/sys/fs/fanotify/ for similar things). Just I'm not
> > sure it will have the desired deterring effect for fanotify users wanting
> > to blame the kernel. What usually convinces them is showing where their
> > tasks supposed to write reply to permission event (i.e., those that have
> > corresponding event fds in their fdtable) are blocked and hence they cannot
> > reply. But with some education I suppose it can work. After all the
> > messages you print contain the task responsible to answer which is already
> > helpful.
> >
> > > +config FANOTIFY_PERM_WATCHDOG
> > > + bool "fanotify permission event watchdog"
> > > + depends on FANOTIFY_ACCESS_PERMISSIONS
> > > + default n
> >
> > As Amir wrote, I don't think we need a kconfig for this, configuration
> > through /proc/sys/fs/fanotify/ will be much more flexible.
> >
> > > diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
> > > index b44e70e44be6..8b60fbb9594f 100644
> > > --- a/fs/notify/fanotify/fanotify.h
> > > +++ b/fs/notify/fanotify/fanotify.h
> > > @@ -438,10 +438,14 @@ FANOTIFY_ME(struct fanotify_event *event)
> > > struct fanotify_perm_event {
> > > struct fanotify_event fae;
> > > struct path path;
> > > - const loff_t *ppos; /* optional file range info */
> > > + union {
> > > + const loff_t *ppos; /* optional file range info */
> > > + pid_t pid; /* pid of task processing the event */
> > > + };
> >
> > I think Amir complained about the generic 'pid' name already. Maybe
> > processing_pid? Also I'd just get rid of the union. We don't have *that*
> > many permission events that 4 bytes would matter and possible interactions
> > between pre-content events and this watchdog using the same space make me
> > somewhat uneasy.
Amir, Jan, thanks for the reviews.
I forgot about this, but now dug it out again and hopefully addressed
all comments in v2:
https://lore.kernel.org/linux-fsdevel/20250909143053.112171-1-mszeredi@redhat.com/
Thanks,
Miklos
prev parent reply other threads:[~2025-09-09 14:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 13:05 [RFC PATCH] fanotify: add watchdog for permission events Miklos Szeredi
2025-07-03 15:42 ` Amir Goldstein
2025-07-03 16:22 ` Miklos Szeredi
2025-07-04 9:56 ` Jan Kara
2025-07-04 10:22 ` Amir Goldstein
2025-09-09 14:34 ` Miklos Szeredi [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=CAJfpeguWVBKk8QcFChAAbdwpJK7iRqaEnW2gtHBTvR45O3mveg@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--cc=sandeen@redhat.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).