* [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
@ 2025-01-22 17:24 Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
` (5 more replies)
0 siblings, 6 replies; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
Hi all,
Following tests for fanotify code in v6.13.
1. The new test case in fanotify13 fails as follows on kernels v6.6..v6.12:
fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
fanotify13.c:282: TFAIL: handle_bytes (180003) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
The fix was already backported to v6.12.10.
It was also backported to v6.6.72,
but then reverted due to a backport bug in v6.6.73
and it now staged again for v6.6.74.
2. The new variant of fanotify21 is skipped on kernels <= v6.12
This variant tests the new feature flag FAN_REPORT_FD_ERROR, which is
not effectively a bug fix.
Because this feature was added as a consequence of a bug report,
it was auto backported to v6.12.5 and to v6.6.66, but I do not
feel comfortable with adding a fix tag to force distros to backport
this feature.
Thanks,
Amir.
Amir Goldstein (5):
fanotify13: Verify that we did not get an extra event
fanotify13: Add test case for FAN_DELETE_SELF
fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR
fanotify21: Test reporting event with RDWR fd on RO mount
fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR
include/lapi/fanotify.h | 4 +
testcases/kernel/syscalls/fanotify/fanotify.h | 1 +
.../kernel/syscalls/fanotify/fanotify05.c | 18 +++-
.../kernel/syscalls/fanotify/fanotify13.c | 90 ++++++++++++++++---
.../kernel/syscalls/fanotify/fanotify21.c | 89 ++++++++++++++++--
5 files changed, 177 insertions(+), 25 deletions(-)
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
@ 2025-01-22 17:24 ` Amir Goldstein
2025-01-23 17:18 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 2/5] fanotify13: Add test case for FAN_DELETE_SELF Amir Goldstein
` (4 subsequent siblings)
5 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
For example, verify that we did not get an event on a directory object
without requesting FAN_ONDIR. Also, report a test failure if no events
received at all instead of blocking on read of fanotify_fd.
With this change, the test fails with overlayfs variants over btrfs,
because the size of fid of overalyfs over btrfs is about 90 bytes and
the events on the three objects do not all fit into a single 256 bytes
buffer read. Increase the size of the events buffer to fix this failure.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify13.c | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 5cd857707..16fd99ba1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -34,7 +34,7 @@
#include "fanotify.h"
#define PATH_LEN 128
-#define BUF_SIZE 256
+#define BUF_SIZE 1024
#define DIR_ONE "dir_one"
#define FILE_ONE "file_one"
#define FILE_TWO "file_two"
@@ -130,10 +130,15 @@ static int setup_marks(unsigned int fd, struct test_case_t *tc)
SAFE_FANOTIFY_MARK(fd, FAN_MARK_ADD | mark->flag, tc->mask,
AT_FDCWD, objects[i].path);
- /* Setup the expected mask for each generated event */
+ /*
+ * Setup the expected mask for each generated event.
+ * No events are expected on directory without FAN_ONDIR.
+ */
event_set[i].expected_mask = tc->mask;
if (!objects[i].is_dir)
event_set[i].expected_mask &= ~FAN_ONDIR;
+ else if (!(event_set[i].expected_mask & FAN_ONDIR))
+ event_set[i].expected_mask = 0;
}
return 0;
}
@@ -163,7 +168,8 @@ static void do_test(unsigned int number)
return;
}
- fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID, O_RDONLY);
+ fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID |
+ FAN_NONBLOCK, O_RDONLY);
/*
* Place marks on a set of objects and setup the expected masks
@@ -279,6 +285,16 @@ static void do_test(unsigned int number)
FSID_VAL_MEMBER(event_fid->fsid, 1),
*(unsigned long *) event_file_handle->f_handle);
}
+
+ /*
+ * Verify that we did not get an extra event, for example, that we did
+ * not get an event on directory without FAN_ONDIR.
+ */
+ if (event_set[i].expected_mask) {
+ tst_res(TFAIL,
+ "Did not get an expected event (expected: %llx)",
+ event_set[i].expected_mask);
+ }
out:
SAFE_CLOSE(fanotify_fd);
}
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [LTP] [PATCH 2/5] fanotify13: Add test case for FAN_DELETE_SELF
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
@ 2025-01-22 17:24 ` Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR Amir Goldstein
` (3 subsequent siblings)
5 siblings, 0 replies; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
Verify that FAN_DELETE_SELF on overlayfs reports a valid file handle.
This was fixed in v6.13-rc7 and backported to v6.12.10 and v6.6.74.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify13.c | 68 ++++++++++++++++---
1 file changed, 57 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 16fd99ba1..67f05da20 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -15,6 +15,15 @@
/*
* This is also regression test for:
* c285a2f01d69 ("fanotify: update connector fsid cache on add mark")
+ *
+ * The test variants 1-2 are regression tests for:
+ * bc2473c90fca5 ("ovl: enable fsnotify events on underlying real files")
+ *
+ * The test variants 3-4 are tests for overlay fid events supprted since v6.6:
+ * 16aac5ad1fa9 ("ovl: support encoding non-decodable file handles")
+ *
+ * The last test case for FAN_DELETE_SELF is a regression test for:
+ * c45beebfde34a ("ovl: support encoding fid from inode with no alias")
*/
#define _GNU_SOURCE
@@ -86,7 +95,12 @@ static struct test_case_t {
{
INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
FAN_OPEN | FAN_CLOSE_NOWRITE | FAN_ONDIR
- }
+ },
+ /* Keep this test case last because it deletes the test files */
+ {
+ INIT_FANOTIFY_MARK_TYPE(INODE),
+ FAN_DELETE_SELF | FAN_ONDIR
+ },
};
static int ovl_mounted;
@@ -111,6 +125,18 @@ static void create_objects(void)
}
}
+static void delete_objects(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(objects); i++) {
+ if (objects[i].is_dir)
+ SAFE_RMDIR(objects[i].path);
+ else
+ SAFE_UNLINK(objects[i].path);
+ }
+}
+
static void get_object_stats(void)
{
unsigned int i;
@@ -155,8 +181,10 @@ static void do_test(unsigned int number)
struct fanotify_mark_type *mark = &tc->mark;
tst_res(TINFO,
- "Test #%d.%d: FAN_REPORT_FID with mark flag: %s",
- number, tst_variant, mark->name);
+ "Test #%d.%d: FAN_REPORT_FID of %s events with mark type %s",
+ number, tst_variant,
+ (tc->mask & FAN_DELETE_SELF) ? "delete" : "open/close",
+ mark->name);
if (tst_variant && !ovl_mounted) {
tst_res(TCONF, "overlayfs not supported on %s", tst_device->fs_type);
@@ -184,23 +212,40 @@ static void do_test(unsigned int number)
tst_res(TCONF, "overlayfs base fs cannot be watched with mount mark");
goto out;
}
+ if (tc->mask & FAN_DELETE_SELF) {
+ /* The eviction of base fs inodes is defered due to overlay held reference */
+ tst_res(TCONF, "overlayfs base fs cannot be watched for delete self events");
+ goto out;
+ }
SAFE_MOUNT(OVL_MNT, MOUNT_PATH, "none", MS_BIND, NULL);
}
/* Generate sequence of FAN_OPEN events on objects */
- for (i = 0; i < ARRAY_SIZE(objects); i++)
- fds[i] = SAFE_OPEN(objects[i].path, O_RDONLY);
+ if (tc->mask & FAN_OPEN) {
+ for (i = 0; i < ARRAY_SIZE(objects); i++)
+ fds[i] = SAFE_OPEN(objects[i].path, O_RDONLY);
+ }
/*
- * Generate sequence of FAN_CLOSE_NOWRITE events on objects. Each
- * FAN_CLOSE_NOWRITE event is expected to be merged with its
- * respective FAN_OPEN event that was performed on the same object.
+ * Generate sequence of FAN_CLOSE_NOWRITE events on objects.
+ * Each FAN_CLOSE_NOWRITE event is expected to be merged with the
+ * respective FAN_OPEN event that was reported on the same object.
*/
- for (i = 0; i < ARRAY_SIZE(objects); i++) {
- if (fds[i] > 0)
- SAFE_CLOSE(fds[i]);
+ if (tc->mask & FAN_CLOSE) {
+ for (i = 0; i < ARRAY_SIZE(objects); i++) {
+ if (fds[i] > 0)
+ SAFE_CLOSE(fds[i]);
+ }
}
+ /*
+ * Generate sequence of FAN_DELETE_SELF events on objects.
+ * Each FAN_DELETE_SELF event is expected to be merged with the
+ * respective OPEN/CLOSE events that were reported on the same object.
+ */
+ if (tc->mask & FAN_DELETE_SELF)
+ delete_objects();
+
if (tst_variant && !ovl_bind_mounted)
SAFE_UMOUNT(MOUNT_PATH);
@@ -392,6 +437,7 @@ static struct tst_test test = {
.tags = (const struct tst_tag[]) {
{"linux-git", "c285a2f01d69"},
{"linux-git", "bc2473c90fca"},
+ {"linux-git", "c45beebfde34a"},
{}
}
};
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 2/5] fanotify13: Add test case for FAN_DELETE_SELF Amir Goldstein
@ 2025-01-22 17:24 ` Amir Goldstein
2025-01-24 7:44 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount Amir Goldstein
` (2 subsequent siblings)
5 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
Expecting to get -EBADF instead of FAN_NOFD.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
include/lapi/fanotify.h | 4 ++++
testcases/kernel/syscalls/fanotify/fanotify.h | 1 +
.../kernel/syscalls/fanotify/fanotify05.c | 18 ++++++++++++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/lapi/fanotify.h b/include/lapi/fanotify.h
index 424514625..40ea7ead7 100644
--- a/include/lapi/fanotify.h
+++ b/include/lapi/fanotify.h
@@ -32,6 +32,10 @@
#define FAN_REPORT_DFID_NAME_TARGET (FAN_REPORT_DFID_NAME | \
FAN_REPORT_FID | FAN_REPORT_TARGET_FID)
#endif
+#ifndef FAN_REPORT_FD_ERROR
+#define FAN_REPORT_FD_ERROR 0x00002000
+#endif
+
/* Non-uapi convenience macros */
#ifndef FAN_REPORT_DFID_NAME_FID
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 554940a7e..48a44cc7e 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -213,6 +213,7 @@ static inline int fanotify_mark_supported_on_fs(uint64_t flag, const char *fname
#define TST_FANOTIFY_INIT_KNOWN_FLAGS \
(FAN_REPORT_DFID_NAME_TARGET | FAN_REPORT_TID | FAN_REPORT_PIDFD | \
+ FAN_REPORT_FD_ERROR | \
FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
/*
diff --git a/testcases/kernel/syscalls/fanotify/fanotify05.c b/testcases/kernel/syscalls/fanotify/fanotify05.c
index 12c240881..f1a132cbf 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify05.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify05.c
@@ -51,6 +51,10 @@ static struct tcase {
"Limited queue",
FAN_CLASS_NOTIF,
},
+ {
+ "Limited queue (FAN_REPORT_FD_ERROR)",
+ FAN_CLASS_NOTIF | FAN_REPORT_FD_ERROR,
+ },
{
"Unlimited queue",
FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE,
@@ -63,6 +67,8 @@ static char symlnk[BUF_SIZE];
static char fdpath[BUF_SIZE];
static int fd, fd_notify;
+static int fd_error_unsupported;
+
static struct fanotify_event_metadata event;
static void event_res(struct fanotify_event_metadata *event, int i)
@@ -110,9 +116,15 @@ static void test_fanotify(unsigned int n)
int len, nevents = 0, got_overflow = 0;
int num_files = max_events + 1;
int expect_overflow = !(tc->init_flags & FAN_UNLIMITED_QUEUE);
+ int nofd_err = tc->init_flags & FAN_REPORT_FD_ERROR ? -EBADF : FAN_NOFD;
tst_res(TINFO, "Test #%d: %s", n, tc->tname);
+ if (fd_error_unsupported && (tc->init_flags & FAN_REPORT_FD_ERROR)) {
+ FANOTIFY_INIT_FLAGS_ERR_MSG(FAN_REPORT_FD_ERROR, fd_error_unsupported);
+ return;
+ }
+
fd_notify = SAFE_FANOTIFY_INIT(tc->init_flags | FAN_NONBLOCK, O_RDONLY);
SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_MOUNT | FAN_MARK_ADD, FAN_OPEN,
@@ -142,7 +154,7 @@ static void test_fanotify(unsigned int n)
tst_res(expect_overflow ? TFAIL : TPASS, "Overflow event not generated!\n");
break;
}
- if (event.fd != FAN_NOFD) {
+ if (event.fd >= 0) {
/*
* Verify that events generated on unique files
* are received by the same order they were generated.
@@ -166,7 +178,7 @@ static void test_fanotify(unsigned int n)
break;
}
if (event.mask == FAN_Q_OVERFLOW) {
- if (got_overflow || event.fd != FAN_NOFD) {
+ if (got_overflow || event.fd != nofd_err) {
tst_res(TFAIL,
"%s overflow event: mask=%llx pid=%u fd=%d",
got_overflow ? "unexpected" : "invalid",
@@ -193,6 +205,8 @@ static void setup(void)
fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
SAFE_CLOSE(fd);
+ fd_error_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FD_ERROR, ".");
+
/* In older kernels this limit is fixed in kernel */
if (access(SYSFS_MAX_EVENTS, F_OK) && errno == ENOENT)
max_events = DEFAULT_MAX_EVENTS;
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
` (2 preceding siblings ...)
2025-01-22 17:24 ` [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR Amir Goldstein
@ 2025-01-22 17:24 ` Amir Goldstein
2025-01-24 8:01 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR Amir Goldstein
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
5 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
When event_f_flags request to open O_RDWR files for event->fd, the
event listener should not get events with fd on a read-only mount.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify21.c | 34 +++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c
index d54930f05..4324019fa 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify21.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify21.c
@@ -21,6 +21,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mount.h>
#include "tst_test.h"
#include "tst_safe_stdio.h"
#include "tst_safe_macros.h"
@@ -45,16 +46,25 @@ static struct test_case_t {
char *name;
int fork;
int want_pidfd_err;
+ int remount_ro;
} test_cases[] = {
{
"return a valid pidfd for event created by self",
0,
0,
+ 0,
},
{
"return invalid pidfd for event created by terminated child",
1,
FAN_NOPIDFD,
+ 0,
+ },
+ {
+ "fail to open rw fd for event created on read-only mount",
+ 0,
+ 0,
+ 1,
},
};
@@ -122,7 +132,7 @@ static void do_setup(void)
REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_PIDFD,
TEST_FILE);
- fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDONLY);
+ fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDWR);
SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD,
TEST_FILE);
@@ -143,6 +153,16 @@ static void do_test(unsigned int num)
tst_res(TINFO, "Test #%d: %s", num, tc->name);
+ if (tc->remount_ro) {
+ /* SAFE_MOUNT fails to remount FUSE */
+ if (mount(tst_device->dev, MOUNT_PATH, tst_device->fs_type,
+ MS_REMOUNT|MS_RDONLY, NULL) != 0) {
+ tst_brk(TFAIL,
+ "filesystem %s failed to remount readonly",
+ tst_device->fs_type);
+ }
+ }
+
/*
* Generate the event in either self or a child process. Event
* generation in a child process is done so that the FAN_NOPIDFD case
@@ -157,7 +177,16 @@ static void do_test(unsigned int num)
* Read all of the queued events into the provided event
* buffer.
*/
- len = SAFE_READ(0, fanotify_fd, event_buf, sizeof(event_buf));
+ len = read(fanotify_fd, event_buf, sizeof(event_buf));
+ if (len < 0) {
+ if (tc->remount_ro && errno == EROFS) {
+ tst_res(TPASS, "cannot read event with rw fd from a ro fs");
+ return;
+ }
+ tst_brk(TBROK | TERRNO, "reading fanotify events failed");
+ } else if (tc->remount_ro) {
+ tst_res(TFAIL, "got unexpected event with rw fd from a ro fs");
+ }
while (i < len) {
struct fanotify_event_metadata *event;
struct fanotify_event_info_pidfd *info;
@@ -297,6 +326,7 @@ static struct tst_test test = {
.cleanup = do_cleanup,
.all_filesystems = 1,
.needs_root = 1,
+ .mount_device = 1,
.mntpoint = MOUNT_PATH,
.forks_child = 1,
};
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
` (3 preceding siblings ...)
2025-01-22 17:24 ` [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount Amir Goldstein
@ 2025-01-22 17:24 ` Amir Goldstein
2025-01-24 8:09 ` Petr Vorel
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
5 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-22 17:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
Expect to get -EROFS as event->fd.
Expect to get -ESRCH instead of FAN_NOPIDFD.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify21.c | 61 ++++++++++++++++---
1 file changed, 51 insertions(+), 10 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c
index 4324019fa..8765767f2 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify21.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify21.c
@@ -57,7 +57,7 @@ static struct test_case_t {
{
"return invalid pidfd for event created by terminated child",
1,
- FAN_NOPIDFD,
+ 1,
0,
},
{
@@ -72,6 +72,8 @@ static int fanotify_fd;
static char event_buf[BUF_SZ];
static struct pidfd_fdinfo_t *self_pidfd_fdinfo;
+static int fd_error_unsupported;
+
static struct pidfd_fdinfo_t *read_pidfd_fdinfo(int pidfd)
{
char *fdinfo_path;
@@ -121,6 +123,15 @@ static void do_fork(void)
static void do_setup(void)
{
int pidfd;
+ int init_flags = FAN_REPORT_PIDFD;
+
+ if (tst_variant) {
+ fanotify_fd = -1;
+ fd_error_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FD_ERROR, ".");
+ if (fd_error_unsupported)
+ return;
+ init_flags |= FAN_REPORT_FD_ERROR;
+ }
SAFE_TOUCH(TEST_FILE, 0666, NULL);
@@ -132,7 +143,7 @@ static void do_setup(void)
REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_PIDFD,
TEST_FILE);
- fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDWR);
+ fanotify_fd = SAFE_FANOTIFY_INIT(init_flags, O_RDWR);
SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD,
TEST_FILE);
@@ -150,8 +161,17 @@ static void do_test(unsigned int num)
{
int i = 0, len;
struct test_case_t *tc = &test_cases[num];
+ int nopidfd_err = tc->want_pidfd_err ?
+ (tst_variant ? -ESRCH : FAN_NOPIDFD) : 0;
+ int fd_err = (tc->remount_ro && tst_variant) ? -EROFS : 0;
- tst_res(TINFO, "Test #%d: %s", num, tc->name);
+ tst_res(TINFO, "Test #%d.%d: %s %s", num, tst_variant, tc->name,
+ tst_variant ? "(FAN_REPORT_FD_ERROR)" : "");
+
+ if (fd_error_unsupported && tst_variant) {
+ FANOTIFY_INIT_FLAGS_ERR_MSG(FAN_REPORT_FD_ERROR, fd_error_unsupported);
+ return;
+ }
if (tc->remount_ro) {
/* SAFE_MOUNT fails to remount FUSE */
@@ -179,12 +199,12 @@ static void do_test(unsigned int num)
*/
len = read(fanotify_fd, event_buf, sizeof(event_buf));
if (len < 0) {
- if (tc->remount_ro && errno == EROFS) {
+ if (tc->remount_ro && !fd_err && errno == EROFS) {
tst_res(TPASS, "cannot read event with rw fd from a ro fs");
return;
}
tst_brk(TBROK | TERRNO, "reading fanotify events failed");
- } else if (tc->remount_ro) {
+ } else if (tc->remount_ro && !fd_err) {
tst_res(TFAIL, "got unexpected event with rw fd from a ro fs");
}
while (i < len) {
@@ -218,6 +238,28 @@ static void do_test(unsigned int num)
goto next_event;
}
+ /*
+ * Check if event->fd reported any errors during
+ * creation and whether they're expected.
+ */
+ if (!fd_err && event->fd >= 0) {
+ tst_res(TPASS,
+ "event->fd %d is valid as expected",
+ event->fd);
+ } else if (fd_err && event->fd == fd_err) {
+ tst_res(TPASS,
+ "event->fd is error %d as expected",
+ event->fd);
+ } else if (fd_err) {
+ tst_res(TFAIL,
+ "event->fd is %d, but expected error %d",
+ event->fd, fd_err);
+ } else {
+ tst_res(TFAIL,
+ "event->fd creation failed with error %d",
+ event->fd);
+ }
+
/*
* Check if pidfd information object reported any errors during
* creation and whether they're expected.
@@ -229,20 +271,18 @@ static void do_test(unsigned int num)
(unsigned int)event->pid,
info->pidfd);
goto next_event;
- } else if (tc->want_pidfd_err &&
- info->pidfd != tc->want_pidfd_err) {
+ } else if (tc->want_pidfd_err && info->pidfd != nopidfd_err) {
tst_res(TFAIL,
"pidfd set to an unexpected error: %d for pid: %u",
info->pidfd,
(unsigned int)event->pid);
goto next_event;
- } else if (tc->want_pidfd_err &&
- info->pidfd == tc->want_pidfd_err) {
+ } else if (tc->want_pidfd_err && info->pidfd == nopidfd_err) {
tst_res(TPASS,
"pid: %u terminated before pidfd was created, "
"pidfd set to the value of: %d, as expected",
(unsigned int)event->pid,
- FAN_NOPIDFD);
+ nopidfd_err);
goto next_event;
}
@@ -323,6 +363,7 @@ static struct tst_test test = {
.setup = do_setup,
.test = do_test,
.tcnt = ARRAY_SIZE(test_cases),
+ .test_variants = 2,
.cleanup = do_cleanup,
.all_filesystems = 1,
.needs_root = 1,
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
` (4 preceding siblings ...)
2025-01-22 17:24 ` [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR Amir Goldstein
@ 2025-01-22 20:50 ` Petr Vorel
2025-01-23 13:09 ` Amir Goldstein
2025-01-24 10:46 ` Cyril Hrubis
5 siblings, 2 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-22 20:50 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir,
> Hi all,
> Following tests for fanotify code in v6.13.
> 1. The new test case in fanotify13 fails as follows on kernels v6.6..v6.12:
> fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> fanotify13.c:282: TFAIL: handle_bytes (180003) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> The fix was already backported to v6.12.10.
> It was also backported to v6.6.72,
> but then reverted due to a backport bug in v6.6.73
> and it now staged again for v6.6.74.
> 2. The new variant of fanotify21 is skipped on kernels <= v6.12
> This variant tests the new feature flag FAN_REPORT_FD_ERROR, which is
> not effectively a bug fix.
> Because this feature was added as a consequence of a bug report,
> it was auto backported to v6.12.5 and to v6.6.66, but I do not
> feel comfortable with adding a fix tag to force distros to backport
> this feature.
We have git freeze before new release. But IMHO this should go in.
It works well on v6.13, I'll retest it on SLES kernels.
Kind regards,
Petr
> Thanks,
> Amir.
> Amir Goldstein (5):
> fanotify13: Verify that we did not get an extra event
> fanotify13: Add test case for FAN_DELETE_SELF
> fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR
> fanotify21: Test reporting event with RDWR fd on RO mount
> fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR
> include/lapi/fanotify.h | 4 +
> testcases/kernel/syscalls/fanotify/fanotify.h | 1 +
> .../kernel/syscalls/fanotify/fanotify05.c | 18 +++-
> .../kernel/syscalls/fanotify/fanotify13.c | 90 ++++++++++++++++---
> .../kernel/syscalls/fanotify/fanotify21.c | 89 ++++++++++++++++--
> 5 files changed, 177 insertions(+), 25 deletions(-)
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
@ 2025-01-23 13:09 ` Amir Goldstein
2025-01-23 13:31 ` Cyril Hrubis
2025-01-24 10:46 ` Cyril Hrubis
1 sibling, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-23 13:09 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
On Wed, Jan 22, 2025 at 9:50 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> > Hi all,
>
> > Following tests for fanotify code in v6.13.
>
> > 1. The new test case in fanotify13 fails as follows on kernels v6.6..v6.12:
>
> > fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> > fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> > fanotify13.c:282: TFAIL: handle_bytes (180003) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
>
> > The fix was already backported to v6.12.10.
> > It was also backported to v6.6.72,
> > but then reverted due to a backport bug in v6.6.73
> > and it now staged again for v6.6.74.
>
>
> > 2. The new variant of fanotify21 is skipped on kernels <= v6.12
>
> > This variant tests the new feature flag FAN_REPORT_FD_ERROR, which is
> > not effectively a bug fix.
>
> > Because this feature was added as a consequence of a bug report,
> > it was auto backported to v6.12.5 and to v6.6.66, but I do not
> > feel comfortable with adding a fix tag to force distros to backport
> > this feature.
>
> We have git freeze before new release. But IMHO this should go in.
> It works well on v6.13, I'll retest it on SLES kernels.
>
OK. For the record, I try to time the posting of these sorts of tests
after the .0 kernel release.
Arguably, I could have posted the fanotify13 test case after the release
of v6.13-rc7 a week earlier, but I often need more time to context switch
for posting the tests.
Are the LTP releases usually timed in some relation to .0 release times?
Thanks,
Amir.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-23 13:09 ` Amir Goldstein
@ 2025-01-23 13:31 ` Cyril Hrubis
0 siblings, 0 replies; 21+ messages in thread
From: Cyril Hrubis @ 2025-01-23 13:31 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi!
> Are the LTP releases usually timed in some relation to .0 release times?
We have releases fixed in time, that is January, May and September. Any
overlap with kernel releases are accidental.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
@ 2025-01-23 17:18 ` Petr Vorel
2025-01-24 10:11 ` Petr Vorel
0 siblings, 1 reply; 21+ messages in thread
From: Petr Vorel @ 2025-01-23 17:18 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir, all,
> For example, verify that we did not get an event on a directory object
> without requesting FAN_ONDIR. Also, report a test failure if no events
> received at all instead of blocking on read of fanotify_fd.
> With this change, the test fails with overlayfs variants over btrfs,
> because the size of fid of overalyfs over btrfs is about 90 bytes and
> the events on the three objects do not all fit into a single 256 bytes
> buffer read. Increase the size of the events buffer to fix this failure.
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> .../kernel/syscalls/fanotify/fanotify13.c | 22 ++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
> index 5cd857707..16fd99ba1 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify13.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
> @@ -34,7 +34,7 @@
> #include "fanotify.h"
> #define PATH_LEN 128
> -#define BUF_SIZE 256
> +#define BUF_SIZE 1024
> #define DIR_ONE "dir_one"
> #define FILE_ONE "file_one"
> #define FILE_TWO "file_two"
> @@ -130,10 +130,15 @@ static int setup_marks(unsigned int fd, struct test_case_t *tc)
> SAFE_FANOTIFY_MARK(fd, FAN_MARK_ADD | mark->flag, tc->mask,
> AT_FDCWD, objects[i].path);
> - /* Setup the expected mask for each generated event */
> + /*
> + * Setup the expected mask for each generated event.
> + * No events are expected on directory without FAN_ONDIR.
> + */
> event_set[i].expected_mask = tc->mask;
> if (!objects[i].is_dir)
> event_set[i].expected_mask &= ~FAN_ONDIR;
> + else if (!(event_set[i].expected_mask & FAN_ONDIR))
> + event_set[i].expected_mask = 0;
> }
> return 0;
> }
> @@ -163,7 +168,8 @@ static void do_test(unsigned int number)
> return;
> }
> - fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID, O_RDONLY);
> + fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID |
> + FAN_NONBLOCK, O_RDONLY);
> /*
> * Place marks on a set of objects and setup the expected masks
> @@ -279,6 +285,16 @@ static void do_test(unsigned int number)
> FSID_VAL_MEMBER(event_fid->fsid, 1),
> *(unsigned long *) event_file_handle->f_handle);
> }
> +
> + /*
> + * Verify that we did not get an extra event, for example, that we did
> + * not get an event on directory without FAN_ONDIR.
> + */
> + if (event_set[i].expected_mask) {
> + tst_res(TFAIL,
> + "Did not get an expected event (expected: %llx)",
> + event_set[i].expected_mask);
I verified that on openSUSE on x86_64 test properly fails with 6.12.9:
fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
and works with 6.12.10. So far so good.
But when testing on other archs, 6.12.10 fails on aarch64 and ppc64le:
fanotify13.c:339: TFAIL: Did not get an expected event (expected: 200)
That's a different failure than on 6.12.9.
Any hint what could be wrong?
Kind regards,
Petr
> + }
> out:
> SAFE_CLOSE(fanotify_fd);
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR
2025-01-22 17:24 ` [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR Amir Goldstein
@ 2025-01-24 7:44 ` Petr Vorel
0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 7:44 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir,
> Expecting to get -EBADF instead of FAN_NOFD.
LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount
2025-01-22 17:24 ` [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount Amir Goldstein
@ 2025-01-24 8:01 ` Petr Vorel
0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 8:01 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir, all,
> When event_f_flags request to open O_RDWR files for event->fd, the
> event listener should not get events with fd on a read-only mount.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM.
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> .../kernel/syscalls/fanotify/fanotify21.c | 34 +++++++++++++++++--
> 1 file changed, 32 insertions(+), 2 deletions(-)
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c
> index d54930f05..4324019fa 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify21.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify21.c
> @@ -21,6 +21,7 @@
> #include <ctype.h>
> #include <stdlib.h>
> #include <string.h>
> +#include <sys/mount.h>
> #include "tst_test.h"
> #include "tst_safe_stdio.h"
> #include "tst_safe_macros.h"
> @@ -45,16 +46,25 @@ static struct test_case_t {
> char *name;
> int fork;
> int want_pidfd_err;
> + int remount_ro;
> } test_cases[] = {
> {
> "return a valid pidfd for event created by self",
> 0,
> 0,
> + 0,
nit: given how many parameters fanotify tests get over time I would use
designated initializers. I can do it after the release.
> },
> {
> "return invalid pidfd for event created by terminated child",
> 1,
> FAN_NOPIDFD,
> + 0,
> + },
> + {
> + "fail to open rw fd for event created on read-only mount",
> + 0,
> + 0,
> + 1,
> },
> };
> @@ -122,7 +132,7 @@ static void do_setup(void)
> REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_PIDFD,
> TEST_FILE);
> - fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDONLY);
> + fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDWR);
> SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD,
> TEST_FILE);
> @@ -143,6 +153,16 @@ static void do_test(unsigned int num)
> tst_res(TINFO, "Test #%d: %s", num, tc->name);
> + if (tc->remount_ro) {
> + /* SAFE_MOUNT fails to remount FUSE */
> + if (mount(tst_device->dev, MOUNT_PATH, tst_device->fs_type,
> + MS_REMOUNT|MS_RDONLY, NULL) != 0) {
> + tst_brk(TFAIL,
> + "filesystem %s failed to remount readonly",
> + tst_device->fs_type);
> + }
> + }
nit: I would join two if into single one.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR
2025-01-22 17:24 ` [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR Amir Goldstein
@ 2025-01-24 8:09 ` Petr Vorel
0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 8:09 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir,
> Expect to get -EROFS as event->fd.
> Expect to get -ESRCH instead of FAN_NOPIDFD.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM.
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> .../kernel/syscalls/fanotify/fanotify21.c | 61 ++++++++++++++++---
> 1 file changed, 51 insertions(+), 10 deletions(-)
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c
> index 4324019fa..8765767f2 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify21.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify21.c
> @@ -57,7 +57,7 @@ static struct test_case_t {
> {
> "return invalid pidfd for event created by terminated child",
> 1,
> - FAN_NOPIDFD,
> + 1,
> 0,
> },
> {
> @@ -72,6 +72,8 @@ static int fanotify_fd;
> static char event_buf[BUF_SZ];
> static struct pidfd_fdinfo_t *self_pidfd_fdinfo;
> +static int fd_error_unsupported;
> +
> static struct pidfd_fdinfo_t *read_pidfd_fdinfo(int pidfd)
> {
> char *fdinfo_path;
> @@ -121,6 +123,15 @@ static void do_fork(void)
> static void do_setup(void)
> {
> int pidfd;
> + int init_flags = FAN_REPORT_PIDFD;
> +
> + if (tst_variant) {
> + fanotify_fd = -1;
> + fd_error_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FD_ERROR, ".");
> + if (fd_error_unsupported)
> + return;
> + init_flags |= FAN_REPORT_FD_ERROR;
> + }
> SAFE_TOUCH(TEST_FILE, 0666, NULL);
> @@ -132,7 +143,7 @@ static void do_setup(void)
> REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_PIDFD,
> TEST_FILE);
> - fanotify_fd = SAFE_FANOTIFY_INIT(FAN_REPORT_PIDFD, O_RDWR);
> + fanotify_fd = SAFE_FANOTIFY_INIT(init_flags, O_RDWR);
> SAFE_FANOTIFY_MARK(fanotify_fd, FAN_MARK_ADD, FAN_OPEN, AT_FDCWD,
> TEST_FILE);
> @@ -150,8 +161,17 @@ static void do_test(unsigned int num)
> {
> int i = 0, len;
> struct test_case_t *tc = &test_cases[num];
> + int nopidfd_err = tc->want_pidfd_err ?
> + (tst_variant ? -ESRCH : FAN_NOPIDFD) : 0;
> + int fd_err = (tc->remount_ro && tst_variant) ? -EROFS : 0;
> - tst_res(TINFO, "Test #%d: %s", num, tc->name);
> + tst_res(TINFO, "Test #%d.%d: %s %s", num, tst_variant, tc->name,
> + tst_variant ? "(FAN_REPORT_FD_ERROR)" : "");
Thanks for printing also tst_variant, it helps reviewing the test
(number of the results increased from 20 to 110).
...
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event
2025-01-23 17:18 ` Petr Vorel
@ 2025-01-24 10:11 ` Petr Vorel
2025-01-24 10:33 ` Amir Goldstein
0 siblings, 1 reply; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 10:11 UTC (permalink / raw)
To: Amir Goldstein, Cyril Hrubis, Jan Kara, ltp
Hi Amir, all,
> Hi Amir, all,
> > For example, verify that we did not get an event on a directory object
> > without requesting FAN_ONDIR. Also, report a test failure if no events
> > received at all instead of blocking on read of fanotify_fd.
> > With this change, the test fails with overlayfs variants over btrfs,
> > because the size of fid of overalyfs over btrfs is about 90 bytes and
> > the events on the three objects do not all fit into a single 256 bytes
> > buffer read. Increase the size of the events buffer to fix this failure.
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > ---
> > .../kernel/syscalls/fanotify/fanotify13.c | 22 ++++++++++++++++---
> > 1 file changed, 19 insertions(+), 3 deletions(-)
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
> > index 5cd857707..16fd99ba1 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify13.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
> > @@ -34,7 +34,7 @@
> > #include "fanotify.h"
> > #define PATH_LEN 128
> > -#define BUF_SIZE 256
> > +#define BUF_SIZE 1024
> > #define DIR_ONE "dir_one"
> > #define FILE_ONE "file_one"
> > #define FILE_TWO "file_two"
> > @@ -130,10 +130,15 @@ static int setup_marks(unsigned int fd, struct test_case_t *tc)
> > SAFE_FANOTIFY_MARK(fd, FAN_MARK_ADD | mark->flag, tc->mask,
> > AT_FDCWD, objects[i].path);
> > - /* Setup the expected mask for each generated event */
> > + /*
> > + * Setup the expected mask for each generated event.
> > + * No events are expected on directory without FAN_ONDIR.
> > + */
> > event_set[i].expected_mask = tc->mask;
> > if (!objects[i].is_dir)
> > event_set[i].expected_mask &= ~FAN_ONDIR;
> > + else if (!(event_set[i].expected_mask & FAN_ONDIR))
> > + event_set[i].expected_mask = 0;
> > }
> > return 0;
> > }
> > @@ -163,7 +168,8 @@ static void do_test(unsigned int number)
> > return;
> > }
> > - fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID, O_RDONLY);
> > + fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID |
> > + FAN_NONBLOCK, O_RDONLY);
> > /*
> > * Place marks on a set of objects and setup the expected masks
> > @@ -279,6 +285,16 @@ static void do_test(unsigned int number)
> > FSID_VAL_MEMBER(event_fid->fsid, 1),
> > *(unsigned long *) event_file_handle->f_handle);
> > }
> > +
> > + /*
> > + * Verify that we did not get an extra event, for example, that we did
> > + * not get an event on directory without FAN_ONDIR.
> > + */
> > + if (event_set[i].expected_mask) {
> > + tst_res(TFAIL,
> > + "Did not get an expected event (expected: %llx)",
> > + event_set[i].expected_mask);
> I verified that on openSUSE on x86_64 test properly fails with 6.12.9:
> fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
> and works with 6.12.10. So far so good.
> But when testing on other archs, 6.12.10 fails on aarch64 and ppc64le:
> fanotify13.c:339: TFAIL: Did not get an expected event (expected: 200)
> That's a different failure than on 6.12.9.
Also fanotify13.c for the same reason on s390x on various SLES (enterprise)
kernels based on various mainline kernels (6.4, 5.3.18, ...).
fanotify13.c:341: TFAIL: Did not get an expected event (expected: 3403000018)
(Just a different mask than on aarch64 and ppc64le.)
@Cyril: due the above I suggest to merge before release only fanotify05.c and
fanotify21.c changes.
Kind regards,
Petr
> Any hint what could be wrong?
> Kind regards,
> Petr
> > + }
> > out:
> > SAFE_CLOSE(fanotify_fd);
> > }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event
2025-01-24 10:11 ` Petr Vorel
@ 2025-01-24 10:33 ` Amir Goldstein
2025-01-24 12:45 ` Petr Vorel
0 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-24 10:33 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
On Fri, Jan 24, 2025 at 11:11 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir, all,
> > Hi Amir, all,
>
> > > For example, verify that we did not get an event on a directory object
> > > without requesting FAN_ONDIR. Also, report a test failure if no events
> > > received at all instead of blocking on read of fanotify_fd.
>
> > > With this change, the test fails with overlayfs variants over btrfs,
> > > because the size of fid of overalyfs over btrfs is about 90 bytes and
> > > the events on the three objects do not all fit into a single 256 bytes
> > > buffer read. Increase the size of the events buffer to fix this failure.
>
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > ---
> > > .../kernel/syscalls/fanotify/fanotify13.c | 22 ++++++++++++++++---
> > > 1 file changed, 19 insertions(+), 3 deletions(-)
>
> > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
> > > index 5cd857707..16fd99ba1 100644
> > > --- a/testcases/kernel/syscalls/fanotify/fanotify13.c
> > > +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
> > > @@ -34,7 +34,7 @@
> > > #include "fanotify.h"
>
> > > #define PATH_LEN 128
> > > -#define BUF_SIZE 256
> > > +#define BUF_SIZE 1024
> > > #define DIR_ONE "dir_one"
> > > #define FILE_ONE "file_one"
> > > #define FILE_TWO "file_two"
> > > @@ -130,10 +130,15 @@ static int setup_marks(unsigned int fd, struct test_case_t *tc)
> > > SAFE_FANOTIFY_MARK(fd, FAN_MARK_ADD | mark->flag, tc->mask,
> > > AT_FDCWD, objects[i].path);
>
> > > - /* Setup the expected mask for each generated event */
> > > + /*
> > > + * Setup the expected mask for each generated event.
> > > + * No events are expected on directory without FAN_ONDIR.
> > > + */
> > > event_set[i].expected_mask = tc->mask;
> > > if (!objects[i].is_dir)
> > > event_set[i].expected_mask &= ~FAN_ONDIR;
> > > + else if (!(event_set[i].expected_mask & FAN_ONDIR))
> > > + event_set[i].expected_mask = 0;
> > > }
> > > return 0;
> > > }
> > > @@ -163,7 +168,8 @@ static void do_test(unsigned int number)
> > > return;
> > > }
>
> > > - fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID, O_RDONLY);
> > > + fanotify_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_REPORT_FID |
> > > + FAN_NONBLOCK, O_RDONLY);
>
> > > /*
> > > * Place marks on a set of objects and setup the expected masks
> > > @@ -279,6 +285,16 @@ static void do_test(unsigned int number)
> > > FSID_VAL_MEMBER(event_fid->fsid, 1),
> > > *(unsigned long *) event_file_handle->f_handle);
> > > }
> > > +
> > > + /*
> > > + * Verify that we did not get an extra event, for example, that we did
> > > + * not get an event on directory without FAN_ONDIR.
> > > + */
> > > + if (event_set[i].expected_mask) {
> > > + tst_res(TFAIL,
> > > + "Did not get an expected event (expected: %llx)",
> > > + event_set[i].expected_mask);
>
> > I verified that on openSUSE on x86_64 test properly fails with 6.12.9:
> > fanotify13.c:282: TFAIL: handle_bytes (0) returned in event does not equal to handle_bytes (24) returned in name_to_handle_at(2)
>
> > and works with 6.12.10. So far so good.
>
> > But when testing on other archs, 6.12.10 fails on aarch64 and ppc64le:
>
> > fanotify13.c:339: TFAIL: Did not get an expected event (expected: 200)
>
> > That's a different failure than on 6.12.9.
>
> Also fanotify13.c for the same reason on s390x on various SLES (enterprise)
> kernels based on various mainline kernels (6.4, 5.3.18, ...).
>
> fanotify13.c:341: TFAIL: Did not get an expected event (expected: 3403000018)
>
> (Just a different mask than on aarch64 and ppc64le.)
>
This mask is out of bound garbage at event_set[EVENT_MAX]
> @Cyril: due the above I suggest to merge before release only fanotify05.c and
> fanotify21.c changes.
>
> Kind regards,
> Petr
>
> > Any hint what could be wrong?
That would be the simplest fix:
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -48,7 +48,7 @@
#define FILE_ONE "file_one"
#define FILE_TWO "file_two"
#define MOUNT_PATH "tstmnt"
-#define EVENT_MAX ARRAY_SIZE(objects)
+#define EVENT_MAX (ARRAY_SIZE(objects)+1)
Thanks,
Amir.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
2025-01-23 13:09 ` Amir Goldstein
@ 2025-01-24 10:46 ` Cyril Hrubis
2025-01-24 11:32 ` Petr Vorel
2025-01-30 20:07 ` Petr Vorel
1 sibling, 2 replies; 21+ messages in thread
From: Cyril Hrubis @ 2025-01-24 10:46 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
Hi!
> We have git freeze before new release. But IMHO this should go in.
> It works well on v6.13, I'll retest it on SLES kernels.
We are going to release LTP next week, I would say that it's not enough
time to properly test these changes and that the timing was too
unfortunate this time. I would deffer merging after the release.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-24 10:46 ` Cyril Hrubis
@ 2025-01-24 11:32 ` Petr Vorel
2025-01-30 20:07 ` Petr Vorel
1 sibling, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 11:32 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Jan Kara, ltp
> Hi!
> > We have git freeze before new release. But IMHO this should go in.
> > It works well on v6.13, I'll retest it on SLES kernels.
> We are going to release LTP next week, I would say that it's not enough
> time to properly test these changes and that the timing was too
> unfortunate this time. I would deffer merging after the release.
Fair enough, let's merge it after.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event
2025-01-24 10:33 ` Amir Goldstein
@ 2025-01-24 12:45 ` Petr Vorel
0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-24 12:45 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Jan Kara, ltp
Hi Amir, all,
...
> > > Any hint what could be wrong?
> That would be the simplest fix:
> --- a/testcases/kernel/syscalls/fanotify/fanotify13.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
> @@ -48,7 +48,7 @@
> #define FILE_ONE "file_one"
> #define FILE_TWO "file_two"
> #define MOUNT_PATH "tstmnt"
> -#define EVENT_MAX ARRAY_SIZE(objects)
> +#define EVENT_MAX (ARRAY_SIZE(objects)+1)
Indeed, that fixes the problem, thanks!
Kind regards,
Petr
> Thanks,
> Amir.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-24 10:46 ` Cyril Hrubis
2025-01-24 11:32 ` Petr Vorel
@ 2025-01-30 20:07 ` Petr Vorel
2025-01-31 14:16 ` Amir Goldstein
1 sibling, 1 reply; 21+ messages in thread
From: Petr Vorel @ 2025-01-30 20:07 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Jan Kara, ltp
Hi all,
> Hi!
> > We have git freeze before new release. But IMHO this should go in.
> > It works well on v6.13, I'll retest it on SLES kernels.
> We are going to release LTP next week, I would say that it's not enough
> time to properly test these changes and that the timing was too
> unfortunate this time. I would deffer merging after the release.
LTP was released, therefore merging the tests. Thanks, Amir!
I'm not sure if you plan to split the tests (hopefully you got enough info about
the goal). If not, I or Martin should do it.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-30 20:07 ` Petr Vorel
@ 2025-01-31 14:16 ` Amir Goldstein
2025-01-31 16:42 ` Petr Vorel
0 siblings, 1 reply; 21+ messages in thread
From: Amir Goldstein @ 2025-01-31 14:16 UTC (permalink / raw)
To: Petr Vorel; +Cc: Jan Kara, ltp
On Thu, Jan 30, 2025 at 9:07 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi all,
>
> > Hi!
> > > We have git freeze before new release. But IMHO this should go in.
> > > It works well on v6.13, I'll retest it on SLES kernels.
>
> > We are going to release LTP next week, I would say that it's not enough
> > time to properly test these changes and that the timing was too
> > unfortunate this time. I would deffer merging after the release.
>
> LTP was released, therefore merging the tests. Thanks, Amir!
>
Thanks!
> I'm not sure if you plan to split the tests (hopefully you got enough info about
> the goal). If not, I or Martin should do it.
I wasn't planning to split the tests.
IMO splitting the tests properly to avoid too much code dedupe
requires a lot of refactoring, which I have no time for right now.
But please feel free to split with or without code dedupe and CC me
for the review.
Thanks,
Amir.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [LTP] [PATCH 0/5] LTP fanotify tests for v6.13
2025-01-31 14:16 ` Amir Goldstein
@ 2025-01-31 16:42 ` Petr Vorel
0 siblings, 0 replies; 21+ messages in thread
From: Petr Vorel @ 2025-01-31 16:42 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Martin Doucha, Jan Kara, ltp
> On Thu, Jan 30, 2025 at 9:07 PM Petr Vorel <pvorel@suse.cz> wrote:
> > Hi all,
> > > Hi!
> > > > We have git freeze before new release. But IMHO this should go in.
> > > > It works well on v6.13, I'll retest it on SLES kernels.
> > > We are going to release LTP next week, I would say that it's not enough
> > > time to properly test these changes and that the timing was too
> > > unfortunate this time. I would deffer merging after the release.
> > LTP was released, therefore merging the tests. Thanks, Amir!
> Thanks!
> > I'm not sure if you plan to split the tests (hopefully you got enough info about
> > the goal). If not, I or Martin should do it.
> I wasn't planning to split the tests.
> IMO splitting the tests properly to avoid too much code dedupe
> requires a lot of refactoring, which I have no time for right now.
Sure, understand.
> But please feel free to split with or without code dedupe and CC me
> for the review.
Sure (hopefully without code dedupe). I'm not sure myself when we get into it.
Kind regards,
Petr
> Thanks,
> Amir.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-01-31 16:42 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
2025-01-23 17:18 ` Petr Vorel
2025-01-24 10:11 ` Petr Vorel
2025-01-24 10:33 ` Amir Goldstein
2025-01-24 12:45 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 2/5] fanotify13: Add test case for FAN_DELETE_SELF Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR Amir Goldstein
2025-01-24 7:44 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount Amir Goldstein
2025-01-24 8:01 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR Amir Goldstein
2025-01-24 8:09 ` Petr Vorel
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
2025-01-23 13:09 ` Amir Goldstein
2025-01-23 13:31 ` Cyril Hrubis
2025-01-24 10:46 ` Cyril Hrubis
2025-01-24 11:32 ` Petr Vorel
2025-01-30 20:07 ` Petr Vorel
2025-01-31 14:16 ` Amir Goldstein
2025-01-31 16:42 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox