public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] fanotify24: remove redundant event_count field
Date: Wed, 19 Mar 2025 20:27:40 +0100	[thread overview]
Message-ID: <20250319192742.999506-2-amir73il@gmail.com> (raw)
In-Reply-To: <20250319192742.999506-1-amir73il@gmail.com>

treat the event-set as a null terminated array.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify24.c     | 31 +++++++++----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify24.c b/testcases/kernel/syscalls/fanotify/fanotify24.c
index 8a448ea50..539f74137 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify24.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify24.c
@@ -60,13 +60,12 @@ static struct tcase {
 	const char *tname;
 	struct fanotify_mark_type mark;
 	unsigned long long mask;
-	int event_count;
 	struct event event_set[EVENT_SET_MAX];
 } tcases[] = {
 	{
 		"inode mark, FAN_OPEN_PERM | FAN_PRE_ACCESS events",
 		INIT_FANOTIFY_MARK_TYPE(INODE),
-		FAN_OPEN_PERM | FAN_PRE_ACCESS, 4,
+		FAN_OPEN_PERM | FAN_PRE_ACCESS,
 		{
 			{FAN_OPEN_PERM, FAN_ALLOW},
 			{FAN_PRE_ACCESS, FAN_DENY},
@@ -77,7 +76,7 @@ static struct tcase {
 	{
 		"inode mark, FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM events",
 		INIT_FANOTIFY_MARK_TYPE(INODE),
-		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM, 3,
+		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM,
 		{
 			{FAN_PRE_ACCESS, FAN_DENY},
 			{FAN_PRE_ACCESS, FAN_DENY_ERRNO(EIO)},
@@ -87,7 +86,7 @@ static struct tcase {
 	{
 		"mount mark, FAN_OPEN_PERM | FAN_PRE_ACCESS events",
 		INIT_FANOTIFY_MARK_TYPE(MOUNT),
-		FAN_OPEN_PERM | FAN_PRE_ACCESS, 4,
+		FAN_OPEN_PERM | FAN_PRE_ACCESS,
 		{
 			{FAN_OPEN_PERM, FAN_ALLOW},
 			{FAN_PRE_ACCESS, FAN_DENY},
@@ -98,7 +97,7 @@ static struct tcase {
 	{
 		"mount mark, FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM events",
 		INIT_FANOTIFY_MARK_TYPE(MOUNT),
-		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM, 3,
+		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM,
 		{
 			{FAN_PRE_ACCESS, FAN_DENY},
 			{FAN_PRE_ACCESS, FAN_DENY_ERRNO(EIO)},
@@ -108,7 +107,7 @@ static struct tcase {
 	{
 		"filesystem mark, FAN_OPEN_PERM | FAN_PRE_ACCESS events",
 		INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
-		FAN_OPEN_PERM | FAN_PRE_ACCESS, 4,
+		FAN_OPEN_PERM | FAN_PRE_ACCESS,
 		{
 			{FAN_OPEN_PERM, FAN_ALLOW},
 			{FAN_PRE_ACCESS, FAN_DENY},
@@ -119,7 +118,7 @@ static struct tcase {
 	{
 		"filesystem mark, FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM events",
 		INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
-		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM, 3,
+		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM,
 		{
 			{FAN_PRE_ACCESS, FAN_DENY},
 			{FAN_PRE_ACCESS, FAN_DENY_ERRNO(EIO)},
@@ -129,7 +128,7 @@ static struct tcase {
 	{
 		"parent watching children, FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM events",
 		INIT_FANOTIFY_MARK_TYPE(PARENT),
-		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM | FAN_EVENT_ON_CHILD, 3,
+		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM | FAN_EVENT_ON_CHILD,
 		{
 			{FAN_PRE_ACCESS, FAN_DENY},
 			{FAN_PRE_ACCESS, FAN_DENY},
@@ -139,14 +138,14 @@ static struct tcase {
 	{
 		"parent not watching children, FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM events",
 		INIT_FANOTIFY_MARK_TYPE(PARENT),
-		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM, 0,
+		FAN_PRE_ACCESS | FAN_OPEN_EXEC_PERM,
 		{
 		}
 	},
 	{
 		"inode mark, FAN_PRE_ACCESS event allowed",
 		INIT_FANOTIFY_MARK_TYPE(INODE),
-		FAN_PRE_ACCESS, 1,
+		FAN_PRE_ACCESS,
 		{
 			/* This allows multiple FAN_PRE_ACCESS events */
 			{FAN_PRE_ACCESS, FAN_ALLOW},
@@ -225,7 +224,7 @@ static void generate_events(struct tcase *tc)
 	 */
 	if (!exp_errno) {
 		fd = SAFE_OPEN(FILE_EXEC_PATH, O_RDWR);
-		if (!tc->event_count)
+		if (!tc->event_set[0].mask)
 			exp_errno = ETXTBSY;
 	}
 
@@ -335,10 +334,10 @@ static void test_fanotify(unsigned int n)
 	/*
 	 * Process events
 	 *
-	 * tc->count + 1 is to let read() wait for child process to exit
-	 * and to accomodate for extra access events
+	 * even if we do not expect another event, let read() wait for child
+	 * process to exit and accomodate for multiple access events
 	 */
-	while (test_num < tc->event_count + 1 && fd_notify != -1) {
+	while (test_num < EVENT_SET_MAX && fd_notify != -1) {
 		struct fanotify_event_metadata *event;
 
 		if (i == len) {
@@ -363,7 +362,7 @@ static void test_fanotify(unsigned int n)
 		 * generate an unknown number of access permission events if they
 		 * are allowed.
 		 */
-		if (test_num > 0 && test_num == tc->event_count &&
+		if (test_num > 0 && !event_set[test_num].mask &&
 		    event_set[test_num-1].response == FAN_ALLOW)
 			test_num--;
 
@@ -418,7 +417,7 @@ static void test_fanotify(unsigned int n)
 		test_num++;
 	}
 
-	for (; test_num < tc->event_count; test_num++) {
+	for (; event_set[test_num].mask && test_num < EVENT_SET_MAX; test_num++) {
 		tst_res(TFAIL, "didn't get event: mask=%llx",
 			event_set[test_num].mask);
 
-- 
2.34.1


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

  reply	other threads:[~2025-03-19 19:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19 19:27 [LTP] [PATCH 0/3] fanotify tests update for 6.14-rc7 Amir Goldstein
2025-03-19 19:27 ` Amir Goldstein [this message]
2025-03-24 13:23   ` [LTP] [PATCH 1/3] fanotify24: remove redundant event_count field Jan Kara
2025-03-25 20:46     ` Petr Vorel
2025-03-19 19:27 ` [LTP] [PATCH 2/3] fanotify24: print range info for pre-content events Amir Goldstein
2025-03-26 15:04   ` Jan Kara
2025-03-27  9:11     ` Amir Goldstein
2025-03-27 10:54       ` Petr Vorel
2025-03-27 17:15         ` Amir Goldstein
2025-03-19 19:27 ` [LTP] [PATCH 3/3] fanotify24: add mmap() and user page fault to test Amir Goldstein
2025-03-20 17:00   ` Petr Vorel
2025-03-20 17:42     ` Amir Goldstein
2025-03-20 18:18       ` Petr Vorel
2025-03-26 15:08   ` Jan Kara

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=20250319192742.999506-2-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=ltp@lists.linux.it \
    --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