Skip to content

Add dynamic DEXCR support

Benjamin Gray linuxppc-dev 1 version Applied

Status from this message: Applied to powerpc/next.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 2 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/9selftests/powerpc/dexcr: Add -no-pie to hashchk teststools/testing/selftests/powerpc/dexcr/Makefile+1 -11 reply
2/9powerpc/dexcr: Track the DEXCR per-processarch/powerpc/include/asm/processor.h arch/powerpc/kernel/process.c arch/powerpc/kernel/ptrace/ptrace-view.c+12 -60 replies
3/9powerpc/dexcr: Reset DEXCR value across execarch/powerpc/include/asm/processor.h arch/powerpc/kernel/Makefile arch/powerpc/kernel/dexcr.c +1 more+30 -10 replies
4/9powerpc/dexcr: Add DEXCR prctl interfacearch/powerpc/include/asm/processor.h arch/powerpc/kernel/dexcr.c include/uapi/linux/prctl.h +1 more+141 -00 replies
5/9selftests/powerpc/dexcr: Add DEXCR prctl interface testtools/testing/selftests/powerpc/dexcr/.gitignore tools/testing/selftests/powerpc/dexcr/Makefile tools/testing/selftests/powerpc/dexcr/dexcr.c +2 more+267 -10 replies
6/9selftests/powerpc/dexcr: Attempt to enable NPHIE in hashchk selftesttools/testing/selftests/powerpc/dexcr/hashchk_test.c+7 -10 replies
7/9selftests/powerpc/dexcr: Add DEXCR config details to lsdexcrtools/testing/selftests/powerpc/dexcr/lsdexcr.c+111 -20 replies
8/9selftests/powerpc/dexcr: Add chdexcr utilitytools/testing/selftests/powerpc/dexcr/.gitignore tools/testing/selftests/powerpc/dexcr/Makefile tools/testing/selftests/powerpc/dexcr/chdexcr.c +2 more+185 -1050 replies
9/9Documentation: Document PowerPC kernel dynamic DEXCR interfaceDocumentation/arch/powerpc/dexcr.rst+139 -20 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchAndrew Donnellan
1/9R-b T-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/9] Add dynamic DEXCR support

Adds support for a process to change its DEXCR value. The implementation is somewhat conservative; SBHE (speculative branch hint enable) is not exposed as an editable aspect because its effects can bleed over to other threads.

As explained in the third patch, this series changes the reset/inherit behaviour on exec. Previously there was a bitmask that tracked which aspects to copy from the current state vs resetting to a fixed default. This allows unprivileged processes to disable ROP protection for setuid binaries though, and is generally a weird interface to work with. The actual intent (and new implementation) tracks the exec value as an independent value that doesn't use the parent's DEXCR at all. The parent can control this reset value separately to its own DEXCR value.

The other interesting part is the prctl interface. I've made the _SET, _CLEAR, _SET_ONEXEC, and _CLEAR_ONEXEC controls each a separate flag. This makes it easier to re-use with the getter prctl, as opposed to making set/clear a boolean value with a separate flag for if it's 'on-exec'. With separate flags you can return both the current and on-exec state in the getter in the same way you'd prepare it for the setter.

There are still more features that can be added. A global switch to disable ROP protection could be useful as an option to prevent performance degradation. Also a prctl to randomise the hash key could be useful for when userspace knows a fork is not going to run any parent hashes. These features could be added in a future series (or the next version of this one :) ) though.

Benjamin Gray (9):
selftests/powerpc/dexcr: Add -no-pie to hashchk tests powerpc/dexcr: Track the DEXCR per-process
powerpc/dexcr: Reset DEXCR value across exec powerpc/dexcr: Add DEXCR prctl interface selftests/powerpc/dexcr: Add DEXCR prctl interface test selftests/powerpc/dexcr: Attempt to enable NPHIE in hashchk selftest selftests/powerpc/dexcr: Add DEXCR config details to lsdexcr selftests/powerpc/dexcr: Add chdexcr utility
Documentation: Document PowerPC kernel dynamic DEXCR interface

 Documentation/arch/powerpc/dexcr.rst          | 141 +++++++++++-
 arch/powerpc/include/asm/processor.h          |  13 +-
 arch/powerpc/kernel/Makefile                  |   1 +
 arch/powerpc/kernel/dexcr.c                   | 120 ++++++++++
 arch/powerpc/kernel/process.c                 |  17 ++
 arch/powerpc/kernel/ptrace/ptrace-view.c      |   7 +-
 include/uapi/linux/prctl.h                    |  16 ++
 kernel/sys.c                                  |  16 ++
 .../selftests/powerpc/dexcr/.gitignore        |   2 +
 .../testing/selftests/powerpc/dexcr/Makefile  |   8 +-
 .../testing/selftests/powerpc/dexcr/chdexcr.c | 110 +++++++++
 tools/testing/selftests/powerpc/dexcr/dexcr.c |  40 ++++
 tools/testing/selftests/powerpc/dexcr/dexcr.h |  57 +++++
 .../selftests/powerpc/dexcr/dexcr_test.c      | 213 ++++++++++++++++++
 .../selftests/powerpc/dexcr/hashchk_test.c    |   8 +-
 .../testing/selftests/powerpc/dexcr/lsdexcr.c | 103 ++++++---
 16 files changed, 823 insertions(+), 49 deletions(-)
 create mode 100644 arch/powerpc/kernel/dexcr.c
 create mode 100644 tools/testing/selftests/powerpc/dexcr/chdexcr.c
 create mode 100644 tools/testing/selftests/powerpc/dexcr/dexcr_test.c

--
2.44.0