Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable remote attestation by librats in SGX mode #1445

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

zeuson0
Copy link
Contributor

@zeuson0 zeuson0 commented Sep 1, 2022

No description provided.

@@ -0,0 +1,59 @@
/* Copyright (c) 2022 Intel Corporation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had better add an extra line like other files:

/*
 * Copyright (c) 2022 Intel Corporation
 * Copyright (c) 2020-2021 Alibaba Cloud

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/* Copyright (c) 2022 Intel Corporation
* Copyright (c) 2020-2021 Alibaba Cloud
*
* SPDX-License-Identifier: Apache-2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -56,8 +56,7 @@ typedef int (*os_print_function_t)(const char *message);
void
os_set_print_function(os_print_function_t pf);

char *
strcpy(char *dest, const char *src);
#define strcpy(dst, src) strncpy(dst, src, strlen(src))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether it needs to change code here? There are compilation warnings:

core/shared/platform/linux-sgx/sgx_file.c: In functionrealpath’:
core/shared/platform/linux-sgx/platform_internal.h:59:26: warning: ‘strncpyoutput truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
   59 | #define strcpy(dst, src) strncpy(dst, src, strlen(src))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because librats and wamr have the same function named strcpy on SGX, now I have recover it in wamr and modify the Implementation of it in librats.


if (WAMR_BUILD_LIB_RATS EQUAL 1)
execute_process(
COMMAND bash -c "sed -i -E 's/^\\/\\/ #define LIB_RATS/#define LIB_RATS/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Enclave/Enclave.edl"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searching \n// #define LIB_RATS might cause error if the code is changed, how about:

#define LIB_RATS 0

And replace between \n#define LIB_RATS 0 and \n#define LIB_RATS 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,80 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please write a README.md under this folder to introduce the sample?

Another issue is that do I need to install other packages? I got compilation error while building this sample:

samples/sgx-ra/build/_deps/librats-src/tee/sgx/untrust/sgx_ecdsa_ocall.c:14:10: fatal error: sgx_dcap_quoteverify.h: No such file or directory
   14 | #include <sgx_dcap_quoteverify.h>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

README.md Outdated
@@ -159,6 +159,7 @@ The WAMR [samples](./samples) integrate the iwasm VM core, application manager a
- **[wasm-c-api](./samples/wasm-c-api/README.md)**: Demonstrating how to run some samples from [wasm-c-api proposal](https://github.com/WebAssembly/wasm-c-api) and showing the supported API's.
- **[socket-api](./samples/socket-api/README.md)**: Demonstrating how to run wasm tcp server and tcp client applications, and how they communicate with each other.
- **[workload](./samples/workload/README.md)**: Demonstrating how to build and run some complex workloads, e.g. tensorflow-lite, XNNPACK, wasm-av1, meshoptimizer and bwa.
- **[sgx-ra](./samples/sgx-ra/README.md)**: Demonstrates how to excute Remote Attestation on SGX with [librats](https://github.com/inclavare-containers/librats), which enables mutual attestation with other runtimes or other entities that support librats to ensure that each is running within the TEE.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be execute but not excute.
And not sure whether Demonstrating or Demonstrates is better, but the other samples use Demonstrating, could this sample also aligns with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"sgx-ra" sample introduction
==============

This sample demonstrates how to excute Remote Attestation on SGX with [librats](https://github.com/inclavare-containers/librats) and run it with iwasm. It can only build on [SGX supported processors](https://www.intel.com/content/www/us/en/support/articles/000028173/processors.html), please check it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/* clang-format off */
#define REG_NATIVE_FUNC(func_name, signature) \
{ #func_name, func_name##_wrapper, signature, NULL }
/* clang-format off */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* clang-format off */
/* clang-format on */

@wenyongh wenyongh merged commit 729c4ae into bytecodealliance:main Sep 6, 2022
@wenyongh wenyongh mentioned this pull request Nov 2, 2022
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Add library librats, update SGX build scripts, add sample and update document.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants