($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: Jan Kara <jack@suse.cz>, Mete Durlu <meted@linux.ibm.com>,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 2/2] fanotify14: fix anonymous pipe testcases
Date: Wed, 20 Mar 2024 13:11:08 +0100	[thread overview]
Message-ID: <20240320121108.5fqgjdinkrhzkuz5@quack3> (raw)
In-Reply-To: <20240320063218.449072-2-pvorel@suse.cz>

On Wed 20-03-24 07:32:17, Petr Vorel wrote:
> From: Mete Durlu <meted@linux.ibm.com>
> 
> When SElinux is in enforcing state and SEpolicies disallow anonymous
> pipe usage with fanotify_mark(), related fanotify14 testcases fail with
> EACCES instead of EINVAL. Accept both errnos when SElinux is in
> enforcing state to correctly evaluate test results.
> 
> Replace TST_EXP_FD_OR_FAIL with TST_EXP_FAIL when testing
> fanotify_mark() as it returns -1 on failure and 0 on success not a file
> descriptor.
> 
> 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>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> Hi,
> 
> this is a replacement of Mete's v2 fanotify14: fix anonymous pipe testcases:
> https://lore.kernel.org/ltp/20240312120829.178305-2-meted@linux.ibm.com/
> 
> Kind regards,
> Petr
> 
>  .../kernel/syscalls/fanotify/fanotify14.c     | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
> index d02d81495..b554af22a 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify14.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
> @@ -30,6 +30,7 @@
>  
>  #ifdef HAVE_SYS_FANOTIFY_H
>  #include "fanotify.h"
> +#include "tst_selinux.h"
>  
>  #define MNTPOINT "mntpoint"
>  #define FILE1 MNTPOINT"/file1"
> @@ -47,6 +48,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 +285,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);
> +	}
>  
>  	/*
>  	 * ENOTDIR are errors for events/flags not allowed on a non-dir inode.
> @@ -334,6 +345,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
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

  parent reply	other threads:[~2024-03-20 12:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  6:32 [LTP] [PATCH 1/2] lib: Add tst_selinux_enforcing() Petr Vorel
2024-03-20  6:32 ` [LTP] [PATCH v3 2/2] fanotify14: fix anonymous pipe testcases Petr Vorel
2024-03-20  6:59   ` Amir Goldstein
2024-03-20  9:01   ` Mete Durlu
2024-03-20 12:11   ` Jan Kara [this message]
2024-03-20  7:31 ` [LTP] [PATCH 1/2] lib: Add tst_selinux_enforcing() Li Wang
2024-03-20  7:56   ` Petr Vorel
2024-03-20  8:04     ` Li Wang
2024-03-20  8:54       ` 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=20240320121108.5fqgjdinkrhzkuz5@quack3 \
    --to=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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).