x86/sgx: Add ptrace() support for the SGX driver
authorJarkko Sakkinen <jarkko@kernel.org>
Thu, 12 Nov 2020 22:01:33 +0000 (00:01 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 18 Nov 2020 17:04:11 +0000 (18:04 +0100)
commit947c6e11fa4310b31c10016ae9816cdca3f1694e
treeb29f0013dff7deaa30df6c5a254b4503eb633a22
parent1728ab54b4be94aed89276eeb8e750a345659765
x86/sgx: Add ptrace() support for the SGX driver

Enclave memory is normally inaccessible from outside the enclave. This
makes enclaves hard to debug. However, enclaves can be put in a debug
mode when they are being built. In that mode, enclave data *can* be read
and/or written by using the ENCLS[EDBGRD] and ENCLS[EDBGWR] functions.

This is obviously only for debugging and destroys all the protections
present with normal enclaves. But, enclaves know their own debug status
and can adjust their behavior appropriately.

Add a vm_ops->access() implementation which can be used to read and write
memory inside debug enclaves.  This is typically used via ptrace() APIs.

 [ bp: Massage. ]

Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Jethro Beekman <jethro@fortanix.com>
Link: https://lkml.kernel.org/r/20201112220135.165028-23-jarkko@kernel.org
arch/x86/kernel/cpu/sgx/encl.c