Patch "x86/pkeys/selftests: Fix pkey exhaustion test off-by-one" has been added to the 4.14-stable tree
Subsystems (3)
[email protected]
AppliedThis is a note to let you know that I've just added the patch titled
x86/pkeys/selftests: Fix pkey exhaustion test off-by-one
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x86-pkeys-selftests-fix-pkey-exhaustion-test-off-by-one.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sun Jun 17 12:13:49 CEST 2018
From: Dave Hansen <[email protected]>
Date: Wed, 9 May 2018 10:13:50 -0700
Subject: x86/pkeys/selftests: Fix pkey exhaustion test off-by-one
From: Dave Hansen <[email protected]>
[ Upstream commit f50b4878329ab61d8e05796f655adeb6f5fb57c6 ]
In our "exhaust all pkeys" test, we make sure that there is the expected number available. Turns out that the test did not cover the execute-only key, but discussed it anyway. It did *not* discuss the test-allocated key.
Now that we have a test for the mprotect(PROT_EXEC) case, this off-by-one issue showed itself. Correct the off-by- one and add the explanation for the case we missed.
--- tools/testing/selftests/x86/protection_keys.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/testing/selftests/x86/protection_keys.c +8 -5
@@ -1163,12 +1163,15 @@ void test_pkey_alloc_exhaust(int *ptr, upkey_assert (i <NR_PKEYS *2 );/* -* There are 16 pkeys supported in hardware. One is taken -* up for the default (0) and another can be taken up by -* an execute-only mapping. Ensure that we can allocate -* at least 14 (16-2). +* There are 16 pkeys supported in hardware. Three are +* allocated by the time we get here: +* 1. The default key (0) +* 2. One possibly consumed by an execute-only mapping. +* 3. One allocated by the test code and passed in via +* 'pkey' to this function. +* Ensure that we can allocate at least another 13 (16-3). */ -pkey_assert (i >=NR_PKEYS -2 ); +pkey_assert (i >=NR_PKEYS -3 );for (i =0 ; i < nr_allocated_pkeys; i++) { err =sys_pkey_free (allocated_pkeys[i]);
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/x86-pkeys-selftests-factor-out-instruction-page.patch queue-4.14/x86-pkeys-selftests-fix-pointer-math.patch queue-4.14/x86-pkeys-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-pkeys-abi.patch queue-4.14/x86-pkeys-selftests-add-a-test-for-pkey-0.patch queue-4.14/x86-pkeys-selftests-stop-using-assert.patch queue-4.14/x86-pkeys-selftests-save-off-prot-for-allocations.patch queue-4.14/x86-pkeys-selftests-remove-dead-debugging-code-fix-dprint_in_signal.patch queue-4.14/x86-mpx-selftests-adjust-the-self-test-to-fresh-distros-that-export-the-mpx-abi.patch queue-4.14/x86-pkeys-selftests-add-prot_exec-test.patch queue-4.14/x86-pkeys-selftests-allow-faults-on-unknown-keys.patch queue-4.14/x86-pkeys-selftests-give-better-unexpected-fault-error-messages.patch queue-4.14/x86-pkeys-selftests-fix-pkey-exhaustion-test-off-by-one.patch