From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Gray <bgray@linux.ibm.com>
Subject: [PATCH v1 0/9] Add dynamic DEXCR support
Date: Wed, 17 Apr 2024 21:23:16 +1000 [thread overview]
Message-ID: <20240417112325.728010-1-bgray@linux.ibm.com> (raw)
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
next reply other threads:[~2024-04-17 11:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 11:23 Benjamin Gray [this message]
2024-04-17 11:23 ` [PATCH v1 1/9] selftests/powerpc/dexcr: Add -no-pie to hashchk tests Benjamin Gray
2024-05-07 7:44 ` Andrew Donnellan
2024-04-17 11:23 ` [PATCH v1 2/9] powerpc/dexcr: Track the DEXCR per-process Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 3/9] powerpc/dexcr: Reset DEXCR value across exec Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 4/9] powerpc/dexcr: Add DEXCR prctl interface Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 5/9] selftests/powerpc/dexcr: Add DEXCR prctl interface test Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 6/9] selftests/powerpc/dexcr: Attempt to enable NPHIE in hashchk selftest Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 7/9] selftests/powerpc/dexcr: Add DEXCR config details to lsdexcr Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 8/9] selftests/powerpc/dexcr: Add chdexcr utility Benjamin Gray
2024-04-17 11:23 ` [PATCH v1 9/9] Documentation: Document PowerPC kernel dynamic DEXCR interface Benjamin Gray
2024-05-08 13:39 ` [PATCH v1 0/9] Add dynamic DEXCR support Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417112325.728010-1-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).