]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix tst-pkey.c pkey_alloc return checks and manual
authorLucas A. M. Magalhaes <lamm@linux.ibm.com>
Thu, 16 Jan 2020 13:39:12 +0000 (10:39 -0300)
committerTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Fri, 17 Jan 2020 12:05:03 +0000 (09:05 -0300)
This test was failing in some powerpc systems as it was not checking
for ENOSPC return.

As said on the Linux man-pages and can be observed by the implementation
at mm/mprotect.c in the Linux Kernel source.  The syscall pkey_alloc can
return EINVAL or ENOSPC.  ENOSPC will indicate either that all keys are
in use or that the kernel does not support pkeys.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.net.br>
manual/memory.texi
sysdeps/unix/sysv/linux/tst-pkey.c

index b565dd69f2bff950f5d8d8017b642dae1706f371..aa5011e4f93b4bce74e249e714a2e36ef37dca7a 100644 (file)
@@ -3288,6 +3288,10 @@ in which memory protection keys are disabled.
 
 @item ENOSPC
 All available protection keys already have been allocated.
+
+The system does not implement memory protection keys or runs in a mode
+in which memory protection keys are disabled.
+
 @end table
 @end deftypefun
 
index 4c4fbae3ad8e3552893443c14d2914c2397642aa..4ea1bc4f9a92b79c69df53741d34f0f531b1e0d8 100644 (file)
@@ -197,6 +197,10 @@ do_test (void)
       if (errno == EINVAL)
         FAIL_UNSUPPORTED
           ("CPU does not support memory protection keys: %m");
+      if (errno == ENOSPC)
+        FAIL_UNSUPPORTED
+          ("no keys available or kernel does not support memory"
+           " protection keys");
       FAIL_EXIT1 ("pkey_alloc: %m");
     }
   TEST_COMPARE (pkey_get (keys[0]), 0);