From: Amir Goldstein <amir73il@gmail.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: Matthew Bobrowski <repnop@google.com>, Jan Kara <jack@suse.cz>,
ltp@lists.linux.it
Subject: [LTP] [PATCH 1/9] syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE
Date: Mon, 5 Sep 2022 18:42:31 +0300 [thread overview]
Message-ID: <20220905154239.2652169-2-amir73il@gmail.com> (raw)
In-Reply-To: <20220905154239.2652169-1-amir73il@gmail.com>
Verify the semantics of the new FAN_MARK_IGNORE flag:
1. Verify that ignore mask ignores events on dir only
when FAN_ONDIR flag is set in ignore mask
2. Verify that ignore mask ignores events on child only
when FAN_EVENT_ON_CHILD flag is set in ignore mask
3. Verify that ignore mask ignores events on subdir only
when both FAN_EVENT_ON_CHILD and FAN_ONDIR flags are
set in ignore mask
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
testcases/kernel/syscalls/fanotify/fanotify.h | 6 ++
.../kernel/syscalls/fanotify/fanotify09.c | 102 +++++++++++++++---
2 files changed, 95 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index a118fbd9e..d67c079af 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -106,6 +106,12 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,
#ifndef FAN_MARK_EVICTABLE
#define FAN_MARK_EVICTABLE 0x00000200
#endif
+#ifndef FAN_MARK_IGNORE
+#define FAN_MARK_IGNORE 0x00000400
+#endif
+#ifndef FAN_MARK_IGNORE_SURV
+#define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)
+#endif
/* New dirent event masks */
#ifndef FAN_ATTRIB
diff --git a/testcases/kernel/syscalls/fanotify/fanotify09.c b/testcases/kernel/syscalls/fanotify/fanotify09.c
index 0eb83e2f8..e40916c08 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify09.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify09.c
@@ -73,12 +73,14 @@ static char event_buf[EVENT_BUF_LEN];
static int mount_created;
static int fan_report_dfid_unsupported;
+static int ignore_mark_unsupported;
static struct tcase {
const char *tname;
struct fanotify_mark_type mark;
unsigned int ondir;
unsigned int ignore;
+ unsigned int ignore_flags;
unsigned int report_name;
const char *close_nowrite;
int nevents;
@@ -88,7 +90,7 @@ static struct tcase {
"Events on non-dir child with both parent and mount marks",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
0,
- 0,
+ 0, 0,
0,
DIR_NAME,
1, 0,
@@ -97,7 +99,7 @@ static struct tcase {
"Events on non-dir child and subdir with both parent and mount marks",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
FAN_ONDIR,
- 0,
+ 0, 0,
0,
DIR_NAME,
2, 0,
@@ -106,7 +108,7 @@ static struct tcase {
"Events on non-dir child and parent with both parent and mount marks",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
FAN_ONDIR,
- 0,
+ 0, 0,
0,
".",
2, 0
@@ -115,7 +117,7 @@ static struct tcase {
"Events on non-dir child and subdir with both parent and subdir marks",
INIT_FANOTIFY_MARK_TYPE(INODE),
FAN_ONDIR,
- 0,
+ 0, 0,
0,
DIR_NAME,
2, 0,
@@ -124,7 +126,7 @@ static struct tcase {
"Events on non-dir children with both parent and mount marks",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
0,
- 0,
+ 0, 0,
0,
FILE2_NAME,
2, FAN_CLOSE_NOWRITE,
@@ -133,7 +135,7 @@ static struct tcase {
"Events on non-dir child with both parent and mount marks and filename info",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
0,
- 0,
+ 0, 0,
FAN_REPORT_DFID_NAME,
FILE2_NAME,
2, FAN_CLOSE_NOWRITE,
@@ -142,7 +144,7 @@ static struct tcase {
"Events on non-dir child with ignore mask on parent",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
0,
- FAN_MARK_IGNORED_MASK,
+ FAN_MARK_IGNORED_MASK, 0,
0,
DIR_NAME,
1, 0,
@@ -151,11 +153,75 @@ static struct tcase {
"Events on non-dir children with surviving ignore mask on parent",
INIT_FANOTIFY_MARK_TYPE(MOUNT),
0,
- FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY,
+ FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY, 0,
+ 0,
+ FILE2_NAME,
+ 2, FAN_CLOSE_NOWRITE,
+ },
+ /* FAN_MARK_IGNORE test cases: */
+ {
+ "Events on dir with ignore mask that does not apply to dirs",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ FAN_ONDIR,
+ FAN_MARK_IGNORE_SURV, 0,
+ 0,
+ ".",
+ 2, FAN_CLOSE_NOWRITE,
+ },
+ {
+ "Events on dir with ignore mask that does apply to dirs",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ FAN_ONDIR,
+ FAN_MARK_IGNORE_SURV, FAN_ONDIR,
+ 0,
+ ".",
+ 2, 0,
+ },
+ {
+ "Events on child with ignore mask on parent that does not apply to children",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ 0,
+ FAN_MARK_IGNORE_SURV, 0,
+ 0,
+ FILE2_NAME,
+ 2, FAN_CLOSE_NOWRITE,
+ },
+ {
+ "Events on child with ignore mask on parent that does apply to children",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ 0,
+ FAN_MARK_IGNORE_SURV, FAN_EVENT_ON_CHILD,
0,
FILE2_NAME,
+ 2, 0,
+ },
+ {
+ "Events on subdir with ignore mask on parent that does not apply to children",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ FAN_ONDIR,
+ FAN_MARK_IGNORE_SURV, FAN_ONDIR,
+ 0,
+ DIR_NAME,
2, FAN_CLOSE_NOWRITE,
},
+ {
+ "Events on subdir with ignore mask on parent that does not apply to dirs",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ FAN_ONDIR,
+ FAN_MARK_IGNORE_SURV, FAN_EVENT_ON_CHILD,
+ 0,
+ DIR_NAME,
+ 2, FAN_CLOSE_NOWRITE,
+ },
+ {
+ "Events on subdir with ignore mask on parent that does apply to subdirs",
+ INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ FAN_ONDIR,
+ FAN_MARK_IGNORE_SURV, FAN_EVENT_ON_CHILD | FAN_ONDIR,
+ 0,
+ DIR_NAME,
+ 2, 0,
+ },
};
static void create_fanotify_groups(struct tcase *tc)
@@ -170,16 +236,19 @@ static void create_fanotify_groups(struct tcase *tc)
*/
unsigned int report_name = tc->report_name;
unsigned int mask_flags = tc->ondir | FAN_EVENT_ON_CHILD;
- unsigned int parent_mask, ignore = 0;
+ unsigned int parent_mask, ignore_mask, ignore = 0;
/*
- * The non-first groups do not request events on children and
- * subdirs and may set an ignore mask on parent dir.
+ * The non-first groups may request events on children and
+ * subdirs only when setting an ignore mask on parent dir.
+ * The parent ignore mask may request to ignore events on
+ * children or subdirs.
*/
if (i > 0) {
ignore = tc->ignore;
report_name = 0;
- mask_flags = 0;
+ if (!ignore)
+ mask_flags = 0;
}
fd_notify[i] = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | report_name |
@@ -206,8 +275,9 @@ static void create_fanotify_groups(struct tcase *tc)
* the close event on dir.
*/
parent_mask = FAN_MODIFY | tc->ondir | mask_flags;
+ ignore_mask = FAN_CLOSE_NOWRITE | tc->ignore_flags;
SAFE_FANOTIFY_MARK(fd_notify[i], FAN_MARK_ADD | ignore,
- ignore ? FAN_CLOSE_NOWRITE : parent_mask,
+ ignore ? ignore_mask : parent_mask,
AT_FDCWD, ".");
}
}
@@ -331,6 +401,11 @@ static void test_fanotify(unsigned int n)
return;
}
+ if (ignore_mark_unsupported && tc->ignore & FAN_MARK_IGNORE) {
+ tst_res(TCONF, "FAN_MARK_IGNORE not supported in kernel?");
+ return;
+ }
+
create_fanotify_groups(tc);
/*
@@ -422,6 +497,7 @@ static void setup(void)
{
fan_report_dfid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
MOUNT_PATH);
+ ignore_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_IGNORE_SURV);
SAFE_MKDIR(MOUNT_NAME, 0755);
SAFE_MOUNT(MOUNT_PATH, MOUNT_NAME, "none", MS_BIND, NULL);
--
2.25.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-09-05 15:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 15:42 [LTP] [PATCH 0/9] Fanotify tests for FAN_MARK_IGNORE Amir Goldstein
2022-09-05 15:42 ` Amir Goldstein [this message]
2022-09-05 16:04 ` [LTP] [PATCH 1/9] syscalls/fanotify09: Add test cases " Petr Vorel
2022-09-06 5:08 ` Amir Goldstein
2022-09-06 5:58 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 2/9] syscalls/fanotify14: Require FAN_REPORT_FID support for entire test Amir Goldstein
2022-09-06 6:06 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 3/9] syscalls/fanotify14: Add test cases for FAN_MARK_IGNORE Amir Goldstein
2022-09-06 9:05 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 4/9] syscalls/fanotify10: Avoid undesired event in test Amir Goldstein
2022-09-06 16:51 ` Petr Vorel
2022-09-06 17:09 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 5/9] syscalls/fanotify10: Add more verifications and debug info Amir Goldstein
2022-09-06 17:01 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 6/9] syscalls/fanotify10: Use dedicated mark type for inode mark on parent Amir Goldstein
2022-09-06 17:03 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 7/9] syscalls/fanotify10: Run tests with two ignore mask variants Amir Goldstein
2022-09-06 17:07 ` Petr Vorel
2022-09-05 15:42 ` [LTP] [PATCH 8/9] syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_EVENT_ON_CHILD Amir Goldstein
2022-09-05 15:42 ` [LTP] [PATCH 9/9] syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_ONDIR Amir Goldstein
2022-09-06 15:38 ` [LTP] [PATCH 0/9] Fanotify tests for FAN_MARK_IGNORE Jan Kara
2022-09-06 17:28 ` Amir Goldstein
2022-09-07 10:45 ` 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=20220905154239.2652169-2-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
--cc=repnop@google.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.