Skip to content

x86, pkeys: two protection keys bug fixes

Dave Hansen linux-mm lkml stable 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest13 patches 2 repliesIn review
  2. v39 patches 6 repliesSuperseded
  3. v29 patches 12 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v19 patches11 repliesSuperseded

Changes in v4 from the cover letter

* Reordered patches following Ingo's recommendations: Introduce failing selftests first, then the kernel code to fix the test failure.
* Increase verbosity and accuracy of do_not_expect_pk_fault() messages.
* Removed abort() use from tests. Crashing is not nice.
* Remove some dead debugging code, fixing dprint_in_signal.
* Fix deadlocks from using printf() and friends in signal handlers.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13x86/pkeys/selftests: Give better unexpected fault error messagestools/testing/selftests/x86/protection_keys.c+7 -60 replies
2/13x86/pkeys/selftests: Stop using assert()tools/testing/selftests/x86/protection_keys.c+8 -40 replies
3/13x86/pkeys/selftests: Remove dead debugging code, fix dprint_in_signaltools/testing/selftests/x86/protection_keys.c+0 -160 replies
4/13x86/pkeys/selftests: Avoid printf-in-signal deadlockstools/testing/selftests/x86/pkey-helpers.h+8 -120 replies
5/13x86/pkeys/selftests: Allow faults on unknown keystools/testing/selftests/x86/protection_keys.c+9 -10 replies
6/13x86/pkeys/selftests: Factor out "instruction page"tools/testing/selftests/x86/protection_keys.c+17 -40 replies
7/13x86/pkeys/selftests: Add PROT_EXEC testtools/testing/selftests/x86/protection_keys.c+44 -00 replies
8/13x86/pkeys/selftests: Fix pkey exhaustion test off-by-onetools/testing/selftests/x86/protection_keys.c+8 -50 replies
9/13x86/pkeys: Override pkey when moving away from PROT_EXECarch/x86/include/asm/pkeys.h arch/x86/mm/pkeys.c+22 -110 replies
10/13x86/pkeys/selftests: Fix pointer mathtools/testing/selftests/x86/protection_keys.c+7 -70 replies
11/13x86/pkeys/selftests: Save off 'prot' for allocationstools/testing/selftests/x86/protection_keys.c+9 -50 replies
12/13x86/pkeys/selftests: Add a test for pkey 0tools/testing/selftests/x86/protection_keys.c+30 -00 replies
13/13x86/pkeys: Do not special case protection key 0arch/x86/include/asm/mmu_context.h arch/x86/include/asm/pkeys.h+4 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH 00/13] [v4] x86, pkeys: two protection keys bug fixes

Hi x86 maintainers,

This set has been seen quite a few changes and additions since the last post. Details below.

Changes from v3:
* Reordered patches following Ingo's recommendations: Introduce failing selftests first, then the kernel code to fix the test failure.
* Increase verbosity and accuracy of do_not_expect_pk_fault() messages.
* Removed abort() use from tests. Crashing is not nice.
* Remove some dead debugging code, fixing dprint_in_signal.
* Fix deadlocks from using printf() and friends in signal handlers.

Changes from v2:
* Clarified commit message in patch 1/9 taking some feedback from Shuah.

Changes from v1:
* Added Fixes: and cc'd stable. No code changes.

--

This fixes two bugs, and adds selftests to make sure they stay fixed:

1. pkey 0 was not usable via mprotect_pkey() because it had never been explicitly allocated.
2. mprotect(PROT_EXEC) memory could sometimes be left with the implicit exec-only protection key assigned.

I already posted #1 previously. I'm including them both here because I don't think it's been picked up in case folks want to pull these all in a single bundle.

Dave Hansen (13):
x86/pkeys/selftests: give better unexpected fault error messages x86/pkeys/selftests: Stop using assert() x86/pkeys/selftests: remove dead debugging code, fix dprint_in_signal x86/pkeys/selftests: avoid printf-in-signal deadlocks x86/pkeys/selftests: Allow faults on unknown keys x86/pkeys/selftests: Factor out "instruction page" x86/pkeys/selftests: Add PROT_EXEC test x86/pkeys/selftests: Fix pkey exhaustion test off-by-one x86/pkeys: Override pkey when moving away from PROT_EXEC x86/pkeys/selftests: Fix pointer math x86/pkeys/selftests: Save off 'prot' for allocations x86/pkeys/selftests: Add a test for pkey 0
x86/pkeys: Do not special case protection key 0

 arch/x86/include/asm/mmu_context.h            |   2 +-
 arch/x86/include/asm/pkeys.h                  |  18 +-
 arch/x86/mm/pkeys.c                           |  21 +-
 tools/testing/selftests/x86/pkey-helpers.h    |  20 +-
 tools/testing/selftests/x86/protection_keys.c | 187 +++++++++++++-----
 5 files changed, 173 insertions(+), 75 deletions(-)
Cc Ram Pai <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Michael Ellermen <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>p
Cc Shuah Khan <[email protected]>
Cc Shakeel Butt <[email protected]>