You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by yu...@apache.org on 2023/03/10 07:37:56 UTC
[incubator-teaclave-trustzone-sdk] branch GP-1.3.1 updated: Fix supp_plugin panic
This is an automated email from the ASF dual-hosted git repository.
yuanz pushed a commit to branch GP-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
The following commit(s) were added to refs/heads/GP-1.3.1 by this push:
new 8ef15ae Fix supp_plugin panic
8ef15ae is described below
commit 8ef15ae19fbb2ae6f1a2ea48dbc7074ef7fd3560
Author: Yuan Zhuang <de...@foxmail.com>
AuthorDate: Fri Mar 10 07:34:52 2023 +0000
Fix supp_plugin panic
- update `tee_invoke_supp_plugin` interface
- fix panic: the shared buffer cannot be sent as the plugin `inbuf`
---
examples/supp_plugin-rs/ta/src/main.rs | 3 ++-
optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs | 4 ++--
optee-utee/src/extension.rs | 12 ++++++------
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/examples/supp_plugin-rs/ta/src/main.rs b/examples/supp_plugin-rs/ta/src/main.rs
index 72363bd..2bd3775 100644
--- a/examples/supp_plugin-rs/ta/src/main.rs
+++ b/examples/supp_plugin-rs/ta/src/main.rs
@@ -50,6 +50,7 @@ fn destroy() {
fn invoke_command(cmd_id: u32, params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
let mut p0 = unsafe { params.0.as_memref().unwrap() };
+ let mut inbuf = p0.buffer().to_vec();
trace_println!("[+] TA received value {:?} then send to plugin", p0.buffer());
let uuid = Uuid::parse_str(PLUGIN_UUID).unwrap();
@@ -59,7 +60,7 @@ fn invoke_command(cmd_id: u32, params: &mut Parameters) -> Result<()> {
let outbuf = plugin.invoke(
PluginCommand::Print as u32,
PLUGIN_SUBCMD_NULL,
- p0.buffer()
+ &inbuf
).unwrap();
trace_println!("[+] TA received out value {:?} outlen {:?}", outbuf, outbuf.len());
diff --git a/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs b/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs
index 8f4ac24..e940143 100644
--- a/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs
+++ b/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs
@@ -32,8 +32,8 @@ extern "C" {
cmd: u32,
sub_cmd: u32,
buf: *mut c_char,
- len: u32,
- outlen: *mut u32,
+ len: usize,
+ outlen: *mut usize,
) -> TEE_Result;
}
diff --git a/optee-utee/src/extension.rs b/optee-utee/src/extension.rs
index 74f9a55..9263803 100644
--- a/optee-utee/src/extension.rs
+++ b/optee-utee/src/extension.rs
@@ -28,21 +28,21 @@ impl LoadablePlugin {
}
pub fn invoke(&mut self, command_id: u32, subcommand_id: u32, data: &[u8]) -> Result<Vec<u8>> {
let raw_uuid: Uuid = self.uuid;
- let mut outlen: u32 = 0;
+ let mut outlen: usize = 0;
match unsafe {
raw::tee_invoke_supp_plugin(
raw_uuid.as_raw_ptr(),
command_id as u32,
subcommand_id as u32,
data.as_ptr() as _,
- data.len() as u32,
- &mut outlen as *mut u32,
+ data.len(),
+ &mut outlen as *mut usize,
)
} {
raw::TEE_SUCCESS => {
- assert!(outlen <= (data.len() as u32));
- let mut outbuf = vec![0; outlen as usize];
- outbuf.copy_from_slice(&data[..(outlen as usize)]);
+ assert!(outlen <= (data.len()));
+ let mut outbuf = vec![0; outlen];
+ outbuf.copy_from_slice(&data[..outlen]);
Ok(outbuf)
},
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org