linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: Ignore mask handling in fanotify_group_event_mask()
Date: Thu, 21 May 2020 21:10:36 +0300	[thread overview]
Message-ID: <CAOQ4uxirUfcpOdxFG9TAHUFSz+A5FMJdT=y4UKwpFUVov43nSA@mail.gmail.com> (raw)
In-Reply-To: <20200521162443.GA26052@quack2.suse.cz>

On Thu, May 21, 2020 at 7:24 PM Jan Kara <jack@suse.cz> wrote:
>
> Hello Amir!
>
> I was looking into backporting of commit 55bf882c7f13dd "fanotify: fix
> merging marks masks with FAN_ONDIR" and realized one oddity in
> fanotify_group_event_mask(). The thing is: Even if the mark mask is such
> that current event shouldn't trigger on the mark, we still have to take
> mark's ignore mask into account.
>
> The most realistic example that would demonstrate the issue that comes to my
> mind is:
>
> mount mark watching for FAN_OPEN | FAN_ONDIR.
> inode mark on a directory with mask == 0 and ignore_mask == FAN_OPEN.
>
> I'd expect the group will not get any event for opening the dir but the
> code in fanotify_group_event_mask() would not prevent event generation. Now
> as I've tested the event currently actually does not get generated because
> there is a rough test in send_to_group() that actually finds out that there
> shouldn't be anything to report and so fanotify handler is actually never
> called in such case. But I don't think it's good to have an inconsistent
> test in fanotify_group_event_mask(). What do you think?
>

I agree this is not perfect.
I think that moving the marks_ignored_mask line
To the top of the foreach loop should fix the broken logic.
It will not make the code any less complicated to follow though.
Perhaps with a comment along the lines of:

             /* Ignore mask is applied regardless of ISDIR and ON_CHILD flags */
             marks_ignored_mask |= mark->ignored_mask;

Now is there a real bug here?
Probably not because send_to_group() always applied an ignore mask
that is greater or equal to that of fanotify_group_event_mask().

should fanotify_group_event_mask() re-apply the same generic logic
already applied in send_to_group()? Maybe there is no point.
After all, fanotify_group_event_mask() also does not handle
FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY, so the
assumption that send_to_group() is doing some of the logic is
already there.

Not sure if I helped answering your question.

Thanks,
Amir.

  reply	other threads:[~2020-05-21 18:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 16:24 Ignore mask handling in fanotify_group_event_mask() Jan Kara
2020-05-21 18:10 ` Amir Goldstein [this message]
2020-05-23 17:14   ` Amir Goldstein
2020-05-25  7:23     ` Jan Kara
2020-05-25  8:52       ` Amir Goldstein
2020-05-25 12:42         ` Jan Kara

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='CAOQ4uxirUfcpOdxFG9TAHUFSz+A5FMJdT=y4UKwpFUVov43nSA@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).