From: Mete Durlu <meted@linux.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] fanotify14: fix anonymous pipe testcases
Date: Mon, 11 Mar 2024 15:53:19 +0100 [thread overview]
Message-ID: <3700d7c9-2f7e-4946-be27-87f500ccb6dd@linux.ibm.com> (raw)
In-Reply-To: <CAOQ4uxhFB2Gv2+8N-sc9a1+Kz1KqW+bniJe0JhVSHsaMWnxrmQ@mail.gmail.com>
On 3/8/24 14:39, Amir Goldstein wrote:
> On Fri, Mar 8, 2024 at 2:43 PM Mete Durlu <meted@linux.ibm.com> wrote:
>>
>> When SElinux is configured (comes out of the box on most distros) and
>> is configured to enforcing (the default configuration), tests related
>> to anonymous pipes return EACCES instead of the expected errno EINVAL.
>> Fix the failures caused by the above condition by checking the SElinux
>> configuration and adjusting the errno accordingly.
>
> Hi Mete,
>
> Isn't the outcome of the test dependent on the SEpolicy rules?
> Not only if it is enforced?
>
> Sorry I have very little experience with SELinux.
>
Hi Amir,
I don't have SElinux experience either, on my proposed patch I only
considered the default behavior but you are right different SElinux
configurations may lead to different outcomes. I skimmed over SElinux
wiki a little and now I think trying to verify the SElinux policy would
be too cumbersome. Instead I propose two different solutions.
1. We can skip the anonymous pipe test cases when SElinux is in
enforcing state.
or
2. We can accept both EACESS and EINVAL as valid errnos when SElinux is
in enforcing state.
Personally option 2 sounds better to me since we would get more coverage
that way. If either way sounds good I can send a v2 right away. How does
that sound?
Thank you.
>
>>
>> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
>> ---
>> testcases/kernel/syscalls/fanotify/fanotify14.c | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>> diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
>> index d02d81495..61ed8c660 100644
>> --- a/testcases/kernel/syscalls/fanotify/fanotify14.c
>> +++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
>> @@ -27,12 +27,14 @@
>> #define _GNU_SOURCE
>> #include "tst_test.h"
>> #include <errno.h>
>> +#include <stdlib.h>
>>
>> #ifdef HAVE_SYS_FANOTIFY_H
>> #include "fanotify.h"
>>
>> #define MNTPOINT "mntpoint"
>> #define FILE1 MNTPOINT"/file1"
>> +#define SELINUX_STATUS_PATH "/sys/fs/selinux/enforce"
>>
>> /*
>> * List of inode events that are only available when notification group is
>> @@ -240,6 +242,19 @@ static struct test_case_t {
>> },
>> };
>>
>> +static int is_selinux_enforcing(void)
>> +{
>> + char res;
>> + int fd;
>> +
>> + fd = open(SELINUX_STATUS_PATH, O_RDONLY);
>> + if (fd <= 0)
>> + return 0;
>> + SAFE_READ(1, fd, &res, 1);
>> + SAFE_CLOSE(fd);
>> + return atoi(&res);
>> +}
>> +
>> static void do_test(unsigned int number)
>> {
>> struct test_case_t *tc = &test_cases[number];
>> @@ -279,6 +294,8 @@ static void do_test(unsigned int number)
>> if (tc->pfd) {
>> dirfd = tc->pfd[0];
>> path = NULL;
>> + if (is_selinux_enforcing())
>> + tc->expected_errno = EACCES;
>> }
>>
>> tst_res(TINFO, "Testing %s with %s",
>> --
>> 2.44.0
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-03-11 14:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 9:26 [LTP] [PATCH v1] fanotify14: fix anonymous pipe testcases Mete Durlu
2024-03-08 13:39 ` Amir Goldstein
2024-03-11 14:53 ` Mete Durlu [this message]
2024-03-11 16:08 ` Amir Goldstein
2024-03-12 13:10 ` Petr Vorel
2024-03-14 8:56 ` 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=3700d7c9-2f7e-4946-be27-87f500ccb6dd@linux.ibm.com \
--to=meted@linux.ibm.com \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--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.