[LTP] [PATCH v3 3/5] fanotify: Introduce SAFE_FANOTIFY_MARK() macro

Amir Goldstein
2020-11-25T15:41:33Z

On Wed, Nov 25, 2020 at 4:16 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
> > > > @@ -101,19 +101,8 @@ static void test_fanotify(unsigned int n)
> > > > "failed", tc->init_flags);
> > > > }
>
> > > > - if (fanotify_mark(fd_notify, FAN_MARK_ADD | mark->flag,
> > > > - FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN,
> > > > - AT_FDCWD, fname) < 0) {
> > > > - if (errno == EINVAL && mark->flag == FAN_MARK_FILESYSTEM) {
> > > > - tst_res(TCONF,
> > > > - "FAN_MARK_FILESYSTEM not supported in kernel?");
> > > > - return;
> > > > - }
>
> > > Here we had tst_res(TCONF, ...) followed by a return but we will can
> > > tst_brk() after the change. I guess that we may skip part of the test on
> > > older kernels with that change.
>
>
> > That's not good. I missed that in my review.
> > There are many tests where only the FAN_MARK_FILESYSTEM
> > test cases are expected to result in TCONF, but the rest of the test
> > cases should run.
>
> I'm not sure if I understand you. Is my approach correct here?
>

I think it is not correct, but please tell me what the outcome is when running
test fanotify01 on kernel < v5.1.

The expected outcome is that the 2 first test cases PASS and the rest of the
test cases are skipped (TCONF).

Now what happens if you reorder the 2 first test cases to be last in the tcases
array? Will they run@all or will tst_brk(TCONF, ... in safe_fanotify_mark()
cause the rest of the test cases not to run?

I'm just not sure how tst_brk() behaves with test cases, but I have a feeling
that it won't result in the expected outcome?

Thanks,
Amir.