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: fweimer@redhat.com
Subject: [PATCH v4] Fix tst-pkey expectations on pkey_get [BZ #23202]
Date: Mon, 17 Feb 2020 09:09:52 -0300	[thread overview]
Message-ID: <20200217120952.5219-1-lamm@linux.ibm.com> (raw)
In-Reply-To: <871rqwyoxl.fsf@oldenburg2.str.redhat.com>

From the GNU C Library manual the pkey_set can receive a combination of
PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS.  However PKEY_DISABLE_ACCESS
is more restrictive than PKEY_DISABLE_WRITE and includes its behavior.

The test expects that after setting
(PKEY_DISABLE_WRITE|PKEY_DISABLE_ACCESS) pkey_get should return the
same.  This may not be true as PKEY_DISABLE_ACCESS will succeed in
describe the state of the key in this case.

The pkey behavior during signal handling is different between x86 and
POWER.  This change make the test compatible with both architectures.

---

Hi,

in V4:
	- Fix comments.

in V3:
	- Commit message changes.
	- Add comments.

in V2:
	- Fix signal handling expectations to accept x86 and POWER behavior.

 sysdeps/unix/sysv/linux/tst-pkey.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
index 4ea1bc4f9a..cba40c73de 100644
--- a/sysdeps/unix/sysv/linux/tst-pkey.c
+++ b/sysdeps/unix/sysv/linux/tst-pkey.c
@@ -37,7 +37,7 @@ static pthread_barrier_t barrier;
 
 /* The keys used for testing.  These have been allocated with access
    rights set based on their array index.  */
-enum { key_count = 4 };
+enum { key_count = 3 };
 static int keys[key_count];
 static volatile int *pages[key_count];
 
@@ -111,14 +111,16 @@ check_page_access (int page, bool write)
 }
 
 static volatile sig_atomic_t sigusr1_handler_ran;
-
-/* Used to check that access is revoked in signal handlers.  */
+/* Used to check the behavior in signal handlers.  In x86 all access are
+   revoked during signal handling.  In PowerPC the key permissions are
+   inherited by the interrupted thread. This test accept both approaches.  */
 static void
 sigusr1_handler (int signum)
 {
   TEST_COMPARE (signum, SIGUSR1);
   for (int i = 0; i < key_count; ++i)
-    TEST_COMPARE (pkey_get (keys[i]), PKEY_DISABLE_ACCESS);
+    TEST_VERIFY (pkey_get (keys[i]) == PKEY_DISABLE_ACCESS
+                 || pkey_get (keys[i]) == i);
   sigusr1_handler_ran = 1;
 }
 
-- 
2.20.1


  reply	other threads:[~2020-02-17 12:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 13:46 [PATCH] Fix tst-pkey expectations on pkey_get Lucas A. M. Magalhaes
2020-02-07 18:22 ` Florian Weimer
2020-02-11 14:03   ` Lucas A. M. Magalhaes
2020-02-11 16:08     ` Florian Weimer
2020-02-12 16:45       ` Lucas A. M. Magalhaes
2020-02-12 17:17         ` Florian Weimer
2020-02-13 18:41 ` [PATCH V2] " Lucas A. M. Magalhaes
2020-02-14 17:02   ` Florian Weimer
2020-02-14 20:44   ` [PATCH v3] Fix tst-pkey expectations on pkey_get [BZ #23202] Lucas A. M. Magalhaes
2020-02-15 13:12     ` Florian Weimer
2020-02-17 12:09       ` Lucas A. M. Magalhaes [this message]
2020-02-17 12:50         ` [PATCH v4] " Florian Weimer
2020-02-19 14:41         ` Tulio Magno Quites Machado Filho

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=20200217120952.5219-1-lamm@linux.ibm.com \
    --to=lamm@linux.ibm.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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).