All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Mete Durlu <meted@linux.ibm.com>, Jan Kara <jack@suse.cz>,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/1] fanotify14: fix anonymous pipe testcases
Date: Wed, 13 Mar 2024 08:26:23 +0100	[thread overview]
Message-ID: <20240313072623.GA519991@pevik> (raw)
In-Reply-To: <CAOQ4uxgPK=t25OvBcevkQseFEr9S6p7PtU35p8T+snzqzN+ndg@mail.gmail.com>

Hi all,
...

> >  static void do_test(unsigned int number)
> >  {
> >         struct test_case_t *tc = &test_cases[number];
> > @@ -275,17 +290,28 @@ static void do_test(unsigned int number)
> >         /* Set mark on non-dir only when expecting error ENOTDIR */
> >         const char *path = tc->expected_errno == ENOTDIR ? FILE1 : MNTPOINT;
> >         int dirfd = AT_FDCWD;
> > +       int se_enforcing = 0;

> >         if (tc->pfd) {
> >                 dirfd = tc->pfd[0];
> >                 path = NULL;
> > +               se_enforcing = is_selinux_enforcing();
nit: this check should be in the setup function to be done only once.
(by default it's done twice, because we have 2 testcases with pfd, we support
-iN parameter, thus it's actually 2*N.). I'll fix it before merge.
> >         }

> >         tst_res(TINFO, "Testing %s with %s",
> >                 tc->mark.desc, tc->mask.desc);
> > -       TST_EXP_FD_OR_FAIL(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
> > -                                        tc->mask.flags, dirfd, path),
> > -                                        tc->expected_errno);
> > +
> > +       if (tc->pfd && se_enforcing) {
> > +               const int exp_errs[] = {tc->expected_errno, EACCES};
> > +
> > +               TST_EXP_FAIL_ARR(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
> > +                                tc->mask.flags, dirfd, path),
> > +                                exp_errs);
> > +       } else {
> > +               TST_EXP_FAIL(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
> > +                                                tc->mask.flags, dirfd, path),
> > +                                                tc->expected_errno);
> > +       }


> This looks fine to me, but on second thought I am not sure how important
> it is to special case se_enforcing.
> We could probably always check for either error value.

I don't mind explicitly testing EACCES with SELinux. @Jan WDYT?

With a diff below (I can change it before merge + I would do the following work
to integrate this into the LTP C API):
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

diff --git testcases/kernel/syscalls/fanotify/fanotify14.c testcases/kernel/syscalls/fanotify/fanotify14.c
index 52c327dff..89d59c8b2 100644
--- testcases/kernel/syscalls/fanotify/fanotify14.c
+++ testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -49,6 +49,7 @@ static int pipes[2] = {-1, -1};
 static int fanotify_fd;
 static int ignore_mark_unsupported;
 static int filesystem_mark_unsupported;
+static int se_enforcing;
 static unsigned int supported_init_flags;
 
 struct test_case_flags_t {
@@ -290,12 +291,10 @@ static void do_test(unsigned int number)
 	/* Set mark on non-dir only when expecting error ENOTDIR */
 	const char *path = tc->expected_errno == ENOTDIR ? FILE1 : MNTPOINT;
 	int dirfd = AT_FDCWD;
-	int se_enforcing = 0;
 
 	if (tc->pfd) {
 		dirfd = tc->pfd[0];
 		path = NULL;
-		se_enforcing = is_selinux_enforcing();
 	}
 
 	tst_res(TINFO, "Testing %s with %s",
@@ -360,6 +359,8 @@ static void do_setup(void)
 	SAFE_FILE_PRINTF(FILE1, "0");
 	/* Create anonymous pipes to place marks on */
 	SAFE_PIPE2(pipes, O_CLOEXEC);
+
+	se_enforcing = is_selinux_enforcing();
 }
 
 static void do_cleanup(void)
> Let's see what Jan and Petr think.

> Thanks,
> Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-03-13  7:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 12:08 [LTP] [PATCH v2 0/1] fix fanotify anonymous pipe testcases Mete Durlu
2024-03-12 12:08 ` [LTP] [PATCH v2 1/1] fanotify14: fix " Mete Durlu
2024-03-12 15:00   ` Amir Goldstein
2024-03-13  7:26     ` Petr Vorel [this message]
2024-03-13 16:47       ` Jan Kara
2024-03-14  8:34       ` Mete Durlu

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=20240313072623.GA519991@pevik \
    --to=pvorel@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=meted@linux.ibm.com \
    /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.