Skip to contentSkip to conversation

syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

PATCH New Jan Stancek 2 participants 8 messages Mar 4, 2019 – Mar 5, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM sets up monitoring that can cover entire root "/". So a random background process can interfere with test.

For example run test while running following on another terminal to reproduce:
while [ True ]; do ls -la /root > /dev/null; done

Test fails and hangs until timeout:
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
fanotify03.c:168: INFO: Test #0: inode mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7317 fd=7
fanotify03.c:236: PASS: got event: mask=20000 pid=7317 fd=7
fanotify03.c:136: PASS: child exited correctly
fanotify03.c:168: INFO: Test #1: mount mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7318 fd=7
fanotify03.c:231: FAIL: got event: mask=20000 pid=7306 (expected 7318) fd=7 fanotify03.c:223: FAIL: got event: mask=20000 (expected 0) pid=7318 fd=7
Test timeouted, sending SIGKILL!
tst_test.c:1125: INFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1 tst_test.c:1126: BROK: Test killed! (timeout?)

Skip events that are not from our child when testing FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM. If these are permission events, allow everything.

---
 testcases/kernel/syscalls/fanotify/fanotify03.c | 36 +++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify03.c +34 -2
index ae240a0eb505..81f1b8f76d9c 100644
@@ -292,6 +292,38 @@ static void test_fanotify(unsigned int n)
 		 * reported should exactly match the event mask within the
 		 * event set.
 		 */
+
+		/* When testing MOUNT or FILESYSTEM, there is a chance
+		 * we get event that is not from our child, skip it */
+		if ((tc->mark.flag & (FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM))
+			&& (event->pid != child_pid)) {
+			struct fanotify_response resp;
+
+			tst_res(TINFO,
+				"skipping event: mask=%llx pid=%u fd=%d "
+				"event->fd: %d child_pid=%u ",
+				(unsigned long long)event->mask,
+				(unsigned)event->pid, event->fd,
+				event->fd, (unsigned)child_pid);
+
+			if ((event->mask & LTP_ALL_PERM_EVENTS) == 0)
+				goto next;
+
+			resp.fd = event->fd;
+			resp.response = FAN_ALLOW;
+
+			/* We could be racing with child_handler() here,
+			 * so ignore EBADF from write() */
+			TEST(write(fd_notify, &resp, sizeof(resp)));
+			if (TST_RET == -1) {
+				if (TST_ERR != EBADF)
+					tst_brk(TBROK | TTERRNO, "write failed");
+			} else if (TST_RET != sizeof(resp)) {
+				tst_brk(TBROK, "write short: %ld", TST_RET);
+			}
+			goto next;
+		}
+
 		if (event->mask != event_set[test_num].mask) {
 			tst_res(TFAIL,
 				"got event: mask=%llx (expected %llx) "
@@ -323,12 +355,12 @@ static void test_fanotify(unsigned int n)
 			SAFE_WRITE(1, fd_notify, &resp, sizeof(resp));
 		}
 
+		test_num++;
+next:
 		i += event->event_len;
 
 		if (event->fd != FAN_NOFD)
 			SAFE_CLOSE(event->fd);
-
-		test_num++;
 	}
 
 	for (; test_num < tc->event_count; test_num++) {
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

Quoted 23 lines · Jan Stancek

FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM sets up monitoring that can cover entire root "/". So a random background process can interfere with test.

For example run test while running following on another terminal to reproduce:
while [ True ]; do ls -la /root > /dev/null; done

Test fails and hangs until timeout:
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
fanotify03.c:168: INFO: Test #0: inode mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7317 fd=7
fanotify03.c:236: PASS: got event: mask=20000 pid=7317 fd=7
fanotify03.c:136: PASS: child exited correctly
fanotify03.c:168: INFO: Test #1: mount mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7318 fd=7
fanotify03.c:231: FAIL: got event: mask=20000 pid=7306 (expected 7318) fd=7 fanotify03.c:223: FAIL: got event: mask=20000 (expected 0) pid=7318 fd=7
Test timeouted, sending SIGKILL!
tst_test.c:1125: INFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1 tst_test.c:1126: BROK: Test killed! (timeout?)

Quoted 3 lines

Skip events that are not from our child when testing FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM. If these are permission events, allow everything.

That's the wrong way to fix the problem.

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I am assuming you will take care of this.
If you need me to get involved with the fix let me know.

Thanks,
Amir.

#2 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

----- Original Message -----

Quoted 26 lines · Jan Stancek
Quoted 25 lines

FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM sets up monitoring that can cover entire root "/". So a random background process can interfere with test.

For example run test while running following on another terminal to reproduce:
while [ True ]; do ls -la /root > /dev/null; done

Test fails and hangs until timeout:
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify03.c:168: INFO: Test #0: inode mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7317 fd=7 fanotify03.c:236: PASS: got event: mask=20000 pid=7317 fd=7 fanotify03.c:136: PASS: child exited correctly fanotify03.c:168: INFO: Test #1: mount mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7318 fd=7 fanotify03.c:231: FAIL: got event: mask=20000 pid=7306 (expected 7318) fd=7
fanotify03.c:223: FAIL: got event: mask=20000 (expected 0) pid=7318 fd=7 Test timeouted, sending SIGKILL!
tst_test.c:1125: INFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
tst_test.c:1126: BROK: Test killed! (timeout?)

Quoted 5 lines
Quoted 3 lines

Skip events that are not from our child when testing FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM. If these are permission events, allow everything.

That's the wrong way to fix the problem.

Can you elaborate? The test still fails if we don't get event from our child.

Quoted 4 lines

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

I recall (from long time ago) that we saw some daemons that could probe new mount points, like gvsfd.

Quoted 5 lines

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I see fanotify01 failing as well.

Quoted 7 lines

I am assuming you will take care of this.
If you need me to get involved with the fix let me know.

Thanks,
Amir.

#3 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

Quoted 30 lines · Jan Stancek

----- Original Message -----

Quoted 26 lines · Jan Stancek
Quoted 25 lines

FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM sets up monitoring that can cover entire root "/". So a random background process can interfere with test.

For example run test while running following on another terminal to reproduce:
while [ True ]; do ls -la /root > /dev/null; done

Test fails and hangs until timeout:
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify03.c:168: INFO: Test #0: inode mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7317 fd=7 fanotify03.c:236: PASS: got event: mask=20000 pid=7317 fd=7 fanotify03.c:136: PASS: child exited correctly fanotify03.c:168: INFO: Test #1: mount mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7318 fd=7 fanotify03.c:231: FAIL: got event: mask=20000 pid=7306 (expected 7318) fd=7
fanotify03.c:223: FAIL: got event: mask=20000 (expected 0) pid=7318 fd=7 Test timeouted, sending SIGKILL!
tst_test.c:1125: INFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
tst_test.c:1126: BROK: Test killed! (timeout?)

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Skip events that are not from our child when testing FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM. If these are permission events, allow everything.

That's the wrong way to fix the problem.

Can you elaborate? The test still fails if we don't get event from our child.

I overlooked the fact that test sets a mark on TEST_APP outside of test device.

fanotify tests need to be contained to the test device, so that changes to /root will not interfere with the tests.

Therefore, TEST_APP should be copied to MOUNT_PATH on setup.

This is done by fanotify10 and SHOULD be done by fanotify03 and fanotify12 as well.

Quoted 8 lines
Quoted 4 lines

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

I recall (from long time ago) that we saw some daemons that could probe new mount points, like gvsfd.

I am not following. How is that related to our case?

Quoted 8 lines
Quoted 5 lines

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I see fanotify01 failing as well.

Failing how? please provide more details.

Thanks,
Amir.

#4 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

----- Original Message -----

Quoted 47 lines · Jan Stancek
Quoted 33 lines

----- Original Message -----

Quoted 29 lines · Jan Stancek
Quoted 28 lines

FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM sets up monitoring that can cover entire root "/". So a random background process can interfere with test.

For example run test while running following on another terminal to reproduce:
while [ True ]; do ls -la /root > /dev/null; done

Test fails and hangs until timeout:
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify03.c:168: INFO: Test #0: inode mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7317 fd=7 fanotify03.c:236: PASS: got event: mask=20000 pid=7317 fd=7 fanotify03.c:136: PASS: child exited correctly fanotify03.c:168: INFO: Test #1: mount mark permission events fanotify03.c:236: PASS: got event: mask=10000 pid=7318 fd=7 fanotify03.c:231: FAIL: got event: mask=20000 pid=7306 (expected 7318)
fd=7
fanotify03.c:223: FAIL: got event: mask=20000 (expected 0) pid=7318 fd=7
Test timeouted, sending SIGKILL!
tst_test.c:1125: INFO: If you are running on slow machine, try exporting
LTP_TIMEOUT_MUL > 1
tst_test.c:1126: BROK: Test killed! (timeout?)

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Skip events that are not from our child when testing FAN_MARK_MOUNT and FAN_MARK_FILESYSTEM. If these are permission events, allow everything.

That's the wrong way to fix the problem.

Can you elaborate? The test still fails if we don't get event from our child.

I overlooked the fact that test sets a mark on TEST_APP outside of test device.

Quoted 7 lines

fanotify tests need to be contained to the test device, so that changes to /root will not interfere with the tests.

Therefore, TEST_APP should be copied to MOUNT_PATH on setup.

This is done by fanotify10 and SHOULD be done by fanotify03 and fanotify12 as well.

OK, I'll look into .mount_device for now.

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

I recall (from long time ago) that we saw some daemons that could probe new mount points, like gvsfd.

I am not following. How is that related to our case?

It's a potential (outside) source of events, that won't originate from test child process.

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I see fanotify01 failing as well.

Failing how? please provide more details.

tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify01.c:68: INFO: Test #0: inode mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:290: PASS: got event: mask=b pid=28138 fd=10 fanotify01.c:290: PASS: got event: mask=9 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2 pid=28138 fd=13 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=12 fanotify01.c:68: INFO: Test #1: mount mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=10 fanotify01.c:256: FAIL: got event: mask=20 (expected 1) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 ... <previous message repeats hundreds of times> fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=14 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=8 pid=28138 fd=13 fanotify01.c:68: INFO: Test #2: filesystem mark events fanotify01.c:77: CONF: FAN_MARK_FILESYSTEM not supported in kernel?

Regards,
Jan

#5 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I recall (from long time ago) that we saw some daemons that could probe new mount points, like gvsfd.

I am not following. How is that related to our case?

It's a potential (outside) source of events, that won't originate from test child process.

Ah. I see.
But the problem with filtering by generator pid is that you would need to fix all fanotify tests to do that and some tests actually verify that reported pid is correct, so chicken and egg situation.

Let's see if this is a real problem that people run into or just a concern. The real issue that you saw was from test bug that wasn't setting the mark on a test device but on the system mount.

Quoted 76 lines
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I see fanotify01 failing as well.

Failing how? please provide more details.

tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify01.c:68: INFO: Test #0: inode mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:290: PASS: got event: mask=b pid=28138 fd=10 fanotify01.c:290: PASS: got event: mask=9 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2 pid=28138 fd=13 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=12 fanotify01.c:68: INFO: Test #1: mount mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=10 fanotify01.c:256: FAIL: got event: mask=20 (expected 1) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 ... <previous message repeats hundreds of times>

Quoted 9 lines

fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=14 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=8 pid=28138 fd=13 fanotify01.c:68: INFO: Test #2: filesystem mark events fanotify01.c:77: CONF: FAN_MARK_FILESYSTEM not supported in kernel?

Which kernel is that?

Can you say which program is run by the processes with pid 5277? 28138?

Thanks,
Amir.

#6 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

Quoted 79 lines
Quoted 69 lines
Quoted 4 lines
Quoted 2 lines

I see fanotify01 failing as well.

Failing how? please provide more details.

tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify01.c:68: INFO: Test #0: inode mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:290: PASS: got event: mask=b pid=28138 fd=10 fanotify01.c:290: PASS: got event: mask=9 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2 pid=28138 fd=13 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=12 fanotify01.c:68: INFO: Test #1: mount mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=10 fanotify01.c:256: FAIL: got event: mask=20 (expected 1) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 ... <previous message repeats hundreds of times>

Quoted 9 lines

fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=14 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=8 pid=28138 fd=13 fanotify01.c:68: INFO: Test #2: filesystem mark events fanotify01.c:77: CONF: FAN_MARK_FILESYSTEM not supported in kernel?

Quoted 4 lines

Which kernel is that?

Can you say which program is run by the processes with pid 5277? 28138?

Nevermind. My work branch has already isolated fanotify01, so I didn't realize it was also buggy on master.

Your fix should have resolved those errors I presume.

Thanks,
Amir.

#7 lore raw

PATCH 1/1 syscalls/fanotify03: skip events from other pids when testing MOUNT|FILESYSTEM

In reply to Amir Goldstein

----- Original Message -----

Quoted 113 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Please use .mount_device = 1 to contain the effects of FAN_MARK_FILESYSTEM/FAN_MARK_MOUNT to events on the test device.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I recall (from long time ago) that we saw some daemons that could probe new mount points, like gvsfd.

I am not following. How is that related to our case?

It's a potential (outside) source of events, that won't originate from test child process.

Ah. I see.
But the problem with filtering by generator pid is that you would need to fix all fanotify tests to do that and some tests actually verify that reported pid is correct, so chicken and egg situation.

Let's see if this is a real problem that people run into or just a concern. The real issue that you saw was from test bug that wasn't setting the mark on a test device but on the system mount.

Quoted 76 lines
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

While at it, I see that fanotify05 also sets a FAN_MARK_MOUNT without having a private test mount.
Can fix this by either .mount_device = 1 or using the bind mount approach taken by fanotify06.

I see fanotify01 failing as well.

Failing how? please provide more details.

tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s fanotify01.c:68: INFO: Test #0: inode mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:290: PASS: got event: mask=b pid=28138 fd=10 fanotify01.c:290: PASS: got event: mask=9 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2 pid=28138 fd=13 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=12 fanotify01.c:68: INFO: Test #1: mount mark events fanotify01.c:290: PASS: got event: mask=31 pid=28138 fd=8 fanotify01.c:290: PASS: got event: mask=11 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=10 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=2a pid=28138 fd=9 fanotify01.c:290: PASS: got event: mask=a pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=8 pid=28138 fd=-2 fanotify01.c:290: PASS: got event: mask=20 pid=28138 fd=11 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=10 fanotify01.c:256: FAIL: got event: mask=20 (expected 1) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 2) pid=5277 fd=-2 fanotify01.c:256: FAIL: got event: mask=20 (expected 8) pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=20 pid=5277 fd=-2 ... <previous message repeats hundreds of times>

Quoted 9 lines

fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=1 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=14 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=2 pid=28138 fd=-2 fanotify01.c:249: FAIL: got unnecessary event: mask=8 pid=28138 fd=13 fanotify01.c:68: INFO: Test #2: filesystem mark events fanotify01.c:77: CONF: FAN_MARK_FILESYSTEM not supported in kernel?

Quoted 1 line

Which kernel is that?

The specific case above was RHEL7.6 kernel (3.10.0 based).

Quoted 2 lines

Can you say which program is run by the processes with pid 5277? 28138?

I can't, system has been returned to pool an re-used for other jobs.

5277 is likely some daemon, my guess would be test harness. 28138 looks like the test itself, same pid is reported at the beginning of output.

I can easily reproduce fanotify01 failure on 5.0 with
while [ True ]; do ls -la /root > /dev/null; done
running in parallel.

Quoted 4 lines

Thanks,
Amir.