regression 1016: add a subtest for non-NULL memref of size 0
Add a subtest to assert that the implementation allows to forward
non-NULL memref from a TA to another TA.
Regression 1016 already contains tests related to forwarding memref
between TAs. Thus extend this existing test with the subtest described
above instead of writing a new one.
The Global Platform specification allows this, however, at the time of
writing, optee-os will panic. A fix is proposed at [1].
[1] core: tee_svc.c: allow to pass non-NULL memref of size 0
Link: https://github.com/OP-TEE/optee_os/pull/6405
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/ta/os_test/os_test.c b/ta/os_test/os_test.c
index b16bcaf..e8b5494 100644
--- a/ta/os_test/os_test.c
+++ b/ta/os_test/os_test.c
@@ -1171,6 +1171,48 @@
}
#undef TA2TA_BUF_SIZE
+TEE_Result ta_entry_ta2ta_memref_size0(uint32_t param_types, TEE_Param params[4])
+{
+ static const TEE_UUID test_uuid = TA_OS_TEST_UUID;
+ TEE_TASessionHandle sess = TEE_HANDLE_NULL;
+ uint32_t ret_orig = 0;
+ TEE_Result res = TEE_ERROR_GENERIC;
+
+ if (param_types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
+ TEE_PARAM_TYPE_MEMREF_INOUT,
+ TEE_PARAM_TYPE_MEMREF_OUTPUT,
+ TEE_PARAM_TYPE_NONE))
+ return TEE_ERROR_BAD_PARAMETERS;
+
+ /*
+ * This test expects all memory references to be non-NULL but
+ * all sizes to be zero.
+ */
+ if (!params[0].memref.buffer || params[0].memref.size ||
+ !params[1].memref.buffer || params[1].memref.size ||
+ !params[2].memref.buffer || params[2].memref.size)
+ return TEE_ERROR_BAD_PARAMETERS;
+
+ res = TEE_OpenTASession(&test_uuid, TEE_TIMEOUT_INFINITE, 0, NULL,
+ &sess, &ret_orig);
+ if (res != TEE_SUCCESS) {
+ EMSG("TEE_OpenTASession failed");
+ return res;
+ }
+
+ /*
+ * TA basically does nothing. The actual test just consists
+ * into validating that passing non-NULL memref of size zero
+ * does not panic.
+ */
+ res = TEE_InvokeTACommand(sess, TEE_TIMEOUT_INFINITE,
+ TA_OS_TEST_CMD_TA2TA_MEMREF_MIX,
+ param_types, params, &ret_orig);
+
+ TEE_CloseTASession(sess);
+ return res;
+}
+
TEE_Result ta_entry_ta2ta_memref_mix(uint32_t param_types, TEE_Param params[4])
{
uint8_t *in = NULL;