[LTP] [PATCH 1/4] fanotify14: Test invalid init flags with permission and pre-content events

Amir Goldstein amir73il@gmail.com
Mon Feb 10 16:13:13 CET 2025


Those events require an high priority fanotify group.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 include/lapi/fanotify.h                       |  5 +++++
 .../kernel/syscalls/fanotify/fanotify14.c     | 20 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/lapi/fanotify.h b/include/lapi/fanotify.h
index 40ea7ead7..e5b930f4e 100644
--- a/include/lapi/fanotify.h
+++ b/include/lapi/fanotify.h
@@ -109,6 +109,9 @@
 #ifndef FAN_FS_ERROR
 #define FAN_FS_ERROR		0x00008000
 #endif
+#ifndef FAN_PRE_ACCESS
+#define FAN_PRE_ACCESS		0x00100000
+#endif
 #ifndef FAN_RENAME
 #define FAN_RENAME		0x10000000
 #endif
@@ -134,6 +137,8 @@
 #define LTP_ALL_PERM_EVENTS	(FAN_OPEN_PERM | FAN_OPEN_EXEC_PERM | \
 				 FAN_ACCESS_PERM)
 
+#define LTP_PRE_CONTENT_EVENTS	(FAN_PRE_ACCESS)
+
 struct fanotify_group_type {
 	unsigned int flag;
 	const char *name;
diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index ee583a095..b17bffd18 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -239,6 +239,26 @@ static struct test_case_t {
 		.pfd = pipes,
 		.expected_errno = EINVAL,
 	},
+	/* permission events in mask with priority < FAN_CLASS_CONTENT are not valid */
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(LTP_ALL_PERM_EVENTS),
+		.expected_errno = EINVAL,
+	},
+	/* pre-content events in mask with priority < FAN_CLASS_PRE_CONTENT are not valid */
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(LTP_PRE_CONTENT_EVENTS),
+		.expected_errno = EINVAL,
+	},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_CONTENT),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(LTP_PRE_CONTENT_EVENTS),
+		.expected_errno = EINVAL,
+	},
 };
 
 static void do_test(unsigned int number)
-- 
2.34.1



More information about the ltp mailing list