aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Brand <pascal.brand@st.com>2016-04-19 13:54:21 +0200
committerPascal Brand <pascal.brand@st.com>2016-04-19 13:54:21 +0200
commit63c852a39ae930ea038576311af7640163b283ec (patch)
tree59c01aeb4c251bbc1a76dff8ac51a9f10283d3da
parentaa18bbb0b8a6ff0905da732bb96f1bd92adfb991 (diff)
Check allocated memory is not corruptedHEADmaster
Memory allocated by smaf_optee_allocator is written (this is possible because QEMU memory is not really secure) and we check it is not modified by other TEE TA. Just run: tee-supplicant & test_smaf & xtest Signed-off-by: Pascal Brand <pascal.brand@st.com>
-rw-r--r--tests/test_smaf.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_smaf.c b/tests/test_smaf.c
index 0f3d206..5656a23 100644
--- a/tests/test_smaf.c
+++ b/tests/test_smaf.c
@@ -91,6 +91,9 @@ static void test_create_non_page_aligned_mmap(void)
int ret;
int fd;
void *data;
+ char reference[LENGTH+1];
+ char *pt;
+ int i;
ret = smaf_create_buffer(LENGTH+1, O_CLOEXEC | O_RDWR, "smaf-optee-allocator", &fd);
@@ -100,6 +103,16 @@ static void test_create_non_page_aligned_mmap(void)
}
data = mmap(0, LENGTH+1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ pt = (char *)data;
+
+ for (i=0; i<LENGTH+1; i++)
+ reference[i] = i;
+ memcpy(pt, reference, LENGTH+1);
+ while (!memcmp(pt, reference, LENGTH+1)) {
+ printf("Data did not changed\n");
+ sleep(10);
+ }
+ printf("Data Changed !!! Wrong\n");
munmap(data, LENGTH+1);
close(fd);