From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: Mete Durlu <meted@linux.ibm.com>, Jan Kara <jack@suse.cz>,
ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 3/3] fanotify14: fix anonymous pipe testcases
Date: Tue, 26 Mar 2024 11:41:13 +0100 [thread overview]
Message-ID: <ZgKmScOuuiobsEdj@yuki> (raw)
In-Reply-To: <20240320102204.475230-4-pvorel@suse.cz>
Hi!
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Co-developed-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> changes v1->v2:
> * Do not include library header in fanotify14 (not needed)
>
> .../kernel/syscalls/fanotify/fanotify14.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
> index d02d81495..82725f317 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify14.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
> @@ -47,6 +47,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 {
> @@ -283,9 +284,18 @@ static void do_test(unsigned int number)
>
> 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 like the test library is not flexible enough to make this
simpler. Maybe having the ARRAY_SIZE() in the TST_EXP_FAIL_ARR wasn't a
good idea after all. Or maybe we just need TST_EXP_FAIL_ARR2() that
would take the array size explicitly, then we could do:
const int exp_errs[] = {tc->expected_errno, EACESS}
TST_EXP_FAIL_ARR2(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
tc->mask.flags, dirfd, path), exp_errs,
se_enforcing ? 1 : 2);
> /*
> * ENOTDIR are errors for events/flags not allowed on a non-dir inode.
> @@ -334,6 +344,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 = tst_selinux_enforcing();
> }
>
> static void do_cleanup(void)
> --
> 2.43.0
>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-03-26 10:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 10:22 [LTP] [PATCH v2 0/3] fanotify14 on SELinux fix + lib source merge Petr Vorel
2024-03-20 10:22 ` [LTP] [PATCH v2 1/3] lib: Merge security related sources Petr Vorel
2024-03-26 10:24 ` Cyril Hrubis
2024-03-26 11:38 ` Petr Vorel
2024-03-26 11:44 ` Petr Vorel
2024-03-20 10:22 ` [LTP] [PATCH v2 2/3] lib: Add tst_selinux_enforcing() Petr Vorel
2024-03-26 10:26 ` Cyril Hrubis
2024-03-20 10:22 ` [LTP] [PATCH v2 3/3] fanotify14: fix anonymous pipe testcases Petr Vorel
2024-03-26 10:41 ` Cyril Hrubis [this message]
2024-03-26 11:42 ` Petr Vorel
2024-03-26 11:53 ` Petr Vorel
2024-03-26 12:41 ` Cyril Hrubis
2024-03-26 14:30 ` Petr Vorel
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=ZgKmScOuuiobsEdj@yuki \
--to=chrubis@suse.cz \
--cc=jack@suse.cz \
--cc=ltp@lists.linux.it \
--cc=meted@linux.ibm.com \
--cc=pvorel@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox