Kernel userspace access/execution prevention with hash translation
Status from this message: Applied to powerpc/next.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest22 patches 3 repliesApplied
- v6 posting 2/222 patches 25 repliesSuperseded
- v5 posting 2/223 patches 12 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 posting 1/2 | 23 patches | 3 replies | Applied | |
| v5 posting 1/2 | 26 patches | 22 replies | Superseded | |
| v4 | 41 patches | 3 replies | Superseded | |
| v3 | 41 patches | 0 replies | Superseded | |
| v2 | 28 patches | 1 reply | Superseded | |
| v1 RFC | 25 patches | 0 replies | Superseded |
Changes in v7 from the cover letter
* Address review comments
* Rename MMU FTR defines
Patches in v7 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/22 | powerpc: Add new macro to handle NESTED_IFCLRarch/ | +3 | 0 replies | |
| 2/22 | KVM: PPC: BOOK3S: PR: Ignore UAMOR SPRarch/ | +6 | 0 replies | |
| 3/22 | powerpc/book3s64/kuap/kuep: Add PPC_PKEY config on book3s64arch/ arch/ arch/ +4 more | +33 | 0 replies | |
| 4/22 | powerpc/book3s64/kuap/kuep: Move uamor setup to pkey initarch/ | +3 | 0 replies | |
| 5/22 | powerpc/book3s64/kuap: Move KUAP related function outside radixarch/ arch/ arch/ +1 more | +28 | 0 replies | |
| 6/22 | powerpc/book3s64/kuep: Move KUEP related function outside radixarch/ arch/ arch/ | +22 | 0 replies | |
| 7/22 | powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP and MMU_FTR_KUEParch/ arch/ arch/ | +25 | 0 replies | |
| 8/22 | powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translationarch/ arch/ arch/ +8 more | +46 | 0 replies | |
| 9/22 | powerpc/exec: Set thread.regs early during execarch/ arch/ | +13 | 0 replies | |
| 10/22 | powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on entry and exit from kernelarch/ arch/ arch/ +3 more | +225 | 0 replies | |
| 11/22 | powerpc/book3s64/pkeys: Inherit correctly on fork.arch/ | +10 | 0 replies | |
| 12/22 | powerpc/book3s64/pkeys: Reset userspace AMR correctly on execarch/ arch/ arch/ | +9 | 0 replies | |
| 13/22 | powerpc/ptrace-view: Use pt_regs values instead of thread_struct based one.arch/ | +4 | 0 replies | |
| 14/22 | powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.arch/ arch/ arch/ +2 more | +31 | 0 replies | |
| 15/22 | powerpc/book3s64/kuap: Restrict access to userspace based on userspace AMRarch/ | +9 | 0 replies | |
| 16/22 | powerpc/book3s64/kuap: Improve error reporting with KUAParch/ arch/ arch/ +2 more | +29 | 0 replies | |
| 17/22 | powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash translation.arch/ | +4 | 0 replies | |
| 18/22 | powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash translation.arch/ | +1 | 0 replies | |
| 19/22 | powerpc/book3s64/hash/kuap: Enable kuap on hasharch/ | +6 | 0 replies | |
| 20/22 | powerpc/book3s64/hash/kuep: Enable KUEP on hasharch/ | +6 | 0 replies | |
| 21/22 | powerpc/book3s64/hash/kup: Don't hardcode kup keyarch/ arch/ arch/ | +50 | 0 replies | |
| 21/22 | powerpc/book3s64/kup: Check max key supported before enabling kuparch/ arch/ arch/ | +26 | 1 reply | |
| 22/22 | powerpc/book3s64/pkeys: Optimize KUAP and KUEP feature disabled casearch/ arch/ arch/ | +67 | 0 replies |
Reviews trailers per patch
10 of 23 patches have a Reviewed-by or Acked-by.
| Patch | Sandipan Das |
|---|---|
| 1/22 | |
| 2/22 | |
| 3/22 | |
| 4/22 | |
| 5/22 | |
| 6/22 | |
| 7/22 | |
| 8/22 | R-b |
| 9/22 | |
| 10/22 | R-b |
| 11/22 | R-b |
| 12/22 | R-b |
| 13/22 | |
| 14/22 | R-b |
| 15/22 | R-b |
| 16/22 | |
| 17/22 | R-b |
| 18/22 | R-b |
| 19/22 | R-b |
| 20/22 | R-b |
| 21/22 | |
| 21/22 | |
| 22/22 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v7 00/22] Kernel userspace access/execution prevention with hash translation
This patch series implements KUAP and KUEP with hash translation mode using memory keys. The kernel now uses memory protection key 3 to control access to the kernel. Kernel page table entries are now configured with key 3. Access to locations configured with any other key value is denied when in kernel mode (MSR_PR=0). This includes userspace which is by default configured with key 0.
null-syscall benchmark results:
With smap/smep disabled:
Without patch:
845.29 ns 2451.44 cycles With patch series: 858.38 ns 2489.30 cycles
With smap/smep enabled:
Without patch:
NA
With patch series:
1021.51 ns 2962.44 cycles
Changes from v6:
* Address review comments
* Rename MMU FTR defines
Changes from v5:
* Rework the patch based on suggestion from Michael to avoid the usage of CONFIG_PPC_PKEY on BOOKE platforms.
Changes from v4:
* Repost with other pkey related changes split out as a separate series.
* Improve null-syscall benchmark by optimizing SPRN save and restore.
Changes from v3:
* Fix build error reported by kernel test robot <[email protected]>
Changes from v2:
* Rebase to the latest kernel.
* Fixed a bug with disabling KUEP/KUAP on kernel command line
* Added a patch to make kup key dynamic.
Changes from V1:
* Rebased on latest kernel
Aneesh Kumar K.V (22):
powerpc: Add new macro to handle NESTED_IFCLR
KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR powerpc/book3s64/kuap/kuep: Add PPC_PKEY config on book3s64 powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init powerpc/book3s64/kuap: Move KUAP related function outside radix powerpc/book3s64/kuep: Move KUEP related function outside radix powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP and MMU_FTR_KUEP powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash
translation
powerpc/exec: Set thread.regs early during exec powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on
entry and exit from kernel
powerpc/book3s64/pkeys: Inherit correctly on fork. powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec powerpc/ptrace-view: Use pt_regs values instead of thread_struct based
one.
powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode. powerpc/book3s64/kuap: Restrict access to userspace based on userspace
AMR
powerpc/book3s64/kuap: Improve error reporting with KUAP powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash
translation.
powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash
translation.
powerpc/book3s64/hash/kuap: Enable kuap on hash powerpc/book3s64/hash/kuep: Enable KUEP on hash powerpc/book3s64/hash/kup: Don't hardcode kup key powerpc/book3s64/pkeys: Optimize KUAP and KUEP feature disabled case
arch/powerpc/include/asm/book3s/32/kup.h | 4 +- .../powerpc/include/asm/book3s/64/hash-pkey.h | 10 +- arch/powerpc/include/asm/book3s/64/hash.h | 2 +- .../powerpc/include/asm/book3s/64/kup-radix.h | 203 -------- arch/powerpc/include/asm/book3s/64/kup.h | 442 ++++++++++++++++++ arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/book3s/64/mmu.h | 2 +- arch/powerpc/include/asm/book3s/64/pkeys.h | 3 + arch/powerpc/include/asm/feature-fixups.h | 3 + arch/powerpc/include/asm/kup.h | 8 +- arch/powerpc/include/asm/mmu.h | 24 +- arch/powerpc/include/asm/mmu_context.h | 2 +- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 4 +- arch/powerpc/include/asm/processor.h | 4 - arch/powerpc/include/asm/ptrace.h | 12 +- arch/powerpc/include/asm/thread_info.h | 2 - arch/powerpc/kernel/asm-offsets.c | 5 + arch/powerpc/kernel/entry_64.S | 6 +- arch/powerpc/kernel/exceptions-64s.S | 4 +- arch/powerpc/kernel/process.c | 47 +- arch/powerpc/kernel/ptrace/ptrace-view.c | 7 +- arch/powerpc/kernel/syscall_64.c | 38 +- arch/powerpc/kernel/traps.c | 6 - arch/powerpc/kvm/book3s_emulate.c | 6 + arch/powerpc/mm/book3s64/Makefile | 2 +- arch/powerpc/mm/book3s64/hash_4k.c | 2 +- arch/powerpc/mm/book3s64/hash_64k.c | 4 +- arch/powerpc/mm/book3s64/hash_hugepage.c | 2 +- arch/powerpc/mm/book3s64/hash_hugetlbpage.c | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 2 +- arch/powerpc/mm/book3s64/hash_utils.c | 10 +- arch/powerpc/mm/book3s64/pkeys.c | 177 ++++--- arch/powerpc/mm/book3s64/radix_pgtable.c | 45 +- arch/powerpc/mm/fault.c | 2 +- arch/powerpc/platforms/Kconfig.cputype | 5 + 35 files changed, 709 insertions(+), 389 deletions(-) delete mode 100644 arch/powerpc/include/asm/book3s/64/kup-radix.h create mode 100644 arch/powerpc/include/asm/book3s/64/kup.h
Signature · 1 line
2.28.0