You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by di...@apache.org on 2020/06/10 22:18:57 UTC

[incubator-teaclave-sgx-sdk] branch master updated: Add checks for untrusted memory allocation result.

This is an automated email from the ASF dual-hosted git repository.

dingyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git


The following commit(s) were added to refs/heads/master by this push:
     new 4941d62  Add checks for untrusted memory allocation result.
     new fdc2ea9  Merge pull request #247 from m4sterchain/dev
4941d62 is described below

commit 4941d62b3d3134611a5539512b73ea40bb94b64f
Author: Zhaofeng Chen <zf...@apache.com>
AuthorDate: Wed Jun 10 15:11:13 2020 -0700

    Add checks for untrusted memory allocation result.
---
 sgx_libc/src/linux/x86_64/ocall.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sgx_libc/src/linux/x86_64/ocall.rs b/sgx_libc/src/linux/x86_64/ocall.rs
index 973d836..efacabc 100644
--- a/sgx_libc/src/linux/x86_64/ocall.rs
+++ b/sgx_libc/src/linux/x86_64/ocall.rs
@@ -476,6 +476,12 @@ pub unsafe fn malloc(size: size_t) -> *mut c_void {
         set_errno(ESGX);
         result = ptr::null_mut();
     }
+
+    if sgx_is_outside_enclave(result, size) == 0 {
+        set_errno(ESGX);
+        result = ptr::null_mut();
+    }
+
     result
 }
 
@@ -508,6 +514,12 @@ pub unsafe fn mmap(start: *mut c_void,
         set_errno(ESGX);
         result = -1 as isize as *mut c_void;
     }
+
+    if sgx_is_outside_enclave(result, length) == 0 {
+        set_errno(ESGX);
+        result = -1 as isize as *mut c_void;
+    }
+
     result
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org