unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Lucas A. M. Magalhaes" <lamm@linux.ibm.com>
To: libc-alpha@sourceware.org
Cc: tuliom@linux.ibm.com
Subject: [PATCH] Fix tst-pkey.c pkey_alloc return checks and manual
Date: Thu, 16 Jan 2020 10:39:12 -0300	[thread overview]
Message-ID: <20200116133912.2578-1-lamm@linux.ibm.com> (raw)

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.
---
 manual/memory.texi                 | 4 ++++
 sysdeps/unix/sysv/linux/tst-pkey.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/manual/memory.texi b/manual/memory.texi
index b565dd69f2..aa5011e4f9 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -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
 
diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
index 4c4fbae3ad..4ea1bc4f9a 100644
--- a/sysdeps/unix/sysv/linux/tst-pkey.c
+++ b/sysdeps/unix/sysv/linux/tst-pkey.c
@@ -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);
-- 
2.20.1


             reply	other threads:[~2020-01-16 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16 13:39 Lucas A. M. Magalhaes [this message]
2020-01-16 13:48 ` [PATCH] Fix tst-pkey.c pkey_alloc return checks and manual Florian Weimer
2020-01-16 13:51   ` Siddhesh Poyarekar
2020-01-17 12:40     ` Tulio Magno Quites Machado Filho
2020-01-16 13:57 ` Gabriel F. T. Gomes
2020-01-16 14:27   ` Lucas A. M. Magalhaes
2020-01-16 15:07     ` Gabriel F. T. Gomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200116133912.2578-1-lamm@linux.ibm.com \
    --to=lamm@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=tuliom@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).