Skip to contentSkip to conversation

fanotify: FAN_REPORT_FID and Directory Modification Events

PATCH Superseded Matthew Bobrowski 3 participants 20 messages Apr 2, 2019 – Apr 19, 2019

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover fanotify: FAN_REPORT_FID and Directory Modification Events

This patch series contains the changes needed to support and validate the new FAN_REPORT_FID flag and directory modification event functionality within the fanotify API.

Amir Goldstein (1):
syscalls/fanotify01: add FAN_REPORT_FID test cases

Matthew Bobrowski (3):
syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality syscalls/fanotify14: new test to validate FAN_REPORT_FID interface
return values
syscalls/fanotify15: verify fid for dirent events

 testcases/kernel/syscalls/fanotify/.gitignore   |   3 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  41 +++
 testcases/kernel/syscalls/fanotify/fanotify01.c |  41 ++-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++
 testcases/kernel/syscalls/fanotify/fanotify14.c | 170 ++++++++++++
 testcases/kernel/syscalls/fanotify/fanotify15.c | 256 ++++++++++++++++++
 6 files changed, 838 insertions(+), 2 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify13.c
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify14.c
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify15.c
Signature · 5 lines
2.16.4


-- 
Matthew Bobrowski
#1 lore raw

PATCH 1/4 syscalls/fanotify01: add FAN_REPORT_FID test cases

For now, only check that event->fd is FAN_NOFD.
On old kernels the new test with result in TCONF.

tmpfs doesn't support FAN_REPORT_FID (it has zero fsid), so use a blockdev filesystem. It is better to use a blockdev filesystem for the rest of the test cases anyway to get more diversity in testing.

---
 testcases/kernel/syscalls/fanotify/fanotify.h   |  3 ++
 testcases/kernel/syscalls/fanotify/fanotify01.c | 41 +++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +3 -0
index e5cc59232..14654b7c7 100644
@@ -57,6 +57,9 @@ static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
 #ifndef FAN_REPORT_TID
 #define FAN_REPORT_TID		0x00000100
 #endif
+#ifndef FAN_REPORT_FID
+#define FAN_REPORT_FID		0x00000200
+#endif
 
 #ifndef FAN_MARK_INODE
 #define FAN_MARK_INODE		0
testcases/kernel/syscalls/fanotify/fanotify01.c +39 -2

77 lines not on this page · raw message

Signature · 5 lines
2.16.4


-- 
Matthew Bobrowski
#3 lore raw

PATCH 2/4 syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

In reply to Matthew Bobrowski

Newly defined test file to validate the fanotify FAN_REPORT_FID functionality.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++
 3 files changed, 346 insertions(+), 3 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify13.c
testcases/kernel/syscalls/fanotify/.gitignore +1 -0
index 4256b8cd3..16bdd99e5 100644
@@ -10,4 +10,5 @@
 /fanotify10
 /fanotify11
 /fanotify12
+/fanotify13
 /fanotify_child
testcases/kernel/syscalls/fanotify/fanotify.h +16 -3
index 14654b7c7..450f3829d 100644
@@ -57,9 +57,6 @@ static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
 #ifndef FAN_REPORT_TID
 #define FAN_REPORT_TID		0x00000100
 #endif
-#ifndef FAN_REPORT_FID
-#define FAN_REPORT_FID		0x00000200
-#endif
 
 #ifndef FAN_MARK_INODE
 #define FAN_MARK_INODE		0
@@ -89,6 +86,22 @@ struct fanotify_mark_type {
 	const char * name;
 };
 
+#ifndef FAN_REPORT_FID
+#define FAN_REPORT_FID		0x00000200
+
+struct fanotify_event_info_header {
+	uint8_t info_type;
+	uint8_t pad;
+	uint16_t len;
+};
+
+struct fanotify_event_info_fid {
+	struct fanotify_event_info_header hdr;
+	__kernel_fsid_t fsid;
+	unsigned char handle[0];
+};
+#endif
+
 #define INIT_FANOTIFY_MARK_TYPE(t) \
 	{ FAN_MARK_ ## t, "FAN_MARK_" #t }
 
testcases/kernel/syscalls/fanotify/fanotify13.c new file +329 -0

329 lines not on this page · raw message

Signature · 5 lines
2.16.4


-- 
Matthew Bobrowski
#4 lore raw

PATCH 2/4 syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

Hi!

Quoted 9 lines

Newly defined test file to validate the fanotify FAN_REPORT_FID functionality.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++

This is missing the runtest entry in runtest/syscalls so that the test is picked up by the testrunner.

And the same bug slipped in during review for fanotify12 so I've commited a fix that adds it there.

...

Quoted 7 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +7 -0
+static void do_test(unsigned int number)
+{
+	unsigned int i;
+	int len, fds[ARRAY_SIZE(objects)];
+
+	struct file_handle *event_file_handle;
+	struct fanotify_event_metadata *metadata;

testcases/kernel/syscalls/fanotify/fanotify13.c line 197

Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +10 -0
+	struct fanotify_event_info_fid *event_fid;
+	struct test_case_t *tc = &test_cases[number];
+	struct fanotify_mark_type *mark = &tc->mark;
+
+	tst_res(TINFO,
+		"Test #%d: FAN_REPORT_FID with mark flag: %s",
+		number, mark->name);
+
+	/* Gets the filesystem fsid and file handle for each object */
+	get_object_stats(tc);

Is there a reason why are are not calling this function once in the test setup? It will be called for every test iteration when the test is passed the -i option...

Otherwise it looks good.

Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

PATCH 2/4 syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

Quoted 33 lines · Cyril Hrubis

Hi!

Quoted 9 lines

Newly defined test file to validate the fanotify FAN_REPORT_FID functionality.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++

This is missing the runtest entry in runtest/syscalls so that the test is picked up by the testrunner.

And the same bug slipped in during review for fanotify12 so I've commited a fix that adds it there.

...

Quoted 13 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +13 -0
+static void do_test(unsigned int number)
+{
+     unsigned int i;
+     int len, fds[ARRAY_SIZE(objects)];
+
+     struct file_handle *event_file_handle;
+     struct fanotify_event_metadata *metadata;
+     struct fanotify_event_info_fid *event_fid;
+     struct test_case_t *tc = &test_cases[number];
+     struct fanotify_mark_type *mark = &tc->mark;
+
+     tst_res(TINFO,
+             "Test #%d: FAN_REPORT_FID with mark flag: %s",
Quoted 9 lines

testcases/kernel/syscalls/fanotify/fanotify13.c line 197

Quoted 4 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +4 -0
+             number, mark->name);
+
+     /* Gets the filesystem fsid and file handle for each object */
+     get_object_stats(tc);

Is there a reason why are are not calling this function once in the test setup? It will be called for every test iteration when the test is passed the -i option...

I think that's an oversight. It could be called once during setup.

Thanks,
Amir.

#6 lore raw

PATCH 2/4 syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

Quoted 13 lines · Amir Goldstein
Quoted 12 lines · Cyril Hrubis

Hi!

Quoted 9 lines

Newly defined test file to validate the fanotify FAN_REPORT_FID functionality.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++
Quoted 8 lines
Quoted 8 lines

This is missing the runtest entry in runtest/syscalls so that the test is picked up by the testrunner.

And the same bug slipped in during review for fanotify12 so I've commited a fix that adds it there.

...

My apologies, this was a simple oversight. I've gone ahead and updated it accordingly.

Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +13 -0
+static void do_test(unsigned int number)
+{
+     unsigned int i;
+     int len, fds[ARRAY_SIZE(objects)];
+
+     struct file_handle *event_file_handle;
+     struct fanotify_event_metadata *metadata;
+     struct fanotify_event_info_fid *event_fid;
+     struct test_case_t *tc = &test_cases[number];
+     struct fanotify_mark_type *mark = &tc->mark;
+
+     tst_res(TINFO,
+             "Test #%d: FAN_REPORT_FID with mark flag: %s",
Quoted 9 lines

testcases/kernel/syscalls/fanotify/fanotify13.c line 197

Quoted 4 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +4 -0
+             number, mark->name);
+
+     /* Gets the filesystem fsid and file handle for each object */
+     get_object_stats(tc);

Is there a reason why are are not calling this function once in the test setup? It will be called for every test iteration when the test is passed the -i option...

Quoted 1 line

I think that's an oversight. It could be called once during setup.

Indeed. I've changed this so that the function is now only called once from within do_setup(). There was one code snippet (added below) that I had to move out from get_object_stats() as there's a setup dependency for each test case.

--
event_set[i].expected_mask = tc->mask;
if (!objects[i].is_dir)

        event_set[i].expected_mask &= ~FAN_ONDIR;

--

I've added this snippet within setup_marks() as we're already iterating over the objects array and passing in a task_struct_t object, which means we could also setup the expected mask for each expected event there. Unless anyone objects?

Signature · 1 line
Matthew Bobrowski
#7 lore raw

PATCH 2/4 syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality

Quoted 59 lines · Matthew Bobrowski
Quoted 13 lines · Amir Goldstein
Quoted 12 lines · Cyril Hrubis

Hi!

Quoted 9 lines

Newly defined test file to validate the fanotify FAN_REPORT_FID functionality.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  19 +-
 testcases/kernel/syscalls/fanotify/fanotify13.c | 329 ++++++++++++++++++++++++
Quoted 8 lines
Quoted 8 lines

This is missing the runtest entry in runtest/syscalls so that the test is picked up by the testrunner.

And the same bug slipped in during review for fanotify12 so I've commited a fix that adds it there.

...

My apologies, this was a simple oversight. I've gone ahead and updated it accordingly.

Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +13 -0
+static void do_test(unsigned int number)
+{
+     unsigned int i;
+     int len, fds[ARRAY_SIZE(objects)];
+
+     struct file_handle *event_file_handle;
+     struct fanotify_event_metadata *metadata;
+     struct fanotify_event_info_fid *event_fid;
+     struct test_case_t *tc = &test_cases[number];
+     struct fanotify_mark_type *mark = &tc->mark;
+
+     tst_res(TINFO,
+             "Test #%d: FAN_REPORT_FID with mark flag: %s",
Quoted 9 lines

testcases/kernel/syscalls/fanotify/fanotify13.c line 197

Quoted 4 lines
testcases/kernel/syscalls/fanotify/fanotify13.c new file +4 -0
+             number, mark->name);
+
+     /* Gets the filesystem fsid and file handle for each object */
+     get_object_stats(tc);

Is there a reason why are are not calling this function once in the test setup? It will be called for every test iteration when the test is passed the -i option...

Quoted 1 line

I think that's an oversight. It could be called once during setup.

Indeed. I've changed this so that the function is now only called once from within do_setup(). There was one code snippet (added below) that I had to move out from get_object_stats() as there's a setup dependency for each test case.

--
event_set[i].expected_mask = tc->mask;
if (!objects[i].is_dir)

Quoted 8 lines
        event_set[i].expected_mask &= ~FAN_ONDIR;

--

I've added this snippet within setup_marks() as we're already iterating over the objects array and passing in a task_struct_t object, which means we could also setup the expected mask for each expected event there. Unless anyone objects?

Sounds good to me.

Thanks,
Amir.

#8 lore raw

PATCH 3/4 syscalls/fanotify14: new test to validate FAN_REPORT_FID interface return values

In reply to Matthew Bobrowski

New test file has been introduced to validate that the fanotify interface returns the correct error values upon specifying invalid flags and masks in conjunction with FAN_REPORT_FID.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  25 ++++
 testcases/kernel/syscalls/fanotify/fanotify14.c | 170 ++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify14.c
testcases/kernel/syscalls/fanotify/.gitignore +1 -0
index 16bdd99e5..bf389c96a 100644
@@ -11,4 +11,5 @@
 /fanotify11
 /fanotify12
 /fanotify13
+/fanotify14
 /fanotify_child
testcases/kernel/syscalls/fanotify/fanotify.h +25 -0
index 450f3829d..46a4b6289 100644
@@ -64,6 +64,31 @@ static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
 #ifndef FAN_MARK_FILESYSTEM
 #define FAN_MARK_FILESYSTEM	0x00000100
 #endif
+/* New dirent event masks */
+#ifndef FAN_ATTRIB
+#define FAN_ATTRIB		0x00000004
+#endif
+#ifndef FAN_MOVED_FROM
+#define FAN_MOVED_FROM		0x00000040
+#endif
+#ifndef FAN_MOVED_TO
+#define FAN_MOVED_TO		0x00000080
+#endif
+#ifndef FAN_CREATE
+#define FAN_CREATE		0x00000100
+#endif
+#ifndef FAN_DELETE
+#define FAN_DELETE		0x00000200
+#endif
+#ifndef FAN_DELETE_SELF
+#define FAN_DELETE_SELF		0x00000400
+#endif
+#ifndef FAN_MOVE_SELF
+#define FAN_MOVE_SELF		0x00000800
+#endif
+#ifndef FAN_MOVE
+#define FAN_MOVE		(FAN_MOVED_FROM | FAN_MOVED_TO)
+#endif
 #ifndef FAN_OPEN_EXEC
 #define FAN_OPEN_EXEC		0x00001000
 #endif
testcases/kernel/syscalls/fanotify/fanotify14.c new file +170 -0

170 lines not on this page · raw message

Signature · 5 lines
2.16.4


-- 
Matthew Bobrowski
#9 lore raw

PATCH 3/4 syscalls/fanotify14: new test to validate FAN_REPORT_FID interface return values

Hi!
This one is missing runtest entry as well, otherwise looks fine.

Signature · 2 lines
Cyril Hrubis
[email protected]
#10 lore raw

PATCH 3/4 syscalls/fanotify14: new test to validate FAN_REPORT_FID interface return values

Quoted 2 lines · Cyril Hrubis

Hi!
This one is missing runtest entry as well, otherwise looks fine.

Simple oversight. I've updated the commit accordingly. I will post through a new patch series with all the fixes shortly.

Signature · 1 line
Matthew Bobrowski
#11 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

In reply to Matthew Bobrowski

New test file that provides coverage for new dirent events.

---
 testcases/kernel/syscalls/fanotify/.gitignore   |   1 +
 testcases/kernel/syscalls/fanotify/fanotify15.c | 256 ++++++++++++++++++++++++
 2 files changed, 257 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify15.c
testcases/kernel/syscalls/fanotify/.gitignore +1 -0
index bf389c96a..68e4cc7aa 100644
@@ -12,4 +12,5 @@
 /fanotify12
 /fanotify13
 /fanotify14
+/fanotify15
 /fanotify_child
testcases/kernel/syscalls/fanotify/fanotify15.c new file +256 -0

256 lines not on this page · raw message

Signature · 5 lines
2.16.4


-- 
Matthew Bobrowski
#12 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Hi!
This one misses runtest entry as well.

Quoted 54 lines
testcases/kernel/syscalls/fanotify/fanotify15.c new file +54 -0
+#define BUF_SIZE 256
+#define EVENT_MAX 256 
+
+#define MOUNT_POINT "mntpoint"
+#define TEST_DIR MOUNT_POINT"/test_dir"
+#define DIR1 TEST_DIR"/dir1"
+#define DIR2 TEST_DIR"/dir2"
+#define FILE1 TEST_DIR"/file1"
+#define FILE2 TEST_DIR"/file2"
+
+struct event_t {
+	unsigned long long mask;
+	__kernel_fsid_t fsid;
+	struct file_handle handle;
+	char buf[MAX_HANDLE_SZ];
+};
+
+static int fanotify_fd;
+static char events_buf[BUF_SIZE];
+static struct event_t event_set[EVENT_MAX];
+
+static void do_setup(void)
+{
+	int fd;
+
+	/* Check kernel for fanotify support */
+	fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
+	SAFE_CLOSE(fd);
+
+	fanotify_fd = fanotify_init(FAN_REPORT_FID, O_RDONLY);
+	if (fanotify_fd == -1) {
+		if (errno == EINVAL)
+			tst_brk(TCONF,
+				"FAN_REPORT_FID not supported in kernel");
+		tst_brk(TBROK | TERRNO,
+			"fanotify_init(FAN_REPORT_FID, O_RDONLY) failed");
+	}
+
+	SAFE_MKDIR(TEST_DIR, 0755);
+}
+
+static void get_fid_data(int i, const char *path)
+{
+	int mount_id;
+	struct statfs stats;
+
+	if (statfs(path, &stats) == -1)
+		tst_brk(TBROK | TERRNO,
+			"statfs(%s, ...) failed", path);
+	memcpy(&event_set[i].fsid, &stats.f_fsid, sizeof(stats.f_fsid));
+
+	event_set[i].handle.handle_bytes = MAX_HANDLE_SZ;
+	if (name_to_handle_at(AT_FDCWD, path, &event_set[i].handle,
+				&mount_id, 0) == -1) {

testcases/kernel/syscalls/fanotify/fanotify15.c line 91

Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify15.c new file +10 -0
+		if (errno == EOPNOTSUPP) {
+			tst_brk(TCONF,
+				"filesystem %s does not support file handles",
+				tst_device->fs_type);
+		}
+		tst_brk(TBROK | TERRNO,
+			"name_to_handle_at(AT_FDCWD, %s, ...) failed",
+			path);
+	}
+}

Can put this code into an header in the fanotify/ directory along with the event_t structure definiton so that we do not carry two copies of nearly identical code.

If we passed a pointer to the event_t structure instead of the index we can call this function in a loop in the get_object_stats() in fanotify13, right?

Signature · 2 lines
Cyril Hrubis
[email protected]
#13 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Quoted 64 lines · Cyril Hrubis

Hi!
This one misses runtest entry as well.

Quoted 60 lines
testcases/kernel/syscalls/fanotify/fanotify15.c new file +60 -0
+#define BUF_SIZE 256
+#define EVENT_MAX 256
+
+#define MOUNT_POINT "mntpoint"
+#define TEST_DIR MOUNT_POINT"/test_dir"
+#define DIR1 TEST_DIR"/dir1"
+#define DIR2 TEST_DIR"/dir2"
+#define FILE1 TEST_DIR"/file1"
+#define FILE2 TEST_DIR"/file2"
+
+struct event_t {
+     unsigned long long mask;
+     __kernel_fsid_t fsid;
+     struct file_handle handle;
+     char buf[MAX_HANDLE_SZ];
+};
+
+static int fanotify_fd;
+static char events_buf[BUF_SIZE];
+static struct event_t event_set[EVENT_MAX];
+
+static void do_setup(void)
+{
+     int fd;
+
+     /* Check kernel for fanotify support */
+     fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
+     SAFE_CLOSE(fd);
+
+     fanotify_fd = fanotify_init(FAN_REPORT_FID, O_RDONLY);
+     if (fanotify_fd == -1) {
+             if (errno == EINVAL)
+                     tst_brk(TCONF,
+                             "FAN_REPORT_FID not supported in kernel");
+             tst_brk(TBROK | TERRNO,
+                     "fanotify_init(FAN_REPORT_FID, O_RDONLY) failed");
+     }
+
+     SAFE_MKDIR(TEST_DIR, 0755);
+}
+
+static void get_fid_data(int i, const char *path)
+{
+     int mount_id;
+     struct statfs stats;
+
+     if (statfs(path, &stats) == -1)
+             tst_brk(TBROK | TERRNO,
+                     "statfs(%s, ...) failed", path);
+     memcpy(&event_set[i].fsid, &stats.f_fsid, sizeof(stats.f_fsid));
+
+     event_set[i].handle.handle_bytes = MAX_HANDLE_SZ;
+     if (name_to_handle_at(AT_FDCWD, path, &event_set[i].handle,
+                             &mount_id, 0) == -1) {
+             if (errno == EOPNOTSUPP) {
+                     tst_brk(TCONF,
+                             "filesystem %s does not support file handles",
+                             tst_device->fs_type);
+             }
+             tst_brk(TBROK | TERRNO,
Quoted 8 lines

testcases/kernel/syscalls/fanotify/fanotify15.c line 91

Quoted 4 lines
testcases/kernel/syscalls/fanotify/fanotify15.c new file +4 -0
+                     "name_to_handle_at(AT_FDCWD, %s, ...) failed",
+                     path);
+     }
+}

Can put this code into an header in the fanotify/ directory along with the event_t structure definiton so that we do not carry two copies of nearly identical code.

Correct, but I would rather leave the event_t structure private to the test because it may have other fields in future tests of similar pattern...

Quoted 5 lines

If we passed a pointer to the event_t structure instead of the index we can call this function in a loop in the get_object_stats() in fanotify13, right?

...so I'd prefer to pass a pointer to fsid and file_handle to helper instead, something like:
void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid, and struct file_handle *handle)

Thanks,
Amir.

#14 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Hi!

Quoted 13 lines
Quoted 3 lines

Can put this code into an header in the fanotify/ directory along with the event_t structure definiton so that we do not carry two copies of nearly identical code.

Correct, but I would rather leave the event_t structure private to the test because it may have other fields in future tests of similar pattern...

Quoted 5 lines

If we passed a pointer to the event_t structure instead of the index we can call this function in a loop in the get_object_stats() in fanotify13, right?

Quoted 4 lines

...so I'd prefer to pass a pointer to fsid and file_handle to helper instead, something like:
void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid, and struct file_handle *handle)

Sounds good to me as well.

Signature · 2 lines
Cyril Hrubis
[email protected]
#15 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Quoted 15 lines · Cyril Hrubis

Hi!

Quoted 13 lines
Quoted 3 lines

Can put this code into an header in the fanotify/ directory along with the event_t structure definiton so that we do not carry two copies of nearly identical code.

Correct, but I would rather leave the event_t structure private to the test because it may have other fields in future tests of similar pattern...

Quoted 5 lines

If we passed a pointer to the event_t structure instead of the index we can call this function in a loop in the get_object_stats() in fanotify13, right?

Quoted 7 lines
Quoted 4 lines

...so I'd prefer to pass a pointer to fsid and file_handle to helper instead, something like:
void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid, and struct file_handle *handle)

Sounds good to me as well.

BTW, I think fanotify14/fanotify15 could use
.all_filesystems = 1

The file handle/fsid issues are filesystem specific (e.g. ENODEV error).

Is anybody else seeing these errors with all_filesystems?

tst_test.c:1157: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' mkfs.xfs: Use the -f option to force overwrite. tst_mkfs.c:101: BROK: mkfs.xfs:1: tst_test.c failed with 751

Thanks,
Amir.

#16 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Hi!

Quoted 6 lines

Is anybody else seeing these errors with all_filesystems?

tst_test.c:1157: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' mkfs.xfs: Use the -f option to force overwrite. tst_mkfs.c:101: BROK: mkfs.xfs:1: tst_test.c failed with 751

That looks strange. If I'm looking at this correctly the 751 is returned from tst_run_cmd() which basically returns the value from waitpid() but we call WEXITSTATUS() there before we return the number, which should return only least significant 8 bits.

So as far as I can tell this output is impossible.

Signature · 2 lines
Cyril Hrubis
[email protected]
#17 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 6 lines

Is anybody else seeing these errors with all_filesystems?

tst_test.c:1157: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' mkfs.xfs: Use the -f option to force overwrite. tst_mkfs.c:101: BROK: mkfs.xfs:1: tst_test.c failed with 751

Quoted 7 lines

That looks strange. If I'm looking at this correctly the 751 is returned from tst_run_cmd() which basically returns the value from waitpid() but we call WEXITSTATUS() there before we return the number, which should return only least significant 8 bits.

So as far as I can tell this output is impossible.

Don't know about that, but the fact is that mkfs.xfs refuses to format a device that has an existing filesystem on it without the -f flag.

Does that ring a bell?
I think it may be because I upgraded xfsprogs to v4.20. Maybe that's a mkfs.xfs bug.

Thanks,
Amir.

#18 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Hi!

Quoted 4 lines

Don't know about that, but the fact is that mkfs.xfs refuses to format a device that has an existing filesystem on it without the -f flag.

Does that ring a bell?

It does, but we clean up first 512kB of the block device prior to call to mkfs.xfs exactly to avoid that.

Quoted 1 line

I think it may be because I upgraded xfsprogs to v4.20.

Quite likely.

Quoted 1 line

Maybe that's a mkfs.xfs bug.

Possibly.

Signature · 2 lines
Cyril Hrubis
[email protected]
#19 lore raw

PATCH 4/4 syscalls/fanotify15: verify fid for dirent events

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 4 lines

Don't know about that, but the fact is that mkfs.xfs refuses to format a device that has an existing filesystem on it without the -f flag.

Does that ring a bell?

It does, but we clean up first 512kB of the block device prior to call to mkfs.xfs exactly to avoid that.

Quoted 8 lines
Quoted 1 line

I think it may be because I upgraded xfsprogs to v4.20.

Quite likely.

Quoted 1 line

Maybe that's a mkfs.xfs bug.

Possibly.

No. seems like a local problem.
I must have built mkfs.xfs without ENABLE_BLKID.

All good now.

Thanks,
Amir.