Fanotify tests for FAN_MARK_IGNORE
cover Fanotify tests for FAN_MARK_IGNORE
Hi Petr,
FAN_MARK_IGNORE feature was merge in v6.0-rc1.
A man page draft was posted here [1].
Following are the tests for the new feature.
All new test cases are skipped on old kernels.
Note that fanotify10 will run ALL of its existing test cases in two variants:
1. Legacy FAN_MARK_IGNORED_MASK
2. New FAN_MARK_IGNORE
On old kernels, only the first variant of the test will run.
In addition to the new test variant it also has some new test cases that only run with new FAN_MARK_IGNORE variant.
Thanks,
Amir.
[1] https://lore.kernel.org/linux-man/[email protected]/
Amir Goldstein (9):
syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE syscalls/fanotify14: Require FAN_REPORT_FID support for entire test syscalls/fanotify14: Add test cases for FAN_MARK_IGNORE syscalls/fanotify10: Avoid undesired event in test syscalls/fanotify10: Add more verifications and debug info syscalls/fanotify10: Use dedicated mark type for inode mark on parent syscalls/fanotify10: Run tests with two ignore mask variants syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_EVENT_ON_CHILD syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_ONDIR
testcases/kernel/syscalls/fanotify/fanotify.h | 19 ++ .../kernel/syscalls/fanotify/fanotify09.c | 102 ++++++++-- .../kernel/syscalls/fanotify/fanotify10.c | 186 ++++++++++++++---- .../kernel/syscalls/fanotify/fanotify14.c | 42 +++- 4 files changed, 290 insertions(+), 59 deletions(-)
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/9 syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE
Verify the semantics of the new FAN_MARK_IGNORE flag:
1. Verify that ignore mask ignores events on dir only when FAN_ONDIR flag is set in ignore mask
2. Verify that ignore mask ignores events on child only when FAN_EVENT_ON_CHILD flag is set in ignore mask
3. Verify that ignore mask ignores events on subdir only when both FAN_EVENT_ON_CHILD and FAN_ONDIR flags are set in ignore mask
--- testcases/kernel/syscalls/fanotify/fanotify.h | 6 ++ .../kernel/syscalls/fanotify/fanotify09.c | 102 +++++++++++++++--- 2 files changed, 95 insertions(+), 13 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +6 -0
@@ -106,6 +106,12 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_MARK_EVICTABLE #define FAN_MARK_EVICTABLE 0x00000200#endif +#ifndef FAN_MARK_IGNORE +#define FAN_MARK_IGNORE 0x00000400 +#endif +#ifndef FAN_MARK_IGNORE_SURV +#define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY) +#endif /* New dirent event masks */ #ifndef FAN_ATTRIB
testcases/kernel/syscalls/fanotify/fanotify09.c +89 -13
197 lines not on this page · raw message
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/9] syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE
Hi Amir,
...
Quoted 20 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +2
-0@@ -73,12 +73,14 @@ static char event_buf[EVENT_BUF_LEN];static int mount_created;static int fan_report_dfid_unsupported; +static int ignore_mark_unsupported; static struct tcase { const char *tname; struct fanotify_mark_type mark; unsigned int ondir; unsigned int ignore; + unsigned int ignore_flags; unsigned int report_name; const char *close_nowrite; int nevents;
testcases/kernel/syscalls/fanotify/fanotify09.c static struct tcase { · line 96
Quoted 8 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +1
-1@@ -88,7 +90,7 @@ static struct tcase {"Events on non-dir child with both parent and mount marks" ,INIT_FANOTIFY_MARK_TYPE (MOUNT ),0 , -0 , +0 ,0 ,0 ,DIR_NAME , 1, 0,
nit: as number of struct grow, it'd help readability to omit members with 0:
.tname = "Events on non-dir child with both parent and mount marks", .mark = INIT_FANOTIFY_MARK_TYPE(MOUNT),
.close_nowrite = DIR_NAME,
.nevents = 1,
This is obviously non-blocker of this patch, if you agree it can be done any time later.
Also I fixed make check warnings some time ago (i.e. checkpatch.pl), but they got back. I might find a time to fix them (we appreciate you look after the test, thus don't want to bother you with these tiny details).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/9] syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE
Quoted 32 lines · Petr Vorel
Hi Amir,
Reviewed-by Petr Vorel <[email protected]>...
Quoted 26 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +3
-1@@ -73,12 +73,14 @@ static char event_buf[EVENT_BUF_LEN];static int mount_created;static int fan_report_dfid_unsupported; +static int ignore_mark_unsupported; static struct tcase { const char *tname; struct fanotify_mark_type mark; unsigned int ondir; unsigned int ignore; + unsigned int ignore_flags; unsigned int report_name; const char *close_nowrite; int nevents;@@ -88,7 +90,7 @@ static struct tcase {"Events on non-dir child with both parent and mount marks" ,INIT_FANOTIFY_MARK_TYPE (MOUNT ),0 , -0 , +0 ,0 , 0,
Quoted 9 lines
testcases/kernel/syscalls/fanotify/fanotify09.c static struct tcase { · line 96
Quoted 2 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +0
-0DIR_NAME , 1, 0,nit: as number of struct grow, it'd help readability to omit members with 0:
.tname = "Events on non-dir child with both parent and mount marks", .mark =INIT_FANOTIFY_MARK_TYPE(MOUNT),
.close_nowrite =DIR_NAME,
.nevents = 1,
You are absolutely right.
The readability of use cases is quite tough at this point.
Quoted 2 lines
This is obviously non-blocker of this patch, if you agree it can be done any time later.
Certainly.
I think that growing the struct is a good place to stop and do this cleanup, we have got plenty of time until v6.0 and I expect to get more comments on this series, so I will probably do this cleanup already for v2.
Quoted 2 lines
Also I fixed make check warnings some time ago (i.e. checkpatch.pl), but they
Cool. I didn't know.
Quoted 3 lines
got back. I might find a time to fix them (we appreciate you look after the test, thus don't want to bother you with these tiny details).
This is the only new check warning I see:
fanotify10.c:378: ERROR: Bad function definition - void drop_caches() should probably be void drop_caches(void)
make: [../../../../include/mk/rules.mk:56: check-fanotify10] Error 1 (ignored) fanotify10.c:378:25: warning: non-ANSI function declaration of function 'drop_caches'
I will fix it.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/9] syscalls/fanotify09: Add test cases for FAN_MARK_IGNORE
Quoted 46 lines · Petr Vorel
Quoted 32 lines
Hi Amir,
Reviewed-by Petr Vorel <[email protected]>...
Quoted 26 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +3
-1@@ -73,12 +73,14 @@ static char event_buf[EVENT_BUF_LEN];static int mount_created;static int fan_report_dfid_unsupported; +static int ignore_mark_unsupported; static struct tcase { const char *tname; struct fanotify_mark_type mark; unsigned int ondir; unsigned int ignore; + unsigned int ignore_flags; unsigned int report_name; const char *close_nowrite; int nevents;@@ -88,7 +90,7 @@ static struct tcase {"Events on non-dir child with both parent and mount marks" ,INIT_FANOTIFY_MARK_TYPE (MOUNT ),0 , -0 , +0 ,0 , 0,Quoted 8 lines
testcases/kernel/syscalls/fanotify/fanotify09.c static struct tcase { · line 96
Quoted 2 lines
testcases/kernel/syscalls/fanotify/fanotify09.c +0
-0DIR_NAME , 1, 0,nit: as number of struct grow, it'd help readability to omit members with 0:
.tname = "Events on non-dir child with both parent and mount marks", .mark =INIT_FANOTIFY_MARK_TYPE(MOUNT),
.close_nowrite =DIR_NAME,
.nevents = 1,You are absolutely right.
The readability of use cases is quite tough at this point.
Quoted 8 lines
Quoted 2 lines
This is obviously non-blocker of this patch, if you agree it can be done any time later.
Certainly.
I think that growing the struct is a good place to stop and do this cleanup, we have got plenty of time until v6.0 and I expect to get more comments on this series, so I will probably do this cleanup already for v2.
Thank you!
FYI we have LTP releases regularly 4x a year [1], the next one will be around the end of September, with git freeze ~ 2 weeks before, i.e. very soon. Of course this patchset should get in the release (I don't expect any issues any major problems reported by Jan or Matthew, checkpatch.pl issues will not block it).
Quoted 8 lines
Quoted 1 line
Also I fixed make check warnings some time ago (i.e. checkpatch.pl), but they
Cool. I didn't know.
Quoted 2 lines
got back. I might find a time to fix them (we appreciate you look after the test, thus don't want to bother you with these tiny details).
Quoted 7 lines
This is the only new check warning I see:
fanotify10.c:378: ERROR: Bad function definition - void
drop_caches()should probably be voiddrop_caches(void)
make: [../../../../include/mk/rules.mk:56: check-fanotify10] Error 1 (ignored) fanotify10.c:378:25: warning: non-ANSI function declaration of function 'drop_caches'
My bad - I fixed it before 0cb281815 ("tools: Check headers with checkpatch.pl") which included the report also for headers. And yes, the rest of (mostly) formatting reports are in fanotify.h.
Obviously we haven't found all checks which aren't relevant for userspace, therefore I posted patch ignore some of them in LTP [2].
Quoted 1 line
I will fix it.
Thank you.
Kind regards,
Petr
[1] https://github.com/linux-test-project/ltp/releases
[2] https://lore.kernel.org/ltp/[email protected]/
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/9 syscalls/fanotify14: Require FAN_REPORT_FID support for entire test
In reply to Amir GoldsteinTo avoid complex requirements for the new test case, we now require FAN_REPORT_FID support for the entire test, which opts-out from testing on FUSE filesystem.
It is not clear that there is anything to gain from running this test on all_filsystems in the first place.
--- testcases/kernel/syscalls/fanotify/fanotify14.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify14.c +2 -5
@@ -219,11 +219,8 @@ out:static void do_setup (void ) { -int fd; - -/* Check for kernel fanotify support */ - fd =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY ); -SAFE_CLOSE (fd); +/* Require FAN_REPORT_FID support for all tests to simplify per test case requirements */ +REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS (FAN_REPORT_FID ,MNTPOINT ); fan_report_target_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME_TARGET ,MNTPOINT );
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/9] syscalls/fanotify14: Require FAN_REPORT_FID support for entire test
Hi Amir, all,
Quoted 3 lines
To avoid complex requirements for the new test case, we now require
FAN_REPORT_FIDsupport for the entire test, which opts-out from testing on FUSE filesystem.
Quoted 2 lines
It is not clear that there is anything to gain from running this test on
all_filsystemsin the first place.
Interesting.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/9 syscalls/fanotify14: Add test cases for FAN_MARK_IGNORE
In reply to Amir GoldsteinFAN_MARK_IGNORE is a new API so it also enforces strict rules about which events and flags are allowed on a non-dir inode mark.
FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY for anything expect a non-dir inode mark.
--- .../kernel/syscalls/fanotify/fanotify14.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify14.c +35 -0
@@ -39,6 +39,7 @@static int fanotify_fd;static int fan_report_target_fid_unsupported; +static int ignore_mark_unsupported;/* * Each test case has been designed in a manner whereby the values defined
@@ -107,6 +108,34 @@ static struct test_case_t {/* With FAN_REPORT_TARGET_FID, FAN_EVENT_ON_CHILD on non-dir is not valid */ FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET, 0, FAN_OPEN | FAN_EVENT_ON_CHILD, ENOTDIR }, + { +/* FAN_MARK_IGNORE_SURV with FAN_DELETE on non-dir is not valid */ +FAN_CLASS_NOTIF |FAN_REPORT_DFID_NAME ,FAN_MARK_IGNORE_SURV ,FAN_DELETE ,ENOTDIR + }, + { +/* FAN_MARK_IGNORE_SURV with FAN_RENAME on non-dir is not valid */ +FAN_CLASS_NOTIF |FAN_REPORT_DFID_NAME ,FAN_MARK_IGNORE_SURV ,FAN_RENAME ,ENOTDIR + }, + { +/* FAN_MARK_IGNORE_SURV with FAN_ONDIR on non-dir is not valid */ +FAN_CLASS_NOTIF |FAN_REPORT_DFID_NAME ,FAN_MARK_IGNORE_SURV ,FAN_OPEN |FAN_ONDIR ,ENOTDIR + }, + { +/* FAN_MARK_IGNORE_SURV with FAN_EVENT_ON_CHILD on non-dir is not valid */ +FAN_CLASS_NOTIF |FAN_REPORT_DFID_NAME ,FAN_MARK_IGNORE_SURV ,FAN_OPEN |FAN_EVENT_ON_CHILD ,ENOTDIR + }, + { +/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on directory is not valid */ +FAN_CLASS_NOTIF ,FAN_MARK_IGNORE ,FAN_OPEN ,EISDIR + }, + { +/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on mount mark is not valid */ +FAN_CLASS_NOTIF ,FAN_MARK_MOUNT |FAN_MARK_IGNORE ,FAN_OPEN ,EINVAL + }, + { +/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on filesystem mark is not valid */ +FAN_CLASS_NOTIF ,FAN_MARK_FILESYSTEM |FAN_MARK_IGNORE ,FAN_OPEN ,EINVAL + }, };static void do_test (unsigned int number)
@@ -120,6 +149,11 @@ static void do_test(unsigned int number)return ; } +if (ignore_mark_unsupported && tc->mark_flags &FAN_MARK_IGNORE ) { +tst_res (TCONF ,"FAN_MARK_IGNORE not supported in kernel?" ); +return ; + } + fanotify_fd =fanotify_init (tc->init_flags,O_RDONLY );if (fanotify_fd <0 ) {if (errno == tc->expected_errno) {
@@ -224,6 +258,7 @@ static void do_setup(void) fan_report_target_fid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME_TARGET ,MNTPOINT ); + ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV );/* Create temporary test file to place marks on */ SAFE_FILE_PRINTF (FILE1 ,"0" );
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/9] syscalls/fanotify14: Add test cases for FAN_MARK_IGNORE
Hi Amir, all,
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/9 syscalls/fanotify10: Avoid undesired event in test
In reply to Amir GoldsteinOpen fd for syncfs before creating groups to avoid the FAN_OPEN event that this open generates.
This event does not break any of the existing test cases, but should avoid it to avoid noise in future test cases.
--- testcases/kernel/syscalls/fanotify/fanotify10.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify10.c +9 -6
@@ -66,6 +66,7 @@ static unsigned int fanotify_class[] = {#define GROUPS_PER_PRIO 3static int fd_notify[NUM_CLASSES ][GROUPS_PER_PRIO ]; +static int fd_syncfs;static char event_buf[EVENT_BUF_LEN ];static int exec_events_unsupported;
@@ -342,14 +343,11 @@ static void show_fanotify_marks(int fd) } } -static void drop_caches (const char *path) +static void drop_caches () { -int fd =SAFE_OPEN (path,O_RDONLY ); - -if (syncfs (fd) <0 ) +if (syncfs (fd_syncfs) <0 )tst_brk (TBROK |TERRNO ,"Unexpected error when syncing filesystem" ); -SAFE_CLOSE (fd);SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); }
@@ -364,6 +362,9 @@ static int create_fanotify_groups(unsigned int n) mark = &fanotify_mark_types[tc->mark_type]; ignore_mark = &fanotify_mark_types[tc->ignore_mark_type]; +/* Open fd for syncfs before creating groups to avoid the FAN_OPEN event */ + fd_syncfs =SAFE_OPEN (MOUNT_PATH ,O_RDONLY ); +for (p =0 ; p < num_classes; p++) {for (i =0 ; i <GROUPS_PER_PRIO ; i++) { fd_notify[p][i] = SAFE_FANOTIFY_INIT(fanotify_class[p] |
@@ -413,7 +414,7 @@ add_mark:* drop_caches should evict inode from cache and remove evictable marks */ if (evictable_ignored) { -drop_caches (tc->mark_path); +drop_caches ();for (p =0 ; p < num_classes; p++) {for (i =0 ; i <GROUPS_PER_PRIO ; i++) {if (fd_notify[p][i] >0 )
@@ -435,6 +436,8 @@ static void cleanup_fanotify_groups(void)SAFE_CLOSE (fd_notify[p][i]); } } +if (fd_syncfs >0 ) +SAFE_CLOSE (fd_syncfs); }/* Flush out all pending dirty inodes and destructing marks */
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/9] syscalls/fanotify10: Avoid undesired event in test
Hi,
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/9] syscalls/fanotify10: Avoid undesired event in test
In reply to Amir GoldsteinHi all,
Quoted 10 lines
+++
b/testcases/kernel/syscalls/fanotify/fanotify10.ctestcases/kernel/syscalls/fanotify/fanotify10.c +1
-0@@ -66,6 +66,7 @@ static unsigned int fanotify_class[] = {#define GROUPS_PER_PRIO 3static int fd_notify[NUM_CLASSES ][GROUPS_PER_PRIO ]; +static int fd_syncfs;static char event_buf[EVENT_BUF_LEN ];static int exec_events_unsupported;
testcases/kernel/syscalls/fanotify/fanotify10.c static void show_fanotify_marks(int fd) · line 345
Quoted 4 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +0
-1@@ -342,14 +343,11 @@ static void show_fanotify_marks(int fd) } } -static void drop_caches (const char *path)
Note for myself to add void here before merge
testcases/kernel/syscalls/fanotify/fanotify10.c static void show_fanotify_marks(int fd) · line 347
Quoted 2 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +1
-0+static void drop_caches () {
fanotify10.c: In function ‘drop_caches’:
fanotify10.c:352:13: warning: old-style function definition [-Wold-style-definition]
352 | static void drop_caches()
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/9 syscalls/fanotify10: Add more verifications and debug info
In reply to Amir GoldsteinCheck that non-evictable inode ignore marks exist as expected and print mask of unexpected events.
Fix information printed for events from unexpected pid.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 4 ++ .../kernel/syscalls/fanotify/fanotify10.c | 41 ++++++++++++------- 2 files changed, 31 insertions(+), 14 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +4 -0
@@ -112,6 +112,10 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_MARK_IGNORE_SURV #define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)#endif +/* Non-uapi convenience macros */ +#ifndef FAN_MARK_TYPES +#define FAN_MARK_TYPES (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM) +#endif /* New dirent event masks */ #ifndef FAN_ATTRIB
testcases/kernel/syscalls/fanotify/fanotify10.c +27 -14
96 lines not on this page · raw message
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/9] syscalls/fanotify10: Add more verifications and debug info
Hi Amir, all,
Quoted 4 lines
Check that non-evictable inode ignore marks exist as expected and print mask of unexpected events.
Fix information printed for events from unexpected pid.
...
Quoted 1 line
+++
b/testcases/kernel/syscalls/fanotify/fanotify10.c
...
testcases/kernel/syscalls/fanotify/fanotify10.c static void test_fanotify(unsigned int n) · line 598
Quoted 11 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +4
-2@@ -582,14 +591,18 @@ static void test_fanotify(unsigned int n)for (p =1 ; p < num_classes && !tc->expected_mask_with_ignore; p++) {for (i =0 ; i <GROUPS_PER_PRIO ; i++) { ret =read (fd_notify[p][i], event_buf,EVENT_BUF_LEN ); -if (ret ==0 ) { +if (ret >=0 && ret < (int )FAN_EVENT_METADATA_LEN ) {tst_brk (TBROK , -"zero length read from fanotify fd" ); +"short read when reading fanotify " +"events (%d < %d)" , ret, + (int )EVENT_BUF_LEN );
Just for the record printing like this...
testcases/kernel/syscalls/fanotify/fanotify10.c static void test_fanotify(unsigned int n) · line 605
Quoted 9 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +4
-2} + event = (struct fanotify_event_metadata *)event_buf;if (ret >0 ) {tst_res (TFAIL ,"group %d (%x) with %s and " -"%s ignore mask got event" , - i, fanotify_class[p], mark->name, ignore_mark->name); +"%s ignore mask got unexpected event (mask %llx)" , + i, fanotify_class[p], mark->name, ignore_mark->name, + event->mask);
and this will be possible to avoid with macros include/tst_test_macros.h, which prints them for free. FYI there can be also custom error text instead of the failing syscall with parameters printed by default. But IMHO there should be a reason to use it (mostly the default should be good enough, in case of failure test reviewers will have to look into the test source anyway).
Kind regards,
Petr
Quoted 3 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +0
-0if (event->fd !=FAN_NOFD )SAFE_CLOSE (event->fd); }else if (errno ==EAGAIN ) {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/9 syscalls/fanotify10: Use dedicated mark type for inode mark on parent
In reply to Amir GoldsteinThis highlights the test cases that use a directory inode mark on parent in contrast to the test cases that use non-dir inode marks.
One test case that uses DIR_MNT2 for no reason (there are no mount marks in this test case) was changed to use the standard DIR_PATH.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 3 +++ .../kernel/syscalls/fanotify/fanotify10.c | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +3 -0
@@ -113,6 +113,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)#endif /* Non-uapi convenience macros */ +#ifndef FAN_MARK_PARENT +#define FAN_MARK_PARENT FAN_MARK_ONLYDIR +#endif #ifndef FAN_MARK_TYPES #define FAN_MARK_TYPES (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM)#endif
testcases/kernel/syscalls/fanotify/fanotify10.c +11 -9
@@ -102,6 +102,7 @@ static unsigned int num_classes = NUM_CLASSES;enum {FANOTIFY_INODE , +FANOTIFY_PARENT ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM ,FANOTIFY_EVICTABLE ,
@@ -109,6 +110,7 @@ enum {static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ), +INIT_FANOTIFY_MARK_TYPE (PARENT ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ),INIT_FANOTIFY_MARK_TYPE (EVICTABLE ),
@@ -243,57 +245,57 @@ static struct tcase { }, {"ignore child exec events created on a specific mount point" , -MOUNT_PATH ,FANOTIFY_INODE , +MOUNT_PATH ,FANOTIFY_PARENT ,MOUNT_PATH ,FANOTIFY_MOUNT ,0 ,FILE_EXEC_PATH ,FAN_OPEN_EXEC ,FAN_OPEN |FAN_OPEN_EXEC }, {"ignore events on children of directory created on a specific file" , -DIR_MNT2 ,FANOTIFY_INODE , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT , +DIR_PATH ,FANOTIFY_PARENT ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"ignore events on file created inside a parent watching children" ,FILE_PATH ,FANOTIFY_INODE , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore events on file created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_INODE , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore mount events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore mount events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore fs events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore fs events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -DIR_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_PARENT ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN },
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 6/9] syscalls/fanotify10: Use dedicated mark type for inode mark on parent
Hi all,
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/9 syscalls/fanotify10: Run tests with two ignore mask variants
In reply to Amir GoldsteinRun test with legacy FAN_MARK_IGNORED_MASK variant and new FAN_MARK_IGNORE variant if kernel supports it.
When running the new variant, do not need to use the hack of setting events and flags in both mask and ignored mask.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 3 ++ .../kernel/syscalls/fanotify/fanotify10.c | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +3 -0
@@ -113,6 +113,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)#endif /* Non-uapi convenience macros */ +#ifndef FAN_MARK_IGNORED_SURV +#define FAN_MARK_IGNORED_SURV (FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY) +#endif #ifndef FAN_MARK_PARENT #define FAN_MARK_PARENT FAN_MARK_ONLYDIR#endif
testcases/kernel/syscalls/fanotify/fanotify10.c +25 -9
@@ -73,6 +73,7 @@ static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported;static int evictable_mark_unsupported; +static int ignore_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"
@@ -393,24 +394,27 @@ static int create_fanotify_groups(unsigned int n)if (p ==0 )continue ; - mask =FAN_OPEN ; - mark_ignored =FAN_MARK_IGNORED_MASK | -FAN_MARK_IGNORED_SURV_MODIFY ; +/* +* Run tests in two variants: +* 1. Legacy FAN_MARK_IGNORED_MASK +* 2. FAN_MARK_IGNORE +*/ + mark_ignored = tst_variant ?FAN_MARK_IGNORE_SURV :FAN_MARK_IGNORED_SURV ; + mask =FAN_OPEN | tc->ignored_onchild; add_mark:SAFE_FANOTIFY_MARK (fd_notify[p][i],FAN_MARK_ADD | ignore_mark->flag | mark_ignored, mask,AT_FDCWD , tc->ignore_path);/* -* If ignored mask is on a parent watching children, -* also set the flag FAN_EVENT_ON_CHILD in mark mask. +* FAN_MARK_IGNORE respects FAN_EVENT_ON_CHILD flag, but legacy +* FAN_MARK_IGNORED_MASK does not. When using legacy ignore mask, +* if ignored mask is on a parent watching children, we need to +* also set the event and flag FAN_EVENT_ON_CHILD in mark mask. * This is needed to indicate that parent ignored mask * should be applied to events on children. */ -if (tc->ignored_onchild && mark_ignored) { - mask = tc->ignored_onchild; -/* XXX: temporary hack may be removed in the future */ - mask |=FAN_OPEN ; +if (tc->ignored_onchild && mark_ignored &FAN_MARK_IGNORED_MASK ) { mark_ignored =0 ; goto add_mark; }
@@ -535,6 +539,11 @@ static void test_fanotify(unsigned int n)return ; } +if (ignore_mark_unsupported && tst_variant) { +tst_res (TCONF ,"FAN_MARK_IGNORE not supported in kernel?" ); +return ; + } +if (tc->ignored_onchild &&tst_kvercmp (5 ,9 ,0 ) <0 ) {tst_res (TCONF ,"ignored mask in combination with flag FAN_EVENT_ON_CHILD" " has undefined behavior on kernel < 5.9" );
@@ -628,6 +637,7 @@ static void setup(void) FAN_CLASS_CONTENT, 0); filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); evictable_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_EVICTABLE ); + ignore_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_IGNORE_SURV ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );if (fan_report_dfid_unsupported) {
@@ -660,11 +670,17 @@ static void cleanup(void)SAFE_UMOUNT (MNT2_PATH );SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"%d" , old_cache_pressure); + +SAFE_UNLINK (FILE_PATH ); +SAFE_UNLINK (FILE2_PATH ); +SAFE_RMDIR (DIR_PATH ); +SAFE_RMDIR (MNT2_PATH ); }static struct tst_test test = { .test = test_fanotify, .tcnt =ARRAY_SIZE (tcases), + .test_variants =2 , .setup = setup, .cleanup = cleanup, .mount_device =1 ,
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 7/9] syscalls/fanotify10: Run tests with two ignore mask variants
Hi all,
1128 tests, quite impressive :).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 8/9 syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_EVENT_ON_CHILD
In reply to Amir GoldsteinVerify correct behavior with FAN_MARK_IGNORE when FAN_EVENT_ON_CHILD flag is set in ignore mask and not in mask and when the flag is set in mask and not in ignore mask.
We do this for 6 test cases where ignore mark is on parent dir, but not for the one test case where both mark and ignore mask are on parent dir.
--- .../kernel/syscalls/fanotify/fanotify10.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify10.c +28 -0
@@ -418,6 +418,34 @@ add_mark: mark_ignored =0 ; goto add_mark; } + +/* +* When using FAN_MARK_IGNORE, verify that the FAN_EVENT_ON_CHILD +* flag in mark mask does not affect the ignore mask. +* +* If parent does not want to ignore FAN_OPEN events on children, +* set a mark mask to watch FAN_CLOSE_WRITE events on children +* to make sure we do not ignore FAN_OPEN events from children. +* +* If parent wants to ignore FAN_OPEN events on childern, +* set a mark mask to watch FAN_CLOSE events only on parent itself +* to make sure we do not get FAN_CLOSE events from children. +* +* If we had already set the FAN_EVENT_ON_CHILD in the parent +* mark mask (mark_type == FANOTIFY_PARENT), then FAN_CLOSE mask +* will apply also to childern, so we skip this verification. +*/ +if (mark_ignored &FAN_MARK_IGNORE && + tc->ignore_mark_type ==FANOTIFY_PARENT ) { +if (!tc->ignored_onchild) + mask =FAN_CLOSE_WRITE |FAN_EVENT_ON_CHILD ; +else if (tc->mark_type ==FANOTIFY_PARENT ) +continue ; +else + mask =FAN_CLOSE |FAN_ONDIR ; + mark_ignored =0 ; + goto add_mark; + } } }
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 9/9 syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_ONDIR
In reply to Amir GoldsteinVerify correct behavior with FAN_MARK_IGNORE when the FAN_ONDIR flag is set in ignore mask and not in mask and when the flag is set in mask and not in ignore mask.
These test cases are skipped for the FAN_MARK_IGNORED_MASK variant where ignore mask is always applied to directories regardless of FAN_ONDIR flag in mask or ignore mask.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 3 + .../kernel/syscalls/fanotify/fanotify10.c | 56 ++++++++++++++++--- 2 files changed, 52 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +3 -0
@@ -119,6 +119,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_MARK_PARENT #define FAN_MARK_PARENT FAN_MARK_ONLYDIR#endif +#ifndef FAN_MARK_SUBDIR +#define FAN_MARK_SUBDIR FAN_MARK_ONLYDIR +#endif #ifndef FAN_MARK_TYPES #define FAN_MARK_TYPES (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM)#endif
testcases/kernel/syscalls/fanotify/fanotify10.c +49 -7
152 lines not on this page · raw message
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Amir!
Quoted 12 lines · Amir Goldstein
FAN_MARK_IGNOREfeature was merge in v6.0-rc1.
A man page draft was posted here [1].Following are the tests for the new feature.
All new test cases are skipped on old kernels.
Note that fanotify10 will run ALL of its existing test cases in two variants:
1. LegacyFAN_MARK_IGNORED_MASK
2. NewFAN_MARK_IGNORE
Quoted 4 lines
On old kernels, only the first variant of the test will run.
In addition to the new test variant it also has some new test cases that only run with new
FAN_MARK_IGNOREvariant.
Thanks for the tests! They look good to me although I have to admit my head starts to spin with the number of combinations and variations in fanotify10 testcase so I'm not very confident some subtle bug could not slip in. But hey, it's just tests and they are easy to fix if some breakage slips in. So feel free to add:
Honza
Quoted 22 lines
[1] https://lore.kernel.org/linux-man/[email protected]/
Amir Goldstein (9):
syscalls/fanotify09: Add test cases forFAN_MARK_IGNOREsyscalls/fanotify14: RequireFAN_REPORT_FIDsupport for entire test syscalls/fanotify14: Add test cases forFAN_MARK_IGNOREsyscalls/fanotify10: Avoid undesired event in test syscalls/fanotify10: Add more verifications and debug info syscalls/fanotify10: Use dedicated mark type for inode mark on parent syscalls/fanotify10: Run tests with two ignore mask variants syscalls/fanotify10: TestFAN_MARK_IGNOREwithFAN_EVENT_ON_CHILDsyscalls/fanotify10: TestFAN_MARK_IGNOREwithFAN_ONDIRtestcases/kernel/syscalls/fanotify/fanotify.h | 19 ++ .../kernel/syscalls/fanotify/fanotify09.c | 102 ++++++++-- .../kernel/syscalls/fanotify/fanotify10.c | 186 ++++++++++++++---- .../kernel/syscalls/fanotify/fanotify14.c | 42 +++- 4 files changed, 290 insertions(+), 59 deletions(-)Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 16 lines · Jan Kara
Hi Amir!
Quoted 12 lines · Amir Goldstein
FAN_MARK_IGNOREfeature was merge in v6.0-rc1.
A man page draft was posted here [1].Following are the tests for the new feature.
All new test cases are skipped on old kernels.
Note that fanotify10 will run ALL of its existing test cases in two variants:
1. LegacyFAN_MARK_IGNORED_MASK
2. NewFAN_MARK_IGNORE
Quoted 8 lines
Quoted 4 lines
On old kernels, only the first variant of the test will run.
In addition to the new test variant it also has some new test cases that only run with new
FAN_MARK_IGNOREvariant.Thanks for the tests! They look good to me although I have to admit my head starts to spin with the number of combinations and variations in fanotify10 testcase so I'm not very confident some subtle bug could not slip in. But
Yeh.. I can follow fanotify10 only on a good day ;)
The good thing about it is that after staring at it for long enough I was able to extend it to provide test coverage for FAN_MARK_IGNORE with relatively very little changes.
Quoted 4 lines
hey, it's just tests and they are easy to fix if some breakage slips in. So feel free to add:
Reviewed-by Jan Kara <[email protected]>
Thanks!
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
patchset merged.
I tested it on various kernels, works as expected (old kernels TCONF; fanotify14 catches problems on 5.18.0 and 5.17.3, but 6.0.0-rc3 TPASS).
Thank you!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp