public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe
@ 2023-07-16  5:35 Amir Goldstein
  2023-07-16  5:35 ` [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag Amir Goldstein
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Amir Goldstein @ 2023-07-16  5:35 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Christian Brauner, Jan Kara, ltp

Petr,

This tests for a behavior that we consider broken since the dawn of
fanotify.

The fix was merged to v6.5-rc1.
I've already posted backport patches for kernels > v5.0 [1].
I am not planning to post backport patches for older kernels.

Even though the two new test cases do not use FAN_REPORT_FID,
fanotify14 requires FAN_REPORT_FID, so it is not going to run these
test cases on kernel < v5.1 anyway.

You suggested to wait for stable tree to apply the backports [2],
but this seems to be taking time.  Since I am going on vacation next
week, I am posting these tests, so you can merge them whenever you like.

Thanks,
Amir.

[1] https://lore.kernel.org/stable/20230710133205.1154168-1-amir73il@gmail.com/
[2] https://lore.kernel.org/ltp/20230710155006.GA659329@pevik/

Changes since v1:
- Fix build warnings of uninitialized struct members

Amir Goldstein (3):
  fanotify14: Use FAN_MARK_INODE semantic flag
  fanotify14: Use named initializers
  fanotify14: Test disallow sb/mount mark on anonymous pipe

 .../kernel/syscalls/fanotify/fanotify14.c     | 198 +++++++++++++-----
 1 file changed, 150 insertions(+), 48 deletions(-)

-- 
2.34.1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag
  2023-07-16  5:35 [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe Amir Goldstein
@ 2023-07-16  5:35 ` Amir Goldstein
  2023-07-17  6:34   ` Petr Vorel
  2023-07-16  5:35 ` [LTP] [PATCH v2 2/3] fanotify14: Use named initializers Amir Goldstein
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Amir Goldstein @ 2023-07-16  5:35 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Christian Brauner, Jan Kara, ltp

FAN_MARK_INODE is defined as 0, but we use the semantic flag
to improve the test case description.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/fanotify/fanotify14.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index bfa0349fe..08cd94858 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -68,7 +68,7 @@ static struct test_case_t {
 	{FLAGS_DESC(FAN_CLASS_PRE_CONTENT | FAN_REPORT_FID), {}, {}, EINVAL},
 
 	/* INODE_EVENTS in mask without class FAN_REPORT_FID are not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(0), FLAGS_DESC(INODE_EVENTS),
+	{FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(INODE_EVENTS),
 		EINVAL},
 
 	/* INODE_EVENTS in mask with FAN_MARK_MOUNT are not valid */
@@ -91,7 +91,7 @@ static struct test_case_t {
 		{}, {}, EINVAL},
 
 	/* FAN_RENAME without FAN_REPORT_NAME is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID), FLAGS_DESC(0),
+	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID), FLAGS_DESC(FAN_MARK_INODE),
 		FLAGS_DESC(FAN_RENAME), EINVAL},
 
 	/* With FAN_MARK_ONLYDIR on non-dir is not valid */
@@ -100,19 +100,19 @@ static struct test_case_t {
 
 	/* With FAN_REPORT_TARGET_FID, FAN_DELETE on non-dir is not valid */
 	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(0), FLAGS_DESC(FAN_DELETE), ENOTDIR},
+		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_DELETE), ENOTDIR},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_RENAME on non-dir is not valid */
 	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(0), FLAGS_DESC(FAN_RENAME), ENOTDIR},
+		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_RENAME), ENOTDIR},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_ONDIR on non-dir is not valid */
 	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(0), FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
+		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_EVENT_ON_CHILD on non-dir is not valid */
 	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(0), FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
+		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
 		ENOTDIR},
 
 	/* FAN_MARK_IGNORE_SURV with FAN_DELETE on non-dir is not valid */
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH v2 2/3] fanotify14: Use named initializers
  2023-07-16  5:35 [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe Amir Goldstein
  2023-07-16  5:35 ` [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag Amir Goldstein
@ 2023-07-16  5:35 ` Amir Goldstein
  2023-07-17  6:35   ` Petr Vorel
  2023-07-16  5:35 ` [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe Amir Goldstein
  2023-07-17  6:44 ` [LTP] [PATCH v2 0/3] Tests for fanotify " Petr Vorel
  3 siblings, 1 reply; 8+ messages in thread
From: Amir Goldstein @ 2023-07-16  5:35 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Christian Brauner, Jan Kara, ltp

In preparation for adding a new optional test case struct member.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify14.c     | 160 +++++++++++++-----
 1 file changed, 114 insertions(+), 46 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 08cd94858..2c6f6afea 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -62,92 +62,160 @@ static struct test_case_t {
 	int expected_errno;
 } test_cases[] = {
 	/* FAN_REPORT_FID without class FAN_CLASS_NOTIF is not valid */
-	{FLAGS_DESC(FAN_CLASS_CONTENT | FAN_REPORT_FID), {}, {}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_CONTENT | FAN_REPORT_FID),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_REPORT_FID without class FAN_CLASS_NOTIF is not valid */
-	{FLAGS_DESC(FAN_CLASS_PRE_CONTENT | FAN_REPORT_FID), {}, {}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_PRE_CONTENT | FAN_REPORT_FID),
+		.expected_errno = EINVAL,
+	},
 
 	/* INODE_EVENTS in mask without class FAN_REPORT_FID are not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(INODE_EVENTS),
-		EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(INODE_EVENTS),
+		.expected_errno = EINVAL,
+	},
 
 	/* INODE_EVENTS in mask with FAN_MARK_MOUNT are not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID),
-		FLAGS_DESC(FAN_MARK_MOUNT), FLAGS_DESC(INODE_EVENTS), EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID),
+		.mark = FLAGS_DESC(FAN_MARK_MOUNT),
+		.mask = FLAGS_DESC(INODE_EVENTS),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_REPORT_NAME without FAN_REPORT_DIR_FID is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_NAME), {}, {}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_NAME),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_REPORT_NAME without FAN_REPORT_DIR_FID is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID | FAN_REPORT_NAME), {},
-		{}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_FID | FAN_REPORT_NAME),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_REPORT_TARGET_FID without FAN_REPORT_FID is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_NAME),
-		{}, {}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_NAME),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_REPORT_TARGET_FID without FAN_REPORT_NAME is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_FID),
-		{}, {}, EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_FID),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_RENAME without FAN_REPORT_NAME is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID), FLAGS_DESC(FAN_MARK_INODE),
-		FLAGS_DESC(FAN_RENAME), EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(FAN_RENAME),
+		.expected_errno = EINVAL,
+	},
 
 	/* With FAN_MARK_ONLYDIR on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_ONLYDIR),
-		FLAGS_DESC(FAN_OPEN), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_ONLYDIR),
+		.mask = FLAGS_DESC(FAN_OPEN),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_DELETE on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_DELETE), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(FAN_DELETE),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_RENAME on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_RENAME), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(FAN_RENAME),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_ONDIR on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(FAN_OPEN | FAN_ONDIR),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* With FAN_REPORT_TARGET_FID, FAN_EVENT_ON_CHILD on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
-		FLAGS_DESC(FAN_MARK_INODE), FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
-		ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET),
+		.mark = FLAGS_DESC(FAN_MARK_INODE),
+		.mask = FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* FAN_MARK_IGNORE_SURV with FAN_DELETE on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
-		FLAGS_DESC(FAN_MARK_IGNORE_SURV), FLAGS_DESC(FAN_DELETE),
-		ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+		.mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+		.mask = FLAGS_DESC(FAN_DELETE),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* FAN_MARK_IGNORE_SURV with FAN_RENAME on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
-		FLAGS_DESC(FAN_MARK_IGNORE_SURV), FLAGS_DESC(FAN_RENAME),
-		ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+		.mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+		.mask = FLAGS_DESC(FAN_RENAME),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* FAN_MARK_IGNORE_SURV with FAN_ONDIR on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
-		FLAGS_DESC(FAN_MARK_IGNORE_SURV),
-		FLAGS_DESC(FAN_OPEN | FAN_ONDIR), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+		.mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+		.mask = FLAGS_DESC(FAN_OPEN | FAN_ONDIR),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* FAN_MARK_IGNORE_SURV with FAN_EVENT_ON_CHILD on non-dir is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
-		FLAGS_DESC(FAN_MARK_IGNORE_SURV),
-		FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD), ENOTDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME),
+		.mark = FLAGS_DESC(FAN_MARK_IGNORE_SURV),
+		.mask = FLAGS_DESC(FAN_OPEN | FAN_EVENT_ON_CHILD),
+		.expected_errno = ENOTDIR,
+	},
 
 	/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on directory is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF), FLAGS_DESC(FAN_MARK_IGNORE),
-		FLAGS_DESC(FAN_OPEN), EISDIR},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_IGNORE),
+		.mask = FLAGS_DESC(FAN_OPEN),
+		.expected_errno = EISDIR,
+	},
 
 	/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on mount mark is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF),
-		FLAGS_DESC(FAN_MARK_MOUNT | FAN_MARK_IGNORE),
-		FLAGS_DESC(FAN_OPEN), EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_MOUNT | FAN_MARK_IGNORE),
+		.mask = FLAGS_DESC(FAN_OPEN),
+		.expected_errno = EINVAL,
+	},
 
 	/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on filesystem mark is not valid */
-	{FLAGS_DESC(FAN_CLASS_NOTIF),
-		FLAGS_DESC(FAN_MARK_FILESYSTEM | FAN_MARK_IGNORE),
-		FLAGS_DESC(FAN_OPEN), EINVAL},
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_FILESYSTEM | FAN_MARK_IGNORE),
+		.mask = FLAGS_DESC(FAN_OPEN),
+		.expected_errno = EINVAL,
+	},
 };
 
 static void do_test(unsigned int number)
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe
  2023-07-16  5:35 [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe Amir Goldstein
  2023-07-16  5:35 ` [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag Amir Goldstein
  2023-07-16  5:35 ` [LTP] [PATCH v2 2/3] fanotify14: Use named initializers Amir Goldstein
@ 2023-07-16  5:35 ` Amir Goldstein
  2023-07-17  6:38   ` Petr Vorel
  2023-07-17  6:44 ` [LTP] [PATCH v2 0/3] Tests for fanotify " Petr Vorel
  3 siblings, 1 reply; 8+ messages in thread
From: Amir Goldstein @ 2023-07-16  5:35 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Christian Brauner, Jan Kara, ltp

This case was retroactively disallowed.

This test is meant to encourage the backporting of commit 69562eb0bd3e
("fanotify: disallow mount/sb marks on kernel internal pseudo fs") to
all stable kernels.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify14.c     | 38 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 2c6f6afea..4596511f0 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -19,6 +19,9 @@
  *
  *     ceaf69f8eadc fanotify: do not allow setting dirent events in mask of non-dir
  *     8698e3bab4dd fanotify: refine the validation checks on non-dir inode mask
+ *
+ * The pipes test cases are regression tests for commit:
+ *     69562eb0bd3e fanotify: disallow mount/sb marks on kernel internal pseudo fs
  */
 
 #define _GNU_SOURCE
@@ -40,6 +43,7 @@
 
 #define FLAGS_DESC(flags) {(flags), (#flags)}
 
+static int pipes[2] = {-1, -1};
 static int fanotify_fd;
 static int fan_report_target_fid_unsupported;
 static int ignore_mark_unsupported;
@@ -60,6 +64,7 @@ static struct test_case_t {
 	/* when mask.flags == 0, fanotify_init() is expected to fail */
 	struct test_case_flags_t mask;
 	int expected_errno;
+	int *pfd;
 } test_cases[] = {
 	/* FAN_REPORT_FID without class FAN_CLASS_NOTIF is not valid */
 	{
@@ -216,6 +221,22 @@ static struct test_case_t {
 		.mask = FLAGS_DESC(FAN_OPEN),
 		.expected_errno = EINVAL,
 	},
+	/* mount mark on anonymous pipe is not valid */
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_MOUNT),
+		.mask = { FAN_ACCESS, "anonymous pipe"},
+		.pfd = pipes,
+		.expected_errno = EINVAL,
+	},
+	/* filesystem mark on anonymous pipe is not valid */
+	{
+		.init = FLAGS_DESC(FAN_CLASS_NOTIF),
+		.mark = FLAGS_DESC(FAN_MARK_FILESYSTEM),
+		.mask = { FAN_ACCESS, "anonymous pipe"},
+		.pfd = pipes,
+		.expected_errno = EINVAL,
+	},
 };
 
 static void do_test(unsigned int number)
@@ -253,11 +274,17 @@ static void do_test(unsigned int number)
 
 	/* Set mark on non-dir only when expecting error ENOTDIR */
 	const char *path = tc->expected_errno == ENOTDIR ? FILE1 : MNTPOINT;
+	int dirfd = AT_FDCWD;
+
+	if (tc->pfd) {
+		dirfd = tc->pfd[0];
+		path = NULL;
+	}
 
-	tst_res(TINFO, "Testing fanotify_mark(FAN_MARK_ADD | %s, %s)",
+	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, AT_FDCWD, path),
+					 tc->mask.flags, dirfd, path),
 					 tc->expected_errno);
 
 	/*
@@ -299,12 +326,18 @@ static void do_setup(void)
 
 	/* Create temporary test file to place marks on */
 	SAFE_FILE_PRINTF(FILE1, "0");
+	/* Create anonymous pipes to place marks on */
+	SAFE_PIPE2(pipes, O_CLOEXEC);
 }
 
 static void do_cleanup(void)
 {
 	if (fanotify_fd > 0)
 		SAFE_CLOSE(fanotify_fd);
+	if (pipes[0] != -1)
+		SAFE_CLOSE(pipes[0]);
+	if (pipes[1] != -1)
+		SAFE_CLOSE(pipes[1]);
 }
 
 static struct tst_test test = {
@@ -319,6 +352,7 @@ static struct tst_test test = {
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "ceaf69f8eadc"},
 		{"linux-git", "8698e3bab4dd"},
+		{"linux-git", "69562eb0bd3e"},
 		{}
 	}
 };
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag
  2023-07-16  5:35 ` [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag Amir Goldstein
@ 2023-07-17  6:34   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-07-17  6:34 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Christian Brauner, Jan Kara, ltp

Hi Amir,

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks!

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH v2 2/3] fanotify14: Use named initializers
  2023-07-16  5:35 ` [LTP] [PATCH v2 2/3] fanotify14: Use named initializers Amir Goldstein
@ 2023-07-17  6:35   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-07-17  6:35 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Christian Brauner, Jan Kara, ltp

Hi Amir,

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks!

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe
  2023-07-16  5:35 ` [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe Amir Goldstein
@ 2023-07-17  6:38   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-07-17  6:38 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Christian Brauner, Jan Kara, ltp

Hi Amir,

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks!

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe
  2023-07-16  5:35 [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe Amir Goldstein
                   ` (2 preceding siblings ...)
  2023-07-16  5:35 ` [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe Amir Goldstein
@ 2023-07-17  6:44 ` Petr Vorel
  3 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-07-17  6:44 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Christian Brauner, Jan Kara, ltp

Hi Amir,

> Petr,

> This tests for a behavior that we consider broken since the dawn of
> fanotify.

> The fix was merged to v6.5-rc1.
> I've already posted backport patches for kernels > v5.0 [1].
> I am not planning to post backport patches for older kernels.

> Even though the two new test cases do not use FAN_REPORT_FID,
> fanotify14 requires FAN_REPORT_FID, so it is not going to run these
> test cases on kernel < v5.1 anyway.

> You suggested to wait for stable tree to apply the backports [2],
> but this seems to be taking time.  Since I am going on vacation next
> week, I am posting these tests, so you can merge them whenever you like.

I was probably too conservative, whole patchset merged, thank you!

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-17  6:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-16  5:35 [LTP] [PATCH v2 0/3] Tests for fanotify on anonymous pipe Amir Goldstein
2023-07-16  5:35 ` [LTP] [PATCH v2 1/3] fanotify14: Use FAN_MARK_INODE semantic flag Amir Goldstein
2023-07-17  6:34   ` Petr Vorel
2023-07-16  5:35 ` [LTP] [PATCH v2 2/3] fanotify14: Use named initializers Amir Goldstein
2023-07-17  6:35   ` Petr Vorel
2023-07-16  5:35 ` [LTP] [PATCH v2 3/3] fanotify14: Test disallow sb/mount mark on anonymous pipe Amir Goldstein
2023-07-17  6:38   ` Petr Vorel
2023-07-17  6:44 ` [LTP] [PATCH v2 0/3] Tests for fanotify " Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox