diff mbox series

linux: Handle personality filtering for 32 bits

Message ID 20230606164830.126052-1-adhemerval.zanella@linaro.org
State New
Headers show
Series linux: Handle personality filtering for 32 bits | expand

Commit Message

Adhemerval Zanella Netto June 6, 2023, 4:48 p.m. UTC
Since commit e0043e17dfc52fe170274, 32 bit personality wrapper does
not set errno because kernel default implementation always successfully
changes the personality if requested (although some arch-specific
implementations might return an error, like aarch64).

However if syscall is being filtered (by a seccomp filter for instance)
there is no way to distinguish a syscall error
(INTERNAL_SYSCALL_ERROR_P) from a possible kernel value.

So in this case just set the test as unsupported.
---
 sysdeps/unix/sysv/linux/tst-personality.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Adhemerval Zanella Netto Aug. 2, 2023, 4:31 p.m. UTC | #1
Ping.

On 06/06/23 13:48, Adhemerval Zanella wrote:
> Since commit e0043e17dfc52fe170274, 32 bit personality wrapper does
> not set errno because kernel default implementation always successfully
> changes the personality if requested (although some arch-specific
> implementations might return an error, like aarch64).
> 
> However if syscall is being filtered (by a seccomp filter for instance)
> there is no way to distinguish a syscall error
> (INTERNAL_SYSCALL_ERROR_P) from a possible kernel value.
> 
> So in this case just set the test as unsupported.
> ---
>  sysdeps/unix/sysv/linux/tst-personality.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-personality.c b/sysdeps/unix/sysv/linux/tst-personality.c
> index 5e59627826..79d9c607e1 100644
> --- a/sysdeps/unix/sysv/linux/tst-personality.c
> +++ b/sysdeps/unix/sysv/linux/tst-personality.c
> @@ -34,10 +34,17 @@ do_test (void)
>    if (r == -1)
>      {
>        /* The syscall argument might be filtered by kernel, so the
> -        test can not check for the bug issue.  */
> +        test can not check for the bug issue.  For 32 bit architectures
> +        the syscall wrapper also never sets the errno (check commit
> +        e0043e17dfc52fe170274 for a full explanation), so in this case
> +        there is no way to detected if the syscall is filtered.  */
> +#if __WORDSIZE == 32
> +      FAIL_UNSUPPORTED ("personality syscall argument are filtered");
> +#else
>        if (errno == EPERM)
>         FAIL_UNSUPPORTED ("personality syscall argument are filtered");
>        FAIL_EXIT1 ("personality (%#x) failed: %m", test_persona);
> +#endif
>      }
>  
>    TEST_COMPARE (r, saved_persona);
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/tst-personality.c b/sysdeps/unix/sysv/linux/tst-personality.c
index 5e59627826..79d9c607e1 100644
--- a/sysdeps/unix/sysv/linux/tst-personality.c
+++ b/sysdeps/unix/sysv/linux/tst-personality.c
@@ -34,10 +34,17 @@  do_test (void)
   if (r == -1)
     {
       /* The syscall argument might be filtered by kernel, so the
-        test can not check for the bug issue.  */
+        test can not check for the bug issue.  For 32 bit architectures
+        the syscall wrapper also never sets the errno (check commit
+        e0043e17dfc52fe170274 for a full explanation), so in this case
+        there is no way to detected if the syscall is filtered.  */
+#if __WORDSIZE == 32
+      FAIL_UNSUPPORTED ("personality syscall argument are filtered");
+#else
       if (errno == EPERM)
        FAIL_UNSUPPORTED ("personality syscall argument are filtered");
       FAIL_EXIT1 ("personality (%#x) failed: %m", test_persona);
+#endif
     }
 
   TEST_COMPARE (r, saved_persona);