diff mbox series

[1/1] syscalls/fanotify10: Require kernel v4.19

Message ID 20181106124802.27170-1-pvorel@suse.cz
State Rejected
Headers show
Series [1/1] syscalls/fanotify10: Require kernel v4.19 | expand

Commit Message

Petr Vorel Nov. 6, 2018, 12:48 p.m. UTC
FAN_MARK_INODE and FAN_MARK_MOUNT were added in v4.19-rc2:
d54f4fba889b fanotify: add API to attach/detach super block mark

Fixes: 16f127f4a syscalls/fanotify10: new test for mount ignore mask

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/fanotify/fanotify10.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Cyril Hrubis Nov. 6, 2018, 12:50 p.m. UTC | #1
Hi!
> FAN_MARK_INODE and FAN_MARK_MOUNT were added in v4.19-rc2:
> d54f4fba889b fanotify: add API to attach/detach super block mark
> 
> Fixes: 16f127f4a syscalls/fanotify10: new test for mount ignore mask

I would slightly prefer handling whatever error we get from fanotify so
that the test would also work in a case that the functionality would get
backported to older kernel. But if that's not easily done we may as well
go for the kernel version detection.

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/syscalls/fanotify/fanotify10.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index 2b96de2f1..bfc60cf89 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -298,7 +298,8 @@ static struct tst_test test = {
>  	.mount_device = 1,
>  	.mntpoint = MOUNT_PATH,
>  	.needs_tmpdir = 1,
> -	.needs_root = 1
> +	.needs_root = 1,
> +	.min_kver = "4.19",
>  };
>  
>  #else
> -- 
> 2.19.1
>
Petr Vorel Nov. 6, 2018, 12:55 p.m. UTC | #2
Hi,

> > FAN_MARK_INODE and FAN_MARK_MOUNT were added in v4.19-rc2:
> > d54f4fba889b fanotify: add API to attach/detach super block mark

> > Fixes: 16f127f4a syscalls/fanotify10: new test for mount ignore mask

> I would slightly prefer handling whatever error we get from fanotify so
> that the test would also work in a case that the functionality would get
> backported to older kernel. But if that's not easily done we may as well
> go for the kernel version detection.
Make sense. Amir, any idea, how to do that?

> > +	.min_kver = "4.19",

Kind regards,
Petr
Amir Goldstein Nov. 6, 2018, 12:59 p.m. UTC | #3
On Tue, Nov 6, 2018 at 2:55 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi,
>
> > > FAN_MARK_INODE and FAN_MARK_MOUNT were added in v4.19-rc2:
> > > d54f4fba889b fanotify: add API to attach/detach super block mark
>
> > > Fixes: 16f127f4a syscalls/fanotify10: new test for mount ignore mask
>
> > I would slightly prefer handling whatever error we get from fanotify so
> > that the test would also work in a case that the functionality would get
> > backported to older kernel. But if that's not easily done we may as well
> > go for the kernel version detection.
> Make sense. Amir, any idea, how to do that?
>

There must be some confusion.
FAN_MARK_MOUNT was NOT added in v4.19-rc2.
It has been there from the start.
FAN_MARK_INODE was NOT added either
the define FAN_MARK_INODE  0 is just a convenience readability define
it does not change the API.

You may be confusing with FAN_MARK_FILESYSTEM
just was just added in kernel v4.20-rc1.
The extension of tests to cover FAN_MARK_FILESYSTEM
is waiting in my queue:
https://github.com/amir73il/ltp/commits/fanotify_sb

And it already includes runtime checks for FAN_MARK_FILESYSTEM
support.

Did I miss anything?

Thanks,
Amir.
Petr Vorel Nov. 6, 2018, 1:06 p.m. UTC | #4
Hi Amir,

> There must be some confusion.
> FAN_MARK_MOUNT was NOT added in v4.19-rc2.
> It has been there from the start.
> FAN_MARK_INODE was NOT added either
> the define FAN_MARK_INODE  0 is just a convenience readability define
> it does not change the API.
I'm sorry, you're right.

> You may be confusing with FAN_MARK_FILESYSTEM
> just was just added in kernel v4.20-rc1.
> The extension of tests to cover FAN_MARK_FILESYSTEM
> is waiting in my queue:
> https://github.com/amir73il/ltp/commits/fanotify_sb

> And it already includes runtime checks for FAN_MARK_FILESYSTEM
> support.

> Did I miss anything?
Testing your branch on older kernel, fanotify10 fails earlier than new TCONF
checks:

tst_device.c:83: INFO: Found free device '/dev/loop0'
tst_mkfs.c:90: INFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
mke2fs 1.44.2 (14-May-2018)
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
fanotify10.c:233: INFO: Test #0: ignore mount events created on a specific file
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:299: PASS: group 0 (prio 1) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:299: PASS: group 1 (prio 1) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:299: PASS: group 2 (prio 1) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:299: PASS: group 0 (prio 2) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:299: PASS: group 1 (prio 2) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:299: PASS: group 2 (prio 2) with FAN_MARK_MOUNT and FAN_MARK_INODE ignore mask got no event
fanotify10.c:233: INFO: Test #1: don't ignore mount events created on another file
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:233: INFO: Test #2: ignore inode events created on a specific mount point
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:293: FAIL: group 0 (prio 1) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:293: FAIL: group 1 (prio 1) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:293: FAIL: group 2 (prio 1) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:293: FAIL: group 0 (prio 2) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:293: FAIL: group 1 (prio 2) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:293: FAIL: group 2 (prio 2) with FAN_MARK_INODE and FAN_MARK_MOUNT ignore mask got event
fanotify10.c:233: INFO: Test #3: don't ignore inode events created on another mount point
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 0 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 1 got event: mask 20 pid=6942 fd=12
fanotify10.c:221: PASS: group 2 got event: mask 20 pid=6942 fd=12
fanotify10.c:233: INFO: Test #4: ignore fs events created on a specific file
fanotify10.c:162: CONF: FAN_MARK_FILESYSTEM not supported in kernel?
fanotify10.c:233: INFO: Test #5: don't ignore mount events created on another file
fanotify10.c:162: CONF: FAN_MARK_FILESYSTEM not supported in kernel?
fanotify10.c:233: INFO: Test #6: ignore fs events created on a specific mount point
fanotify10.c:162: CONF: FAN_MARK_FILESYSTEM not supported in kernel?
fanotify10.c:233: INFO: Test #7: don't ignore fs events created on another mount point
fanotify10.c:162: CONF: FAN_MARK_FILESYSTEM not supported in kernel?

Summary:
passed   30
failed   6
skipped  4
warnings 0


Kind regards,
Petr
Amir Goldstein Nov. 6, 2018, 1:32 p.m. UTC | #5
On Tue, Nov 6, 2018 at 3:06 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> > There must be some confusion.
> > FAN_MARK_MOUNT was NOT added in v4.19-rc2.
> > It has been there from the start.
> > FAN_MARK_INODE was NOT added either
> > the define FAN_MARK_INODE  0 is just a convenience readability define
> > it does not change the API.
> I'm sorry, you're right.
>
> > You may be confusing with FAN_MARK_FILESYSTEM
> > just was just added in kernel v4.20-rc1.
> > The extension of tests to cover FAN_MARK_FILESYSTEM
> > is waiting in my queue:
> > https://github.com/amir73il/ltp/commits/fanotify_sb
>
> > And it already includes runtime checks for FAN_MARK_FILESYSTEM
> > support.
>
> > Did I miss anything?
> Testing your branch on older kernel, fanotify10 fails earlier than new TCONF

Because fanotify10 checks for a bug that existed since the beginning
and fixed by 9bdda4e9cf2d fsnotify: fix ignore mask logic in fsnotify().
So test SHOULD fail until the backported patch is applied to the old kernel.

The patch does not apply cleanly to kernels <= v4.17.
Tested backport patch for v4.14.y attached.

Thanks,
Amir.
From 657b3d5db0b930c7cdfa47131c48a24c64c08ae8 Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@gmail.com>
Date: Sat, 1 Sep 2018 09:40:01 +0300
Subject: [PATCH] fsnotify: fix ignore mask logic in fsnotify()

Commit 92183a42898d ("fsnotify: fix ignore mask logic in
send_to_group()") acknoledges the use case of ignoring an event on
an inode mark, because of an ignore mask on a mount mark of the same
group (i.e. I want to get all events on this file, except for the events
that came from that mount).

This change depends on correctly merging the inode marks and mount marks
group lists, so that the mount mark ignore mask would be tested in
send_to_group(). Alas, the merging of the lists did not take into
account the case where event in question is not in the mask of any of
the mount marks.

To fix this, completely remove the tests for inode and mount event masks
from the lists merging code.

Fixes: 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
[amir: backport to v4.14.y]
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fsnotify.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index d76c81323dc1..2bc61e7543dd 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -286,17 +286,13 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 
 	iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
 
-	if ((mask & FS_MODIFY) ||
-	    (test_mask & to_tell->i_fsnotify_mask)) {
-		inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
+	inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
+				      &fsnotify_mark_srcu);
+	if (inode_conn)
+		inode_node = srcu_dereference(inode_conn->list.first,
 					      &fsnotify_mark_srcu);
-		if (inode_conn)
-			inode_node = srcu_dereference(inode_conn->list.first,
-						      &fsnotify_mark_srcu);
-	}
 
-	if (mnt && ((mask & FS_MODIFY) ||
-		    (test_mask & mnt->mnt_fsnotify_mask))) {
+	if (mnt) {
 		inode_conn = srcu_dereference(to_tell->i_fsnotify_marks,
 					      &fsnotify_mark_srcu);
 		if (inode_conn)
Sasha Levin Nov. 6, 2018, 5:46 p.m. UTC | #6
On Tue, Nov 06, 2018 at 03:32:33PM +0200, Amir Goldstein wrote:
>On Tue, Nov 6, 2018 at 3:06 PM Petr Vorel <pvorel@suse.cz> wrote:
>>
>> Hi Amir,
>>
>> > There must be some confusion.
>> > FAN_MARK_MOUNT was NOT added in v4.19-rc2.
>> > It has been there from the start.
>> > FAN_MARK_INODE was NOT added either
>> > the define FAN_MARK_INODE  0 is just a convenience readability define
>> > it does not change the API.
>> I'm sorry, you're right.
>>
>> > You may be confusing with FAN_MARK_FILESYSTEM
>> > just was just added in kernel v4.20-rc1.
>> > The extension of tests to cover FAN_MARK_FILESYSTEM
>> > is waiting in my queue:
>> > https://github.com/amir73il/ltp/commits/fanotify_sb
>>
>> > And it already includes runtime checks for FAN_MARK_FILESYSTEM
>> > support.
>>
>> > Did I miss anything?
>> Testing your branch on older kernel, fanotify10 fails earlier than new TCONF
>
>Because fanotify10 checks for a bug that existed since the beginning
>and fixed by 9bdda4e9cf2d fsnotify: fix ignore mask logic in fsnotify().
>So test SHOULD fail until the backported patch is applied to the old kernel.
>
>The patch does not apply cleanly to kernels <= v4.17.
>Tested backport patch for v4.14.y attached.

Queued for 4.14, thanks Amir.

--
Thanks,
Sasha
Petr Vorel Nov. 12, 2018, 1:11 p.m. UTC | #7
Hi Amir,

> > > Did I miss anything?
> > Testing your branch on older kernel, fanotify10 fails earlier than new TCONF

> Because fanotify10 checks for a bug that existed since the beginning
> and fixed by 9bdda4e9cf2d fsnotify: fix ignore mask logic in fsnotify().
> So test SHOULD fail until the backported patch is applied to the old kernel.

> The patch does not apply cleanly to kernels <= v4.17.
> Tested backport patch for v4.14.y attached.

Thanks for info and Cc us for your patch in kernel.

> Thanks,
> Amir.
Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 2b96de2f1..bfc60cf89 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -298,7 +298,8 @@  static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
 	.needs_tmpdir = 1,
-	.needs_root = 1
+	.needs_root = 1,
+	.min_kver = "4.19",
 };
 
 #else