Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret
@ 2025-07-09 16:30 Jan Polensky
  2025-07-10 13:32 ` Wei Gao via ltp
  2025-07-15  8:02 ` Andrea Cervesato via ltp
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Polensky @ 2025-07-09 16:30 UTC (permalink / raw)
  To: chrubis, pvorel; +Cc: Linux Test Project

Linux commit cbe4134ea4bc ("fs: export anon_inode_make_secure_inode() and fix
secretmem LSM bypass") prevents any access to secret memory pages from other
kernel subsystems.

Splice operations involving memfd secret are no longer valid and return EACCES.
These test cases are skipped accordingly.

This avoids false negatives in splice07 test:

    [skip]
    splice07.c:54: TFAIL: splice() on pipe read end -> memfd secret expected EBADF, EINVAL: EACCES (13)
    [skip]
    splice07.c:54: TFAIL: splice() on memfd secret -> pipe write end expected EBADF, EINVAL: EACCES (13)
    [skip]

Reference: cbe4134ea4bc ("fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass")
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
---
 testcases/kernel/syscalls/splice/splice07.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
index 2228e2f269de..c750a14bf439 100644
--- a/testcases/kernel/syscalls/splice/splice07.c
+++ b/testcases/kernel/syscalls/splice/splice07.c
@@ -27,6 +27,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
 		case TST_FD_UNIX_SOCK:
 		case TST_FD_INET_SOCK:
 		case TST_FD_MEMFD:
+		case TST_FD_MEMFD_SECRET:
 			return;
 		default:
 		break;
@@ -40,6 +41,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
 		case TST_FD_FILE:
 		case TST_FD_PROC_MAPS:
 		case TST_FD_MEMFD:
+		case TST_FD_MEMFD_SECRET:
 			return;
 		/* And this complains about socket not being connected */
 		case TST_FD_INET_SOCK:
-- 
2.50.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret
  2025-07-10 13:32 ` Wei Gao via ltp
@ 2025-07-10  7:43   ` Jan Polensky
  2025-07-15  8:01     ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Polensky @ 2025-07-10  7:43 UTC (permalink / raw)
  To: Wei Gao; +Cc: Linux Test Project

Hi Wei,
On Thu, Jul 10, 2025 at 09:32:12AM -0400, Wei Gao wrote:
> On Wed, Jul 09, 2025 at 06:30:22PM +0200, Jan Polensky wrote:
> > Linux commit cbe4134ea4bc ("fs: export anon_inode_make_secure_inode() and fix
[skip]
> >  		case TST_FD_INET_SOCK:
>
> Another option maybe we can add this error into exp_errnos, i guess can
> fix your issue?
>
> for example:
>         const int exp_errnos[] = {EBADF, EINVAL};
> +       const int exp_errnos[] = {EBADF, EINVAL, EACCES};
>
I’m concerned that this approach might make the tests too unspecific.

Associating specific combinations with corresponding error codes would
provide much more precise results. However, given the vast number of
possible combinations, such an effort seems hardly practical.
> > --
> > 2.50.0
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret
  2025-07-09 16:30 [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret Jan Polensky
@ 2025-07-10 13:32 ` Wei Gao via ltp
  2025-07-10  7:43   ` Jan Polensky
  2025-07-15  8:02 ` Andrea Cervesato via ltp
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Gao via ltp @ 2025-07-10 13:32 UTC (permalink / raw)
  To: Jan Polensky; +Cc: Linux Test Project

On Wed, Jul 09, 2025 at 06:30:22PM +0200, Jan Polensky wrote:
> Linux commit cbe4134ea4bc ("fs: export anon_inode_make_secure_inode() and fix
> secretmem LSM bypass") prevents any access to secret memory pages from other
> kernel subsystems.
> 
> Splice operations involving memfd secret are no longer valid and return EACCES.
> These test cases are skipped accordingly.
> 
> This avoids false negatives in splice07 test:
> 
>     [skip]
>     splice07.c:54: TFAIL: splice() on pipe read end -> memfd secret expected EBADF, EINVAL: EACCES (13)
>     [skip]
>     splice07.c:54: TFAIL: splice() on memfd secret -> pipe write end expected EBADF, EINVAL: EACCES (13)
>     [skip]
> 
> Reference: cbe4134ea4bc ("fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass")
> Signed-off-by: Jan Polensky <japo@linux.ibm.com>
> ---
>  testcases/kernel/syscalls/splice/splice07.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/splice/splice07.c b/testcases/kernel/syscalls/splice/splice07.c
> index 2228e2f269de..c750a14bf439 100644
> --- a/testcases/kernel/syscalls/splice/splice07.c
> +++ b/testcases/kernel/syscalls/splice/splice07.c
> @@ -27,6 +27,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>  		case TST_FD_UNIX_SOCK:
>  		case TST_FD_INET_SOCK:
>  		case TST_FD_MEMFD:
> +		case TST_FD_MEMFD_SECRET:
>  			return;
>  		default:
>  		break;
> @@ -40,6 +41,7 @@ static void check_splice(struct tst_fd *fd_in, struct tst_fd *fd_out)
>  		case TST_FD_FILE:
>  		case TST_FD_PROC_MAPS:
>  		case TST_FD_MEMFD:
> +		case TST_FD_MEMFD_SECRET:
>  			return;
>  		/* And this complains about socket not being connected */
>  		case TST_FD_INET_SOCK:

Another option maybe we can add this error into exp_errnos, i guess can
fix your issue?

for example:
        const int exp_errnos[] = {EBADF, EINVAL};
+       const int exp_errnos[] = {EBADF, EINVAL, EACCES};

> -- 
> 2.50.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret
  2025-07-10  7:43   ` Jan Polensky
@ 2025-07-15  8:01     ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-15  8:01 UTC (permalink / raw)
  To: Jan Polensky, Wei Gao; +Cc: Linux Test Project


On 7/10/25 9:43 AM, Jan Polensky wrote:
>> Another option maybe we can add this error into exp_errnos, i guess can
>> fix your issue?
>>
>> for example:
>>          const int exp_errnos[] = {EBADF, EINVAL};
>> +       const int exp_errnos[] = {EBADF, EINVAL, EACCES};
>>
> I’m concerned that this approach might make the tests too unspecific.
>
> Associating specific combinations with corresponding error codes would
> provide much more precise results. However, given the vast number of
> possible combinations, such an effort seems hardly practical.
A specific approach for the TST_FD_MEMFD_SECRET is probably required, 
because we don't really want to test EACCESS for all the other file 
descriptions. That might hide a bug in the kernel. We need to create a 
new test, since this one is only checking for EBADF/EINVAL according to 
the description.

- Andrea

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret
  2025-07-09 16:30 [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret Jan Polensky
  2025-07-10 13:32 ` Wei Gao via ltp
@ 2025-07-15  8:02 ` Andrea Cervesato via ltp
  1 sibling, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2025-07-15  8:02 UTC (permalink / raw)
  To: Jan Polensky, chrubis, pvorel; +Cc: Linux Test Project

Merged, thanks!

- Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-15  8:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 16:30 [LTP] [RFC PATCH v1 1/1] splice07.c: Skip invalid splice() tests involving memfd secret Jan Polensky
2025-07-10 13:32 ` Wei Gao via ltp
2025-07-10  7:43   ` Jan Polensky
2025-07-15  8:01     ` Andrea Cervesato via ltp
2025-07-15  8:02 ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox