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

Message ID 4206d7388fdbee87053c9655919096225a461423.1687884031.git.nabijaczleweli@nabijaczleweli.xyz
State New
Headers
Series [v3,1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success |

Commit Message

Ahelenia Ziemiańska June 27, 2023, 4:55 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
Link: https://bugs.debian.org/1039488
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 fs/splice.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Amir Goldstein June 27, 2023, 6:11 p.m. UTC | #1
On Tue, Jun 27, 2023 at 7:55 PM 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
> Link: https://bugs.debian.org/1039488
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/splice.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index e16f4f032d2f..0eb36e93c030 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -1346,6 +1346,9 @@ static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
>                 pipe_unlock(pipe);
>         }
>
> +       if (ret > 0)
> +               fsnotify_access(file);
> +
>         return ret;
>  }
>
> @@ -1375,8 +1378,10 @@ static long vmsplice_to_pipe(struct file *file, struct iov_iter *iter,
>         if (!ret)
>                 ret = iter_to_pipe(iter, pipe, buf_flag);
>         pipe_unlock(pipe);
> -       if (ret > 0)
> +       if (ret > 0) {
>                 wakeup_pipe_readers(pipe);
> +               fsnotify_modify(file);
> +       }
>         return ret;
>  }
>
> --
> 2.39.2
>
  

Patch

diff --git a/fs/splice.c b/fs/splice.c
index e16f4f032d2f..0eb36e93c030 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1346,6 +1346,9 @@  static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
 		pipe_unlock(pipe);
 	}
 
+	if (ret > 0)
+		fsnotify_access(file);
+
 	return ret;
 }
 
@@ -1375,8 +1378,10 @@  static long vmsplice_to_pipe(struct file *file, struct iov_iter *iter,
 	if (!ret)
 		ret = iter_to_pipe(iter, pipe, buf_flag);
 	pipe_unlock(pipe);
-	if (ret > 0)
+	if (ret > 0) {
 		wakeup_pipe_readers(pipe);
+		fsnotify_modify(file);
+	}
 	return ret;
 }