public inbox for linux-sgx@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/sgx: Return VM_FAULT_SIGBUS for EPC exhaustion
@ 2023-10-20  2:53 Haitao Huang
  2023-10-23 23:30 ` Jarkko Sakkinen
  2023-10-25 14:31 ` Dave Hansen
  0 siblings, 2 replies; 9+ messages in thread
From: Haitao Huang @ 2023-10-20  2:53 UTC (permalink / raw)
  To: jarkko, dave.hansen, linux-sgx, x86
  Cc: reinette.chatre, kai.huang, Haitao Huang, stable

In the EAUG on page fault path, VM_FAULT_OOM is returned when the
Enclave Page Cache (EPC) runs out. This may trigger unneeded OOM kill
that will not free any EPCs. Return VM_FAULT_SIGBUS instead.

Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave")
Cc: stable@vger.kernel.org # v6.0+
Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
---
 arch/x86/kernel/cpu/sgx/encl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index 279148e72459..d13b7e4ad0f5 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -322,7 +322,7 @@ struct sgx_encl_page *sgx_encl_load_page(struct sgx_encl *encl,
  * ENCLS[EAUG] instruction.
  *
  * Returns: Appropriate vm_fault_t: VM_FAULT_NOPAGE when PTE was installed
- * successfully, VM_FAULT_SIGBUS or VM_FAULT_OOM as error otherwise.
+ * successfully, VM_FAULT_SIGBUS as error otherwise.
  */
 static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
 				     struct sgx_encl *encl, unsigned long addr)
@@ -348,7 +348,7 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
 	secinfo_flags = SGX_SECINFO_R | SGX_SECINFO_W | SGX_SECINFO_X;
 	encl_page = sgx_encl_page_alloc(encl, addr - encl->base, secinfo_flags);
 	if (IS_ERR(encl_page))
-		return VM_FAULT_OOM;
+		return VM_FAULT_SIGBUS;
 
 	mutex_lock(&encl->lock);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-28  8:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20  2:53 [PATCH] x86/sgx: Return VM_FAULT_SIGBUS for EPC exhaustion Haitao Huang
2023-10-23 23:30 ` Jarkko Sakkinen
2023-10-25 14:31 ` Dave Hansen
2023-10-25 23:58   ` Huang, Kai
2023-10-26 16:01     ` Reinette Chatre
2023-10-26 16:34       ` Haitao Huang
2023-10-26 21:16         ` Huang, Kai
2023-10-28  8:24           ` Ingo Molnar
2023-10-26 21:10       ` Huang, Kai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox