-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When unexpected errors occur in the secure storage tests (regression_6xxx) some persistent objects might be left over, causing errors in further tests which expect to start from a clean state. This situation cannot be addressed fully by error handling in xtest or in the storage TA, because there are unrecoverable conditions (data abort, kill -9...). Instead, implement a new --clear-storage option which invokes the storage TA to enumerate and delete any objects it may own. The TA is invoked twice (because the same code is exposed via two UUIDS), and each invocation iterates on the two possible filesystems (TEE_STORAGE_PRIVATE_REE, TEE_STORAGE_PRIVATE_RPMB). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
- Loading branch information
1 parent
755a708
commit c21e578
Showing
10 changed files
with
155 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2023, Linaro Limited | ||
*/ | ||
|
||
#include <err.h> | ||
#include <ta_storage.h> | ||
#include <tee_client_api.h> | ||
#include <stdlib.h> | ||
#include <util.h> | ||
|
||
#include "clear_storage.h" | ||
|
||
static int clear_storage_for_ta(TEEC_UUID *uuid) | ||
{ | ||
TEEC_Result res = TEEC_ERROR_GENERIC; | ||
TEEC_Context ctx = { }; | ||
TEEC_Session sess = { }; | ||
TEEC_Operation op = { }; | ||
uint32_t eo = 0; | ||
|
||
res = TEEC_InitializeContext(NULL, &ctx); | ||
if (res) | ||
errx(EXIT_FAILURE, "TEEC_InitializeContext: %#"PRIx32, res); | ||
|
||
res = TEEC_OpenSession(&ctx, &sess, uuid, TEEC_LOGIN_PUBLIC, NULL, | ||
NULL, &eo); | ||
if (res) | ||
errx(EXIT_FAILURE, | ||
"TEEC_OpenSession: res %#"PRIx32" err_orig %#"PRIx32, | ||
res, eo); | ||
|
||
op.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, | ||
TEEC_NONE); | ||
res = TEEC_InvokeCommand(&sess, TA_STORAGE_CMD_CLEAR_STORAGE, &op, &eo); | ||
if (res) | ||
errx(EXIT_FAILURE, | ||
"TEEC_InvokeCommand: res %#"PRIx32" err_orig %#"PRIx32, | ||
res, eo); | ||
|
||
TEEC_CloseSession(&sess); | ||
TEEC_FinalizeContext(&ctx); | ||
return 0; | ||
} | ||
|
||
int clear_storage(void) | ||
{ | ||
TEEC_UUID uuid[] = { TA_STORAGE_UUID, TA_STORAGE2_UUID }; | ||
size_t i = 0; | ||
int res = 0; | ||
|
||
for (i = 0; i < ARRAY_SIZE(uuid); i++) { | ||
res = clear_storage_for_ta(uuid + i); | ||
if (res) | ||
break; | ||
} | ||
return res; | ||
} |
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 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Copyright (c) 2023, Linaro Limited | ||
*/ | ||
|
||
#ifndef CLEAR_STORAGE_H | ||
#define CLEAR_STORAGE_H | ||
|
||
int clear_storage(void); | ||
|
||
#endif /*CLEAR_STORAGE_H*/ |
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