-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(handle_t): redef handle_t as pointer
* Add a "HANDLE_TYPE_IS_PTR" compile flag that redefines handle_t as ptr (instead of int32). * Create a local copy of storage/ipc.c in trusty_mod directory to allow handle_t to be treated as an opaque object. * Create a local include dir with trusty_ipc.h for the actual handle_t is ptr redef. * Run port_create_destroy_harness and msg_buffer_harness with redefined handle_t on local ipc.c * Add handle is ptr jobs to CI Known issues/Needs investigation: The following issues need to be fixed but not blocking the PR since the infrastructure changes are quite big itself. * msg_buffer_harness.c fails in vac mode with handle_t as ptr. It seems to be failing at head (added to CI blacklist) so this PR doesn't make the situation worse.
- Loading branch information
1 parent
1179915
commit bd84d22
Showing
69 changed files
with
2,194 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
storage_ipc_indirect_handlers_unsat_test | ||
storage_ipc_msg_buffer_unsat_test | ||
gatekeeper_ipc_unsat_test | ||
# following tracked in https://github.com/seahorn/verifyTrusty/issues/18 | ||
storage_ipc_port_create_destroy_unsat_test | ||
# following tracked in https://github.com/seahorn/verifyTrusty/issues/19 | ||
port_send_msg_pf_unsat_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
storage_ipc_indirect_handlers_unsat_test | ||
storage_ipc_msg_buffer_unsat_test | ||
gatekeeper_ipc_unsat_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
include_directories(include) | ||
|
||
add_compile_definitions(CAN_RETURN_INVALID_IPC_HANDLE=1) | ||
if (HANDLE_TYPE_IS_PTR) | ||
set(IPC_SRC ${TRUSTY_MOD_ROOT}/trusty/user/app/storage/ipc.c) | ||
add_compile_definitions(HANDLE_TYPE_IS_PTR=1) | ||
else () | ||
set(IPC_SRC ${TRUSTY_ROOT}/trusty/user/app/storage/ipc.c) | ||
endif () | ||
|
||
add_subdirectory(lib) | ||
add_subdirectory(stubs) | ||
|
||
# The following jobs will be built | ||
add_subdirectory(jobs/ipc/indirect_handlers) | ||
add_subdirectory(jobs/ipc/msg_buffer) | ||
add_subdirectory(jobs/ipc/port_create_destroy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
add_subdirectory(user/base/lib/libc-trusty) | ||
add_subdirectory(user/base/lib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
set(EXTERNAL ${TRUSTY_ROOT}/trusty/user/base/lib/libc-trusty) | ||
add_library( | ||
sea_libc_trusty | ||
${EXTERNAL}/ipc.c | ||
) | ||
|
||
if (HANDLE_TYPE_IS_PTR) | ||
add_subdirectory(libc-trusty-ptr) | ||
else () | ||
add_subdirectory(libc-trusty) | ||
endif () | ||
add_compile_definitions(CAN_RETURN_INVALID_IPC_HANDLE=0) |
10 changes: 10 additions & 0 deletions
10
seahorn/trusty/user/base/lib/libc-trusty-ptr/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
target_sources(sea_libc_trusty PUBLIC | ||
sea_handle_table.c | ||
trusty_syscalls_impl.c | ||
) | ||
|
||
target_include_directories(sea_libc_trusty PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
sea_attach_bc(sea_libc_trusty) | ||
|
||
add_subdirectory(proof) |
11 changes: 11 additions & 0 deletions
11
seahorn/trusty/user/base/lib/libc-trusty-ptr/proof/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_subdirectory(port_create) | ||
add_subdirectory(port_close) | ||
add_subdirectory(port_connect) | ||
add_subdirectory(port_accept) | ||
add_subdirectory(port_get_msg) | ||
add_subdirectory(port_put_msg) | ||
add_subdirectory(port_read_msg) | ||
add_subdirectory(port_send_msg) | ||
add_subdirectory(port_wait) | ||
add_subdirectory(port_wait_any) | ||
add_subdirectory(port_set_cookie) |
5 changes: 5 additions & 0 deletions
5
seahorn/trusty/user/base/lib/libc-trusty-ptr/proof/port_accept/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
add_executable(port_accept_pf main.c) | ||
sea_link_libraries(port_accept_pf sea_libc_trusty.ir) | ||
|
||
sea_attach_bc(port_accept_pf) | ||
sea_add_unsat_test(port_accept_pf) |
53 changes: 53 additions & 0 deletions
53
seahorn/trusty/user/base/lib/libc-trusty-ptr/proof/port_accept/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "trusty_ipc.h" | ||
#include <seahorn/seahorn.h> | ||
|
||
/* Documentation from trusty API: | ||
accept() | ||
Accepts an incoming connection and gets a handle to a channel. | ||
long accept(uint32_t handle_id, uuid_t *peer_uuid); | ||
[in] handle_id: Handle representing the port to which a client has connected | ||
[out] peer_uuid: Pointer to a uuud_t structure to be filled with the UUID of | ||
the connecting client application. It will be set to all zeros if the | ||
connection originated from the non-secure world. | ||
[retval]: Handle to a channel (if non-negative) on which the server can exchange | ||
messages with the client (or an error code otherwise) | ||
*/ | ||
|
||
const char *HANDLE_PATH = "seahorn.com"; | ||
|
||
bool is_uuid_all_zeros(uuid_t *peer_uuid) { | ||
return peer_uuid->time_low == 0 && peer_uuid->time_mid == 0 && | ||
peer_uuid->time_hi_and_version == 0; | ||
} | ||
|
||
int main(void) { | ||
|
||
handle_t port; | ||
int rc; | ||
|
||
port = port_create(HANDLE_PATH, 1, 100, | ||
IPC_PORT_ALLOW_NS_CONNECT | IPC_PORT_ALLOW_TA_CONNECT); | ||
|
||
// -- got expected handle | ||
sassert(!port->secure); | ||
|
||
uuid_t peer_uuid; | ||
handle_t chan; | ||
chan = accept(port, &peer_uuid); | ||
assume(chan != INVALID_IPC_HANDLE); | ||
sassert(is_uuid_all_zeros(&peer_uuid)); | ||
|
||
rc = close(port); | ||
sassert(rc == 0); | ||
|
||
port = port_create(HANDLE_PATH, 1, 100, IPC_PORT_ALLOW_NS_CONNECT); | ||
|
||
// -- expected secure handle handle | ||
sassert(port->secure); | ||
|
||
chan = accept(port, &peer_uuid); | ||
assume(chan != INVALID_IPC_HANDLE); | ||
return 0; | ||
} |
Oops, something went wrong.