From: Matthew Bobrowski <mbobrowski@mbobrowski.org>
To: ltp@lists.linux.it
Subject: [LTP] [RFC 2/3] syscalls/fanotify03: included execve() to generate_events() to increase test coverage
Date: Thu, 25 Oct 2018 17:39:49 +1100 [thread overview]
Message-ID: <20181025063924.GA7235@development.internal.lab> (raw)
In-Reply-To: <CAOQ4uxgmOPQz7ZCobHvWKhpyCmAjNn9_sBsuxc+cv-YvhWG9DQ@mail.gmail.com>
On Wed, Oct 24, 2018 at 08:31:22AM +0300, Amir Goldstein wrote:
> On Wed, Oct 24, 2018 at 6:28 AM Matthew Bobrowski
> <mbobrowski@mbobrowski.org> wrote:
> >
> > * Created an executable helper program 'fanotify_child' so that can be
> > used within fanotify tests
> >
> > * Defined .resource_files so that additional test resources can be
> > copied across to the tmp working directory i.e. fanotify_child
> >
> > * Updated generate_events() so that it now includes a call to execve()
> > on fanotify_child. This is so that we can increase the overall test
> > coverage by generating more events on a watched object
> >
> > * Updated each tcase events[] to accommodate for the additional events
> > generated by execve()
> >
> > Signed-off-by: Matthew Bobrowski <mbobrowski@mbobrowski.org>
> > ---
> > testcases/kernel/syscalls/fanotify/.gitignore | 1 +
> > .../kernel/syscalls/fanotify/fanotify03.c | 83 ++++++++++++-------
> > .../kernel/syscalls/fanotify/fanotify_child.c | 14 ++++
> > 3 files changed, 66 insertions(+), 32 deletions(-)
> > create mode 100644 testcases/kernel/syscalls/fanotify/fanotify_child.c
> >
> > diff --git a/testcases/kernel/syscalls/fanotify/.gitignore b/testcases/kernel/syscalls/fanotify/.gitignore
> > index c26f2bd27..af420b8b3 100644
> > --- a/testcases/kernel/syscalls/fanotify/.gitignore
> > +++ b/testcases/kernel/syscalls/fanotify/.gitignore
> > @@ -8,3 +8,4 @@
> > /fanotify08
> > /fanotify09
> > /fanotify10
> > +/fanotify_child
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
> > index cca15aa00..f9418ee6b 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify03.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
> > @@ -35,6 +35,7 @@
> >
> > #define BUF_SIZE 256
> > #define TST_TOTAL 3
> > +#define TEST_APP "fanotify_child"
> >
> > static char fname[BUF_SIZE];
> > static char buf[BUF_SIZE];
> > @@ -60,28 +61,31 @@ static struct tcase {
> > {
> > "inode mark permission events",
> > INIT_FANOTIFY_MARK_TYPE(INODE),
> > - FAN_OPEN_PERM | FAN_ACCESS_PERM, 2,
> > + FAN_OPEN_PERM | FAN_ACCESS_PERM, 3,
> > {
> > {FAN_OPEN_PERM, FAN_ALLOW},
> > - {FAN_ACCESS_PERM, FAN_DENY}
> > + {FAN_ACCESS_PERM, FAN_DENY},
> > + {FAN_OPEN_PERM, FAN_DENY}
> > }
> > },
> > {
> > "mount mark permission events",
> > INIT_FANOTIFY_MARK_TYPE(MOUNT),
> > - FAN_OPEN_PERM | FAN_ACCESS_PERM, 2,
> > + FAN_OPEN_PERM | FAN_ACCESS_PERM, 3,
> > {
> > {FAN_OPEN_PERM, FAN_ALLOW},
> > - {FAN_ACCESS_PERM, FAN_DENY}
> > + {FAN_ACCESS_PERM, FAN_DENY},
> > + {FAN_OPEN_PERM, FAN_DENY}
> > }
> > },
> > {
> > "filesystem mark permission events",
> > INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
> > - FAN_OPEN_PERM | FAN_ACCESS_PERM, 2,
> > + FAN_OPEN_PERM | FAN_ACCESS_PERM, 3,
> > {
> > {FAN_OPEN_PERM, FAN_ALLOW},
> > - {FAN_ACCESS_PERM, FAN_DENY}
> > + {FAN_ACCESS_PERM, FAN_DENY},
> > + {FAN_OPEN_PERM, FAN_DENY}
> > }
> > }
> > };
> > @@ -89,9 +93,10 @@ static struct tcase {
> > static void generate_events(void)
> > {
> > int fd;
> > + char *const argv[] = {TEST_APP, NULL};
> >
> > /*
> > - * generate sequence of events
> > + * Generate sequence of events
> > */
> > if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
> > exit(1);
> > @@ -104,6 +109,9 @@ static void generate_events(void)
> >
> > if (close(fd) == -1)
> > exit(4);
> > +
> > + if (execve(TEST_APP, argv, environ) != -1)
> > + exit(5);
> > }
> >
>
> I am a bit puzzled.
> Did you test this point in the series?
>
Yes, I did test it at this point.
> If child is denied read access then it exits before execve(), so you
> shouldn't be adding an extra OPEN event in event_set of exiting
> test cases, which DENY ACCESS??
>
I don't know whether I'm understanding you correctly, but I do believe
that it's needed based on the following facts. Within generate_events()
the system logic flow is as follows:
open(...) == -1
write(...) == -1
read(...) != -1
close(...) == -1
execve(...) == -1
Based on the sequence of system calls and comparison operators above, then
if read access is denied (FAN_DENY) then it does not exit, as that is what
is expected, so it falls through to the next set system calls. Based on
that fact, an additional event {FAN_OPEN_PERM, FAN_DENY} is needed as this
is the first event that is generated when the mask FAN_OPEN_EXEC_PERM
hasn't been provided as a mask.
--
Matthew Bobrowski <mbobrowski@mbobrowski.org>
next prev parent reply other threads:[~2018-10-25 6:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-24 3:26 [LTP] [RFC 0/3] syscalls/fanotify03: add support and tests for new FAN_OPEN_EXEC_PERM flag Matthew Bobrowski
2018-10-24 3:27 ` [LTP] [RFC 1/3] syscalls/fanotify03: defined additional tcase members to support more tcase control Matthew Bobrowski
2018-10-24 5:23 ` Amir Goldstein
2018-10-25 6:19 ` Matthew Bobrowski
2018-10-24 3:27 ` [LTP] [RFC 2/3] syscalls/fanotify03: included execve() to generate_events() to increase test coverage Matthew Bobrowski
2018-10-24 5:31 ` Amir Goldstein
2018-10-25 6:39 ` Matthew Bobrowski [this message]
2018-10-25 6:46 ` Amir Goldstein
2018-10-24 3:28 ` [LTP] [RFC 3/3] syscalls/fanotify03: add FAN_OPEN_EXEC_PERM tcase support Matthew Bobrowski
2018-10-24 5:56 ` Amir Goldstein
2018-10-25 6:39 ` Matthew Bobrowski
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=20181025063924.GA7235@development.internal.lab \
--to=mbobrowski@mbobrowski.org \
--cc=ltp@lists.linux.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.