You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by rd...@apache.org on 2021/05/18 05:50:25 UTC

[incubator-teaclave-sgx-sdk] branch master updated: fix prctl ocall.(thread::set_name)

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

rduan 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 d1e2a90  fix prctl ocall.(thread::set_name)
d1e2a90 is described below

commit d1e2a909ee0a4e95437ba75149d12ab9d07fcfe1
Author: volcano <vo...@163.com>
AuthorDate: Tue May 18 13:49:17 2021 +0800

    fix prctl ocall.(thread::set_name)
---
 sgx_tstd/src/sys/thread.rs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sgx_tstd/src/sys/thread.rs b/sgx_tstd/src/sys/thread.rs
index 91d20ec..15f6a72 100644
--- a/sgx_tstd/src/sys/thread.rs
+++ b/sgx_tstd/src/sys/thread.rs
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License..
 
-use sgx_types::sgx_status_t;
+use sgx_types::{sgx_ocalloc, sgx_ocfree, sgx_status_t};
 use core::cmp;
 use core::mem;
 use core::ptr;
@@ -66,8 +66,14 @@ impl Thread {
         const PR_SET_NAME: libc::c_int = 15;
         // pthread wrapper only appeared in glibc 2.12, so we use syscall
         // directly.
+        let name = name.to_bytes_with_nul();
         unsafe {
-            libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0);
+            let ptr = sgx_ocalloc(name.len());
+            if !ptr.is_null() {
+                ptr::copy_nonoverlapping(name.as_ptr() as *const u8, ptr as *mut u8, name.len());
+                libc::prctl(PR_SET_NAME, ptr as libc::c_ulong, 0, 0, 0);
+                sgx_ocfree();
+            }
         }
     }
 

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