diff mbox series

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

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

Commit Message

Petr Vorel Jan. 26, 2024, 12:16 p.m. UTC
/dev/zero on pipe write started to succeeded on kernel 6.7.

This is due commit 1b057bd800c3 ("drivers/char/mem: implement splice()
for /dev/zero, /dev/full") from kernel 6.7.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Skip only for kernel >= 6.7

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

Comments

Martin Doucha Jan. 26, 2024, 1:11 p.m. UTC | #1
Hi,
splice() works on /dev/zero and /proc/self/maps on older kernels at 
least between v4.4 and v5.3.

On 26. 01. 24 13:16, Petr Vorel wrote:
> /dev/zero on pipe write started to succeeded on kernel 6.7.
> 
> This is due commit 1b057bd800c3 ("drivers/char/mem: implement splice()
> for /dev/zero, /dev/full") from kernel 6.7.
> 
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Changes v1->v2:
> * Skip only for kernel >= 6.7
> 
>   testcases/kernel/syscalls/splice/splice07.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
> index 135c42e47..c7b1c9ee5 100644
> --- a/testcases/kernel/syscalls/splice/splice07.c
> +++ b/testcases/kernel/syscalls/splice/splice07.c
> @@ -44,6 +44,10 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>   		/* And this complains about socket not being connected */
>   		case TST_FD_INET_SOCK:
>   			return;
> +		/* 1b057bd800c3 implemented splice() for /dev/zero, /dev/full */
> +		case TST_FD_DEV_ZERO:
> +			if (tst_kvercmp(6, 7, 0) >= 0)
> +				return;
>   		default:
>   		break;
>   		}
Petr Vorel Jan. 26, 2024, 1:20 p.m. UTC | #2
> Hi,
> splice() works on /dev/zero and /proc/self/maps on older kernels at least
> between v4.4 and v5.3.

Yep, this was just a sanity fix before the release to fix mainline.
OK, so we should skip also between v4.4 and v5.3?
Because you're testing it, please post better version.

And we should (as Cyril noted) after release add tests which actually test
splice() on /dev/zero and /proc/self/maps.

Thanks!

Kind regards,
Petr
Jan Kara Jan. 26, 2024, 2:13 p.m. UTC | #3
On Fri 26-01-24 13:16:03, Petr Vorel wrote:
> /dev/zero on pipe write started to succeeded on kernel 6.7.
> 
> This is due commit 1b057bd800c3 ("drivers/char/mem: implement splice()
> for /dev/zero, /dev/full") from kernel 6.7.
> 
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>

Yeah, makes sense to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> Changes v1->v2:
> * Skip only for kernel >= 6.7
> 
>  testcases/kernel/syscalls/splice/splice07.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
> index 135c42e47..c7b1c9ee5 100644
> --- a/testcases/kernel/syscalls/splice/splice07.c
> +++ b/testcases/kernel/syscalls/splice/splice07.c
> @@ -44,6 +44,10 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>  		/* And this complains about socket not being connected */
>  		case TST_FD_INET_SOCK:
>  			return;
> +		/* 1b057bd800c3 implemented splice() for /dev/zero, /dev/full */
> +		case TST_FD_DEV_ZERO:
> +			if (tst_kvercmp(6, 7, 0) >= 0)
> +				return;
>  		default:
>  		break;
>  		}
> -- 
> 2.43.0
>
Cyril Hrubis Jan. 26, 2024, 2:14 p.m. UTC | #4
Hi!
> splice() works on /dev/zero and /proc/self/maps on older kernels at 
> least between v4.4 and v5.3.

My guess would have been that this stopped working after the changes for
set_fs removal, see:

https://lwn.net/Articles/832121/

and kernel commit 36e2c7421f02

The article explicitly cites that splice() stopped working for files
that does not implemente splice_read().

So splice for these two didn't work between 5.10 and 6.7.
Martin Doucha Jan. 26, 2024, 2:19 p.m. UTC | #5
On 26. 01. 24 15:14, Cyril Hrubis wrote:
> Hi!
>> splice() works on /dev/zero and /proc/self/maps on older kernels at
>> least between v4.4 and v5.3.
> 
> My guess would have been that this stopped working after the changes for
> set_fs removal, see:
> 
> https://lwn.net/Articles/832121/
> 
> and kernel commit 36e2c7421f02
> 
> The article explicitly cites that splice() stopped working for files
> that does not implemente splice_read().
> 
> So splice for these two didn't work between 5.10 and 6.7.

In that case it makes sense to treat /dev/zero and /proc/self/maps as 
unconditionally expected success for splice() to writable pipe.
Cyril Hrubis Jan. 26, 2024, 2:26 p.m. UTC | #6
Hi!
> In that case it makes sense to treat /dev/zero and /proc/self/maps as 
> unconditionally expected success for splice() to writable pipe.

I suppose so. And ideally we should write a separate test just for that
after the release.
Martin Doucha Jan. 26, 2024, 2:35 p.m. UTC | #7
On 26. 01. 24 15:26, Cyril Hrubis wrote:
> Hi!
>> In that case it makes sense to treat /dev/zero and /proc/self/maps as
>> unconditionally expected success for splice() to writable pipe.
> 
> I suppose so. And ideally we should write a separate test just for that
> after the release.

+1 to new test.
Petr Vorel Jan. 29, 2024, 10:11 a.m. UTC | #8
Hi,

just for a record in the end we decided to merge v1.

https://lore.kernel.org/ltp/20240125155107.430656-1-pvorel@suse.cz/
https://lore.kernel.org/ltp/Zbd44afh7ytamDuA@yuki/

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..c7b1c9ee5 100644
--- a/testcases/kernel/syscalls/splice/splice07.c
+++ b/testcases/kernel/syscalls/splice/splice07.c
@@ -44,6 +44,10 @@  static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
 		/* And this complains about socket not being connected */
 		case TST_FD_INET_SOCK:
 			return;
+		/* 1b057bd800c3 implemented splice() for /dev/zero, /dev/full */
+		case TST_FD_DEV_ZERO:
+			if (tst_kvercmp(6, 7, 0) >= 0)
+				return;
 		default:
 		break;
 		}