[GIT PULL] x86/sgx for v5.19

From: Dave Hansen
Date: Mon May 23 2022 - 13:45:50 EST


Hi Linus,

It's my first pull request, signing tags and all that jazz. I hope I didn't
botch anything too badly. Here we go:

Please pull a set of x86/sgx patches to fix crashes under SGX memory pressure.

---

The following changes since commit 42226c989789d8da4af1de0c31070c96726d990c:

Linux 5.18-rc7 (2022-05-15 18:08:58 -0700)

are available in the Git repository at:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git tags/x86_sgx_for_v5.19_rc1

for you to fetch changes up to e3a3bbe3e99de73043a1d32d36cf4d211dc58c7e:

x86/sgx: Ensure no data in PCMD page after truncate (2022-05-16 15:17:57 -0700)

----------------------------------------------------------------
A set of patches to prevent crashes in SGX enclaves under heavy memory
pressure:

SGX uses normal RAM allocated from special shmem files as backing storage
when it runs out of SGX memory (EPC). The code was overly aggressive when
freeing shmem pages and was inadvertently freeing perfectly good data.
This resulted in failures in the SGX instructions used to swap data back
into SGX memory.

This turned out to be really hard to trigger in mainline. It was
originally encountered testing the out-of-tree "SGX2" patches, but later
reproduced on mainline.

Fix the data loss by being more careful about truncating pages out of
the backing storage and more judiciously setting pages dirty.

----------------------------------------------------------------
Reinette Chatre (5):
x86/sgx: Disconnect backing page references from dirty status
x86/sgx: Mark PCMD page as dirty when modifying contents
x86/sgx: Obtain backing storage page with enclave mutex held
x86/sgx: Fix race between reclaimer and page fault handler
x86/sgx: Ensure no data in PCMD page after truncate

arch/x86/kernel/cpu/sgx/encl.c | 113 +++++++++++++++++++++++++++++++++++++----
arch/x86/kernel/cpu/sgx/encl.h | 2 +-
arch/x86/kernel/cpu/sgx/main.c | 13 +++--
3 files changed, 114 insertions(+), 14 deletions(-)