!172 add codegen compile marco and use memset instead of explicit_bzero
From: @zhengxiaoxiaoGitee Reviewed-by: @houmingyong Signed-off-by: @houmingyong
This commit is contained in:
commit
5b664a53c1
29
backport-add-codegen-compile-marco.patch
Normal file
29
backport-add-codegen-compile-marco.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 088eca103708b2d54c4fe46f6dc2da7a21f4f0da Mon Sep 17 00:00:00 2001
|
||||
From: houmingyong <houmingyong@huawei.com>
|
||||
Date: Thu, 7 Dec 2023 14:08:36 +0800
|
||||
Subject: [PATCH] add codegen compile marco
|
||||
|
||||
Reference:https://gitee.com/openeuler/secGear/commit/088eca103708b2d54c4fe46f6dc2da7a21f4f0da
|
||||
Conflict:Deleted the PL part from the patch.
|
||||
---
|
||||
CMakeLists.txt | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 25e6381..8a6f22b 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -74,7 +74,10 @@ if(${ENCLAVE} STREQUAL "SGX")
|
||||
set(CC_SGX ON)
|
||||
endif()
|
||||
|
||||
-add_subdirectory(tools/codegener)
|
||||
+option(CODEGEN "default off" ON)
|
||||
+if(CODEGEN)
|
||||
+ add_subdirectory(tools/codegener)
|
||||
+endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(component)
|
||||
--
|
||||
2.33.0
|
||||
58
backport-memset-no-optimize.patch
Normal file
58
backport-memset-no-optimize.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From c15207d44281663b32ad4a8ede998dd4c7bda6fd Mon Sep 17 00:00:00 2001
|
||||
From: zhengxiaoxiao <zhengxiaoxiao2@huawei.com>
|
||||
Date: Thu, 14 Mar 2024 20:20:34 +0800
|
||||
Subject: [PATCH] memset no optimize
|
||||
|
||||
Reference:https://gitee.com/openeuler/secGear/commit/c0997efc6a69d465b286347285cb1508a9d9c24b
|
||||
Conflict:NA
|
||||
---
|
||||
src/enclave_src/gp/itrustee/itrustee_seal_data.c | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/enclave_src/gp/itrustee/itrustee_seal_data.c b/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
index b074d6f..e23cb1e 100644
|
||||
--- a/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
+++ b/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
@@ -15,6 +15,13 @@
|
||||
#include "tee_crypto_api.h"
|
||||
#include "dataseal_internal.h"
|
||||
#include "tee_trusted_storage.h"
|
||||
+
|
||||
+#define CC_OPTIMIZE_OFF __attribute__((optimize("O0")))
|
||||
+CC_OPTIMIZE_OFF static void *memset_no_optimize(void *ptr, int value, size_t num)
|
||||
+{
|
||||
+ memset(ptr, 0, num);
|
||||
+}
|
||||
+
|
||||
uint32_t get_sealed_data_size_ex(uint32_t seal_data_len, uint32_t aad_len)
|
||||
{
|
||||
if (UINT32_MAX - aad_len <= seal_data_len) {
|
||||
@@ -139,13 +146,13 @@ TEE_Result itrustee_seal_data(uint8_t *seal_data, uint32_t seal_data_len, void *
|
||||
result = data_copy(tmp_sealed_data, salt, nonce, mac_data, mac_data_len);
|
||||
|
||||
error0:
|
||||
- memset(nonce, 0, SEAL_DATA_NONCE_LEN);
|
||||
+ memset_no_optimize(nonce, 0, SEAL_DATA_NONCE_LEN);
|
||||
TEE_Free(nonce);
|
||||
error1:
|
||||
- memset(salt, 0, SEAL_KEY_SALT_LEN);
|
||||
+ memset_no_optimize(salt, 0, SEAL_KEY_SALT_LEN);
|
||||
TEE_Free(salt);
|
||||
error2:
|
||||
- memset(key_buf, 0, SEAL_KEY_LEN);
|
||||
+ memset_no_optimize(key_buf, 0, SEAL_KEY_LEN);
|
||||
TEE_Free(key_buf);
|
||||
return result;
|
||||
}
|
||||
@@ -249,7 +256,7 @@ TEE_Result itrustee_unseal_data(void *sealed_data, uint8_t *decrypted_data, uint
|
||||
}
|
||||
|
||||
done:
|
||||
- memset(key_buf, 0, SEAL_KEY_LEN);
|
||||
+ memset_no_optimize(key_buf, 0, SEAL_KEY_LEN);
|
||||
TEE_Free(key_buf);
|
||||
return result;
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
67
backport-use-memset-instead-of-explicit_bzero.patch
Normal file
67
backport-use-memset-instead-of-explicit_bzero.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From 248f56df792c14421074a6049ac668464070a574 Mon Sep 17 00:00:00 2001
|
||||
From: zhengxiaoxiao <zhengxiaoxiao2@huawei.com>
|
||||
Date: Tue, 12 Mar 2024 16:53:22 +0800
|
||||
Subject: [PATCH] use memset instead of explicit_bzero
|
||||
|
||||
Reference: https://gitee.com/openeuler/secGear/commit/248f56df792c14421074a6049ac668464070a574
|
||||
Conflict: NA
|
||||
---
|
||||
src/enclave_src/gp/itrustee/itrustee_seal_data.c | 8 ++++----
|
||||
src/host_src/enclave.c | 4 ++--
|
||||
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/enclave_src/gp/itrustee/itrustee_seal_data.c b/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
index cae1734..b074d6f 100644
|
||||
--- a/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
+++ b/src/enclave_src/gp/itrustee/itrustee_seal_data.c
|
||||
@@ -139,13 +139,13 @@ TEE_Result itrustee_seal_data(uint8_t *seal_data, uint32_t seal_data_len, void *
|
||||
result = data_copy(tmp_sealed_data, salt, nonce, mac_data, mac_data_len);
|
||||
|
||||
error0:
|
||||
- explicit_bzero(nonce, SEAL_DATA_NONCE_LEN);
|
||||
+ memset(nonce, 0, SEAL_DATA_NONCE_LEN);
|
||||
TEE_Free(nonce);
|
||||
error1:
|
||||
- explicit_bzero(salt, SEAL_KEY_SALT_LEN);
|
||||
+ memset(salt, 0, SEAL_KEY_SALT_LEN);
|
||||
TEE_Free(salt);
|
||||
error2:
|
||||
- explicit_bzero(key_buf, SEAL_KEY_LEN);
|
||||
+ memset(key_buf, 0, SEAL_KEY_LEN);
|
||||
TEE_Free(key_buf);
|
||||
return result;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ TEE_Result itrustee_unseal_data(void *sealed_data, uint8_t *decrypted_data, uint
|
||||
}
|
||||
|
||||
done:
|
||||
- explicit_bzero(key_buf, SEAL_KEY_LEN);
|
||||
+ memset(key_buf, 0, SEAL_KEY_LEN);
|
||||
TEE_Free(key_buf);
|
||||
return result;
|
||||
}
|
||||
diff --git a/src/host_src/enclave.c b/src/host_src/enclave.c
|
||||
index d8b7d35..f13feec 100644
|
||||
--- a/src/host_src/enclave.c
|
||||
+++ b/src/host_src/enclave.c
|
||||
@@ -70,7 +70,7 @@ static void error_handle(cc_enclave_t *enclave, void *handle, p_tee_registered r
|
||||
|
||||
if (enclave) {
|
||||
pthread_rwlock_destroy(&enclave->rwlock);
|
||||
- explicit_bzero(enclave, sizeof(cc_enclave_t));
|
||||
+ memset(enclave, 0, sizeof(cc_enclave_t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ cc_enclave_result_t cc_enclave_destroy(cc_enclave_t *context)
|
||||
}
|
||||
pthread_rwlock_unlock(&context->rwlock);
|
||||
pthread_rwlock_destroy(&context->rwlock);
|
||||
- explicit_bzero(context, sizeof(cc_enclave_t));
|
||||
+ memset(context, 0, sizeof(cc_enclave_t));
|
||||
|
||||
return CC_SUCCESS;
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: secGear
|
||||
Version: 0.1.0
|
||||
Release: 45
|
||||
Release: 46
|
||||
Summary: secGear is an SDK to develop confidential computing apps based on hardware enclave features
|
||||
|
||||
|
||||
@ -80,6 +80,9 @@ Patch67: 0068-bugfix-when-input-empty-hash.patch
|
||||
Patch68: 0069-adapt-sign-tool-to-pass-API_LEVEL.patch
|
||||
Patch69: 0070-sign-tool-add-invalid-param-verify.patch
|
||||
Patch70: 0071-adapt-report-with-request-key.patch
|
||||
Patch71: backport-add-codegen-compile-marco.patch
|
||||
Patch72: backport-use-memset-instead-of-explicit_bzero.patch
|
||||
Patch73: backport-memset-no-optimize.patch
|
||||
|
||||
BuildRequires: gcc python automake autoconf libtool
|
||||
BUildRequires: glibc glibc-devel cmake ocaml-dune rpm gcc-c++ openssl-libs openssl-devel
|
||||
@ -211,6 +214,9 @@ popd
|
||||
systemctl restart rsyslog
|
||||
|
||||
%changelog
|
||||
* Fri Mar 29 2024 zhengxiaoxiao <zhengxiaoxiao2@huawei.com> - 0.1.0-46
|
||||
- add codegen compile marco and use memset instead of explicit_bzero
|
||||
|
||||
* Mon Nov 27 2023 jinlun<jinlun@huawei.com> - 0.1.0-45
|
||||
- Keep the 22.03-LTS-SP3 branch of the secGear consistent with the 22.03-LTS-SP3 release
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user