[v2,2/3] splice: fsnotify_modify(fd) in vmsplice

Message ID raezzuhjjoddoc5tsln2bg3rkudczwou4jjfq6noeawrtn6jre@uvf4rikifzpx
State New
Headers
Series fanotify accounting for fs/splice.c |

Commit Message

Ahelenia Ziemiańska June 26, 2023, 11:09 p.m. UTC
  Same logic applies here: this can fill up the pipe and pollers that rely
on getting IN_MODIFY notifications never wake up.

Fixes: 983652c69199 ("splice: report related fsnotify events")
Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 fs/splice.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Amir Goldstein June 27, 2023, 6:27 a.m. UTC | #1
On Tue, Jun 27, 2023 at 2:09 AM Ahelenia Ziemiańska
<nabijaczleweli@nabijaczleweli.xyz> wrote:
>
> Same logic applies here: this can fill up the pipe and pollers that rely
> on getting IN_MODIFY notifications never wake up.
>
> Fixes: 983652c69199 ("splice: report related fsnotify events")
> Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
>  fs/splice.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 94fae24f9d54..a18274209dc1 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -1447,6 +1447,9 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov,
>         else
>                 error = vmsplice_to_user(f.file, &iter, flags);
>
> +       if (error > 0)
> +               fsnotify_modify(f.file);
> +

Wow, that is a twisted syscall, it does either write or read on the pipe
depending on whether it was open for read or write.

so you need to move fsnotify_modify() into vmsplice_to_pipe() and
add fsnotify_access() to vmsplice_to_user().

Thanks,
Amir.
  

Patch

diff --git a/fs/splice.c b/fs/splice.c
index 94fae24f9d54..a18274209dc1 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1447,6 +1447,9 @@  SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov,
 	else
 		error = vmsplice_to_user(f.file, &iter, flags);
 
+	if (error > 0)
+		fsnotify_modify(f.file);
+
 	kfree(iov);
 out_fdput:
 	fdput(f);