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

From: Jan Kara
Date: Thu Nov 28 2024 - 11:37:24 EST


On Sun 24-11-24 07:25:20, Amir Goldstein wrote:
> On Sat, Nov 23, 2024 at 12:00 AM Song Liu <song@xxxxxxxxxx> 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@xxxxxxxx>
SUSE Labs, CR