diff mbox series

[1/1] splice07: Whitelist /dev/zero on pipe write

Message ID 20240125155107.430656-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] splice07: Whitelist /dev/zero on pipe write | expand

Commit Message

Petr Vorel Jan. 25, 2024, 3:51 p.m. UTC
/dev/zero on pipe write started to succeeded on kernel 6.7.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

@Jan could you please check the problem is a kernel 6.7 bug
or just wanted change and we should whitelist /dev/zero on pipe write?

Thanks!

Kind regards,
Petr

 testcases/kernel/syscalls/splice/splice07.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Cyril Hrubis Jan. 26, 2024, noon UTC | #1
Hi!
> /dev/zero on pipe write started to succeeded on kernel 6.7.
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
> 
> @Jan could you please check the problem is a kernel 6.7 bug
> or just wanted change and we should whitelist /dev/zero on pipe write?
> 
> Thanks!
> 
> Kind regards,
> Petr
> 
>  testcases/kernel/syscalls/splice/splice07.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
> index 135c42e47..1fa13b3e6 100644
> --- a/testcases/kernel/syscalls/splice/splice07.c
> +++ b/testcases/kernel/syscalls/splice/splice07.c
> @@ -38,6 +38,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>  	if (fd_out->type == TST_FD_PIPE_WRITE) {
>  		switch (fd_in->type) {
>  		/* While these combinations succeeed */
> +		case TST_FD_DEV_ZERO:

long as the reading end is open and there is a space in the pipe. So I
suppose that we got EINVAL because the /dev/zero didn't support splice.

And indeed looking at git log drivers/char/mem.c shows:

commit 1b057bd800c3ea0c926191d7950cd2365eddc9bb
Author: Max Kellermann <max.kellermann@ionos.com>
Date:   Tue Sep 19 09:37:42 2023 +0200

    drivers/char/mem: implement splice() for /dev/zero, /dev/full

    This allows splicing zeroed pages into a pipe, and allows discarding
    pages from a pipe by splicing them to /dev/zero.  Writing to /dev/zero
    should have the same effect as writing to /dev/null, and a
    "splice_write" implementation exists only for /dev/null.

    (The /dev/zero splice_read implementation could be optimized by
    pushing references to the global zero page to the pipe, but that's an
    optimization for another day.)

    Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
    Link: https://lore.kernel.org/r/20230919073743.1066313-1-max.kellermann@ionos.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

With that I guess that we may want to skip the test only on newer
kernels and possibly implement splice test for these two special files
later on.


>  		case TST_FD_FILE:
>  		case TST_FD_MEMFD:
>  			return;
> -- 
> 2.43.0
>
Martin Doucha Jan. 29, 2024, 9:58 a.m. UTC | #2
Hi,
we should drop v2 and merge this patch.

Reviewed-by: Martin Doucha <mdoucha@suse.cz>

On 25. 01. 24 16:51, Petr Vorel wrote:
> /dev/zero on pipe write started to succeeded on kernel 6.7.
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
> 
> @Jan could you please check the problem is a kernel 6.7 bug
> or just wanted change and we should whitelist /dev/zero on pipe write?
> 
> Thanks!
> 
> Kind regards,
> Petr
> 
>   testcases/kernel/syscalls/splice/splice07.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
> index 135c42e47..1fa13b3e6 100644
> --- a/testcases/kernel/syscalls/splice/splice07.c
> +++ b/testcases/kernel/syscalls/splice/splice07.c
> @@ -38,6 +38,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>   	if (fd_out->type == TST_FD_PIPE_WRITE) {
>   		switch (fd_in->type) {
>   		/* While these combinations succeeed */
> +		case TST_FD_DEV_ZERO:
>   		case TST_FD_FILE:
>   		case TST_FD_MEMFD:
>   			return;
Cyril Hrubis Jan. 29, 2024, 10:07 a.m. UTC | #3
Hi!
> we should drop v2 and merge this patch.

Indeed with the commit that removed the generic splice implementation
from the kernel mentioned in the commit message.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel Jan. 29, 2024, 10:08 a.m. UTC | #4
Hi Martin,

> Hi,
> we should drop v2 and merge this patch.
thanks a lot, merged.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
index 135c42e47..1fa13b3e6 100644
--- a/testcases/kernel/syscalls/splice/splice07.c
+++ b/testcases/kernel/syscalls/splice/splice07.c
@@ -38,6 +38,7 @@  static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
 	if (fd_out->type == TST_FD_PIPE_WRITE) {
 		switch (fd_in->type) {
 		/* While these combinations succeeed */
+		case TST_FD_DEV_ZERO:
 		case TST_FD_FILE:
 		case TST_FD_MEMFD:
 			return;