diff mbox series

linux: Also check pkey_get for ENOSYS on tst-pkey (BZ 31996)

Message ID 20240719142320.881675-1-adhemerval.zanella@linaro.org
State New
Headers show
Series linux: Also check pkey_get for ENOSYS on tst-pkey (BZ 31996) | expand

Commit Message

Adhemerval Zanella Netto July 19, 2024, 2:23 p.m. UTC
The powerpc pkey_get/pkey_set support was only added for 64-bit [1],
and tst-pkey only checks if the support was present with pkey_alloc
(which does not fail on powerpc32, at least running a 64-bit kernel).

Checked on powerpc-linux-gnu.

[1] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520
---
 sysdeps/unix/sysv/linux/tst-pkey.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Andreas K. Huettel July 19, 2024, 5:28 p.m. UTC | #1
Am Freitag, 19. Juli 2024, 16:23:15 MESZ schrieb Adhemerval Zanella:
> The powerpc pkey_get/pkey_set support was only added for 64-bit [1],
> and tst-pkey only checks if the support was present with pkey_alloc
> (which does not fail on powerpc32, at least running a 64-bit kernel).
> 
> Checked on powerpc-linux-gnu.
> 

OK for 2.40

Reviewed-By: Andreas K. Huettel <dilfridge@gentoo.org>

> [1] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520
> ---
>  sysdeps/unix/sysv/linux/tst-pkey.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
> index d9083daab9..46f55666da 100644
> --- a/sysdeps/unix/sysv/linux/tst-pkey.c
> +++ b/sysdeps/unix/sysv/linux/tst-pkey.c
> @@ -205,7 +205,13 @@ do_test (void)
>             " protection keys");
>        FAIL_EXIT1 ("pkey_alloc: %m");
>      }
> -  TEST_COMPARE (pkey_get (keys[0]), 0);
> +  if (pkey_get (keys[0]) < 0)
> +    {
> +      if (errno == ENOSYS)
> +	FAIL_UNSUPPORTED
> +	  ("glibc does not support memory protection keys");
> +      FAIL_EXIT1 ("pkey_alloc: %m");
> +    }
>    for (int i = 1; i < key_count; ++i)
>      {
>        keys[i] = pkey_alloc (0, i);
>
Carlos O'Donell July 19, 2024, 8:52 p.m. UTC | #2
On 7/19/24 1:28 PM, Andreas K. Huettel wrote:
> Am Freitag, 19. Juli 2024, 16:23:15 MESZ schrieb Adhemerval Zanella:
>> The powerpc pkey_get/pkey_set support was only added for 64-bit [1],
>> and tst-pkey only checks if the support was present with pkey_alloc
>> (which does not fail on powerpc32, at least running a 64-bit kernel).
>>
>> Checked on powerpc-linux-gnu.
>>
> 
> OK for 2.40
> 
> Reviewed-By: Andreas K. Huettel <dilfridge@gentoo.org>
> 
>> [1] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520
>> ---
>>  sysdeps/unix/sysv/linux/tst-pkey.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
>> index d9083daab9..46f55666da 100644
>> --- a/sysdeps/unix/sysv/linux/tst-pkey.c
>> +++ b/sysdeps/unix/sysv/linux/tst-pkey.c
>> @@ -205,7 +205,13 @@ do_test (void)
>>             " protection keys");
>>        FAIL_EXIT1 ("pkey_alloc: %m");
>>      }
>> -  TEST_COMPARE (pkey_get (keys[0]), 0);
>> +  if (pkey_get (keys[0]) < 0)
>> +    {
>> +      if (errno == ENOSYS)
>> +	FAIL_UNSUPPORTED
>> +	  ("glibc does not support memory protection keys");
>> +      FAIL_EXIT1 ("pkey_alloc: %m");

This should be "pkey_get: %m" since that is the call that you just made.

>> +    }
>>    for (int i = 1; i < key_count; ++i)
>>      {
>>        keys[i] = pkey_alloc (0, i);
>>
> 
>
Andreas K. Huettel July 19, 2024, 9:04 p.m. UTC | #3
Am Freitag, 19. Juli 2024, 22:52:40 MESZ schrieb Carlos O'Donell:
> On 7/19/24 1:28 PM, Andreas K. Huettel wrote:
> > Am Freitag, 19. Juli 2024, 16:23:15 MESZ schrieb Adhemerval Zanella:
> >> The powerpc pkey_get/pkey_set support was only added for 64-bit [1],
> >> and tst-pkey only checks if the support was present with pkey_alloc
> >> (which does not fail on powerpc32, at least running a 64-bit kernel).
> >>
> >> Checked on powerpc-linux-gnu.
> >>
> > 
> > OK for 2.40
> > 
> > Reviewed-By: Andreas K. Huettel <dilfridge@gentoo.org>
> > 
> >> [1] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520
> >> ---
> >>  sysdeps/unix/sysv/linux/tst-pkey.c | 8 +++++++-
> >>  1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
> >> index d9083daab9..46f55666da 100644
> >> --- a/sysdeps/unix/sysv/linux/tst-pkey.c
> >> +++ b/sysdeps/unix/sysv/linux/tst-pkey.c
> >> @@ -205,7 +205,13 @@ do_test (void)
> >>             " protection keys");
> >>        FAIL_EXIT1 ("pkey_alloc: %m");
> >>      }
> >> -  TEST_COMPARE (pkey_get (keys[0]), 0);
> >> +  if (pkey_get (keys[0]) < 0)
> >> +    {
> >> +      if (errno == ENOSYS)
> >> +	FAIL_UNSUPPORTED
> >> +	  ("glibc does not support memory protection keys");
> >> +      FAIL_EXIT1 ("pkey_alloc: %m");
> 
> This should be "pkey_get: %m" since that is the call that you just made.
> 

Pushed a fix-up.

Hopefully the last non-release-related commit before the release.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
index d9083daab9..46f55666da 100644
--- a/sysdeps/unix/sysv/linux/tst-pkey.c
+++ b/sysdeps/unix/sysv/linux/tst-pkey.c
@@ -205,7 +205,13 @@  do_test (void)
            " protection keys");
       FAIL_EXIT1 ("pkey_alloc: %m");
     }
-  TEST_COMPARE (pkey_get (keys[0]), 0);
+  if (pkey_get (keys[0]) < 0)
+    {
+      if (errno == ENOSYS)
+	FAIL_UNSUPPORTED
+	  ("glibc does not support memory protection keys");
+      FAIL_EXIT1 ("pkey_alloc: %m");
+    }
   for (int i = 1; i < key_count; ++i)
     {
       keys[i] = pkey_alloc (0, i);