Re: [PATCH v3 fanotify 1/2] fanotify: Introduce fanotify filter

Jan Kara
2024-11-28T16:37:12Z

On Sun 24-11-24 07:25:20, Amir Goldstein wrote:
> On Sat, Nov 23, 2024 at 12:00 AM Song Liu <song@kernel.org> wrote:
...
> > @@ -921,6 +924,39 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask,
> > pr_debug("%s: group=%p mask=%x report_mask=%x\n", __func__,
> > group, mask, match_mask);
> >
> > + if (FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS))
> > + fsid = fanotify_get_fsid(iter_info);
> > +
> > +#ifdef CONFIG_FANOTIFY_FILTER
> > + filter_hook = srcu_dereference(group->fanotify_data.filter_hook, &fsnotify_mark_srcu);
>
> Do we actually need the sleeping rcu protection for calling the hook?
> Can regular rcu read side be nested inside srcu read side?

Nesting rcu inside srcu is fine.

> Jan,
>
> I don't remember why srcu is needed since we are not holding it
> when waiting for userspace anymore?

You need srcu to access marks or notification group unless you grab a
reference to them (which is what waiting for permission event reply code
does).

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR