diff mbox

[intel-sgx-kernel-dev,v3,6/7] intel_sgx: return correct errno for EINIT ioctl

Message ID 20161130142323.5324-7-jarkko.sakkinen@linux.intel.com
State New, archived
Headers show

Commit Message

Jarkko Sakkinen Nov. 30, 2016, 2:23 p.m. UTC
From: Sean Christopherson <sean.j.christopherson@intel.com>

Return -EBUSY in the case of interrupt storm and -EFAULT in other
cases instead of leaking SGX error codes.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 drivers/platform/x86/intel_sgx_ioctl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/platform/x86/intel_sgx_ioctl.c b/drivers/platform/x86/intel_sgx_ioctl.c
index 57c21aa..1d5a629 100644
--- a/drivers/platform/x86/intel_sgx_ioctl.c
+++ b/drivers/platform/x86/intel_sgx_ioctl.c
@@ -849,7 +849,10 @@  static int __sgx_encl_init(struct sgx_encl *encl, char *sigstruct,
 out:
 	if (ret) {
 		sgx_dbg(encl, "EINIT returned %d\n", ret);
-		ret = -EBUSY;
+		if (ret == SGX_UNMASKED_EVENT)
+			ret = -EBUSY;
+		else
+			ret = -EFAULT;
 	} else {
 		encl->flags |= SGX_ENCL_INITIALIZED;