|
|
dfa500 |
commit 8d42bf859a289944749d9f978c076cd318119867
|
|
|
dfa500 |
Author: Lucas A. M. Magalhaes <lamm@linux.ibm.com>
|
|
|
dfa500 |
Date: Mon Feb 17 09:09:52 2020 -0300
|
|
|
dfa500 |
|
|
|
dfa500 |
Fix tst-pkey expectations on pkey_get [BZ #23202]
|
|
|
dfa500 |
|
|
|
dfa500 |
From the GNU C Library manual, the pkey_set can receive a combination of
|
|
|
dfa500 |
PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS. However PKEY_DISABLE_ACCESS
|
|
|
dfa500 |
is more restrictive than PKEY_DISABLE_WRITE and includes its behavior.
|
|
|
dfa500 |
|
|
|
dfa500 |
The test expects that after setting
|
|
|
dfa500 |
(PKEY_DISABLE_WRITE|PKEY_DISABLE_ACCESS) pkey_get should return the
|
|
|
dfa500 |
same. This may not be true as PKEY_DISABLE_ACCESS will succeed in
|
|
|
dfa500 |
describing the state of the key in this case.
|
|
|
dfa500 |
|
|
|
dfa500 |
The pkey behavior during signal handling is different between x86 and
|
|
|
dfa500 |
POWER. This change make the test compatible with both architectures.
|
|
|
dfa500 |
|
|
|
dfa500 |
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
|
|
|
dfa500 |
|
|
|
dfa500 |
diff --git a/sysdeps/unix/sysv/linux/tst-pkey.c b/sysdeps/unix/sysv/linux/tst-pkey.c
|
|
|
dfa500 |
index 5f721d4444490945..600b6f0098def773 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/sysv/linux/tst-pkey.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/sysv/linux/tst-pkey.c
|
|
|
dfa500 |
@@ -37,7 +37,7 @@ static pthread_barrier_t barrier;
|
|
|
dfa500 |
|
|
|
dfa500 |
/* The keys used for testing. These have been allocated with access
|
|
|
dfa500 |
rights set based on their array index. */
|
|
|
dfa500 |
-enum { key_count = 4 };
|
|
|
dfa500 |
+enum { key_count = 3 };
|
|
|
dfa500 |
static int keys[key_count];
|
|
|
dfa500 |
static volatile int *pages[key_count];
|
|
|
dfa500 |
|
|
|
dfa500 |
@@ -111,14 +111,16 @@ check_page_access (int page, bool write)
|
|
|
dfa500 |
}
|
|
|
dfa500 |
|
|
|
dfa500 |
static volatile sig_atomic_t sigusr1_handler_ran;
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* Used to check that access is revoked in signal handlers. */
|
|
|
dfa500 |
+/* Used to check the behavior in signal handlers. In x86 all access are
|
|
|
dfa500 |
+ revoked during signal handling. In PowerPC the key permissions are
|
|
|
dfa500 |
+ inherited by the interrupted thread. This test accept both approaches. */
|
|
|
dfa500 |
static void
|
|
|
dfa500 |
sigusr1_handler (int signum)
|
|
|
dfa500 |
{
|
|
|
dfa500 |
TEST_COMPARE (signum, SIGUSR1);
|
|
|
dfa500 |
for (int i = 0; i < key_count; ++i)
|
|
|
dfa500 |
- TEST_COMPARE (pkey_get (keys[i]), PKEY_DISABLE_ACCESS);
|
|
|
dfa500 |
+ TEST_VERIFY (pkey_get (keys[i]) == PKEY_DISABLE_ACCESS
|
|
|
dfa500 |
+ || pkey_get (keys[i]) == i);
|
|
|
dfa500 |
sigusr1_handler_ran = 1;
|
|
|
dfa500 |
}
|
|
|
dfa500 |
|