summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungho Lee <sh1006.lee@samsung.com>2016-06-16 20:05:31 +0900
committerjino.cho <jino.cho@samsung.com>2017-03-03 17:02:45 +0900
commitdbe3b4b8f4cb83f2c9131dbbeb2eb7d7cb45ca77 (patch)
tree50760267f144a650713fc56af07ee49185b6f491
parentc0e6b36cb5ffec0d7e3b54bd456498509ecdc416 (diff)
downloadlinux-3.10-artik-dbe3b4b8f4cb83f2c9131dbbeb2eb7d7cb45ca77.tar.gz
linux-3.10-artik-dbe3b4b8f4cb83f2c9131dbbeb2eb7d7cb45ca77.tar.bz2
linux-3.10-artik-dbe3b4b8f4cb83f2c9131dbbeb2eb7d7cb45ca77.zip
misc: artiktee: Fixed create file when disk is full.
This patch to fix secure storage service. Though filesystem doesn't have enough space to save secure data. Artiktee driver creates only 0 byte file. If secure file size is zero, Secure OS should ignore the file. Change-Id: I7afd02bb4fd44b19c78877c3ef154d8341e25d01 Signed-off-by: Seungho Lee <sh1006.lee@samsung.com>
-rwxr-xr-x[-rw-r--r--]drivers/misc/artiktee/ss_core.c30
-rwxr-xr-x[-rw-r--r--]drivers/misc/artiktee/ss_file.c6
2 files changed, 23 insertions, 13 deletions
diff --git a/drivers/misc/artiktee/ss_core.c b/drivers/misc/artiktee/ss_core.c
index 0a31b0bd541..06b0384de57 100644..100755
--- a/drivers/misc/artiktee/ss_core.c
+++ b/drivers/misc/artiktee/ss_core.c
@@ -176,6 +176,7 @@ static void ssdev_query_object(SSTransaction_t *tsx)
char file_main[128] = { 0 };
char file_back[128] = { 0 };
int *p = NULL;
+ int file_size;
p = (int *)sstransaction_payload_ptr(tsx);
@@ -191,20 +192,23 @@ static void ssdev_query_object(SSTransaction_t *tsx)
tzlog_print(TZLOG_DEBUG, "file_main:%s\n", file_main);
tzlog_print(TZLOG_DEBUG, "file_back:%s\n", file_back);
- if (ss_file_object_exist(file_main) == 1) {
+ file_size = ss_file_object_size(file_main);
+ if (file_size > 0) {
sstransaction_set_arg(tsx, 0, TEE_STORAGE_PRIVATE);
tzlog_print(TZLOG_DEBUG,
- " Same object id in main File.\n");
- } else if ((ss_file_object_exist(file_back) == 1)) {
- /*if not find in main file,
- let's check bak file for the obj */
- sstransaction_set_arg(tsx, 0, TEE_STORAGE_PRIVATE);
- tzlog_print(TZLOG_DEBUG,
- " Same object id in back File.\n");
+ " Same object id in main File.\n");
} else {
- sstransaction_set_arg(tsx, 0, 0);
- tzlog_print(TZLOG_DEBUG,
- " object id does not found in normal world.\n");
+ file_size = ss_file_object_size(file_back);
+ if (file_size > 0) {
+ sstransaction_set_arg(tsx, 0, TEE_STORAGE_PRIVATE);
+ tzlog_print(TZLOG_DEBUG,
+ " Same object id in back File.\n");
+ }
+ else {
+ sstransaction_set_arg(tsx, 0, 0);
+ tzlog_print(TZLOG_DEBUG,
+ " object id does not found in normal world.\n");
+ }
}
} else if (sstransaction_get_arg(tsx, 0) == TEE_STORAGE_RPMB) {
if (sstransaction_get_arg(tsx, 1)) {
@@ -374,6 +378,7 @@ static void ssdev_file_create_data(SSTransaction_t *tsx)
int *p = (int *)sstransaction_payload_ptr(tsx);
size_t wsm_size = 0;
int ret;
+ int file_size;
void *wsm_buffer =
(char *)ss_wsm_channel.payload + sstransaction_wsm_offset(tsx,
&wsm_size);
@@ -391,7 +396,8 @@ static void ssdev_file_create_data(SSTransaction_t *tsx)
"Create data, file_main '%s', file back '%s'\n", file_main,
file_back);
- if (ss_file_object_exist(file_main) == 1) {
+ file_size = ss_file_object_size(file_main);
+ if (file_size > 0) {
tzlog_print(TZLOG_DEBUG, "Copy main to bak file\n");
(void)ssdev_file_copy_object(file_back, file_main);
diff --git a/drivers/misc/artiktee/ss_file.c b/drivers/misc/artiktee/ss_file.c
index d808aff20c5..f1225d62fdf 100644..100755
--- a/drivers/misc/artiktee/ss_file.c
+++ b/drivers/misc/artiktee/ss_file.c
@@ -68,6 +68,10 @@ int ss_file_create_object(char *path, char *buf, size_t size)
filp_close(file, NULL);
+ if (write_size != size) {
+ ss_file_delete_object(path);
+ }
+
return write_size;
}
@@ -165,7 +169,7 @@ int ss_file_object_size(char *path)
file = filp_open(path, O_RDWR, 0);
if (IS_ERR(file)) {
- tzlog_print(TZLOG_ERROR,
+ tzlog_print(TZLOG_DEBUG,
"error occured while opening file %s, exiting...\n",
path);
return -1;