[LTP] [PATCH 2/3] fanotify24: print range info for pre-content events

Petr Vorel pvorel@suse.cz
Thu Mar 27 11:54:34 CET 2025


Hi Amir, Jan,

> > > @@ -386,6 +388,22 @@ static void test_fanotify(unsigned int n)
> > >                               (unsigned int)event->pid,
> > >                               (unsigned int)child_pid,
> > >                               event->fd);
> > > +             } else if (event->mask & LTP_PRE_CONTENT_EVENTS) {

> > You should probably check here that the event->len is sufficiently large to
> > contain the range info. Otherwise 'range' might point beyond the end of
> > event and result in odd behavior...


> Right. feel free to use the amended version below



> >                                                                 Honza

> > > +                     if (range->hdr.info_type != FAN_EVENT_INFO_TYPE_RANGE) {
> > > +                             tst_res(TFAIL,
> > > +                                     "got event: mask=%llx pid=%u fd=%d "
> > > +                                     "(expected range info)",
> > > +                                     (unsigned long long)event->mask,
> > > +                                     (unsigned int)event->pid,
> > > +                                     event->fd);

>                         if (event->event_len < sizeof(*event) +
> sizeof(*range) ||
>                             range->hdr.info_type != FAN_EVENT_INFO_TYPE_RANGE) {
>                                 tst_res(TFAIL,
>                                         "got event: mask=%llx pid=%u
> len=%d fd=%d "
>                                         "(expected range info)",
>                                         (unsigned long long)event->mask,
>                                         (unsigned int)event->pid,
>                                         (unsigned int)event->event_len,
>                                         event->fd);

Thanks! I dared instead of copy pasting to use fan_hsm branch from your fork.
Jan, thanks for the review!
Merged the rest of the pachset.

Kind regards,
Petr

> Thanks,
> Amir.


More information about the ltp mailing list