From 0e177cc136b971af11953a84e10f5489e5557579 Mon Sep 17 00:00:00 2001 From: "r.tyminski" Date: Mon, 5 Jun 2017 13:12:39 +0200 Subject: Update from upstream to 2.4.0 version Change-Id: I748163170cec3409645e3990c4c2d774b01f349f --- tee-supplicant/src/tee_supp_fs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tee-supplicant/src/tee_supp_fs.c b/tee-supplicant/src/tee_supp_fs.c index ba8b805..bd1a220 100644 --- a/tee-supplicant/src/tee_supp_fs.c +++ b/tee-supplicant/src/tee_supp_fs.c @@ -726,6 +726,8 @@ static TEEC_Result ree_fs_new_opendir(size_t num_params, char *fname; DIR *dir; int handle; + struct dirent *dent; + bool empty = true; if (num_params != 3 || (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) != @@ -748,6 +750,30 @@ static TEEC_Result ree_fs_new_opendir(size_t num_params, if (!dir) return TEEC_ERROR_ITEM_NOT_FOUND; + /* + * Ignore empty directories. Works around an issue when the + * data path is mounted over NFS. Due to the way OP-TEE implements + * TEE_CloseAndDeletePersistentObject1() currently, tee-supplicant + * still has a file descriptor open to the file when it's removed in + * ree_fs_new_remove(). In this case the NFS server may create a + * temporary reference called .nfs????, and the rmdir() call fails + * so that the TA directory is left over. Checking this special case + * here avoids that TEE_StartPersistentObjectEnumerator() returns + * TEE_SUCCESS when it should return TEEC_ERROR_ITEM_NOT_FOUND. + * Test case: "xtest 6009 6010". + */ + while ((dent = readdir(dir))) { + if (dent->d_name[0] == '.') + continue; + empty = false; + break; + } + if (empty) { + closedir(dir); + return TEEC_ERROR_ITEM_NOT_FOUND; + } + rewinddir(dir); + handle = handle_get(&dir_handle_db, dir); if (handle < 0) { closedir(dir); -- cgit v1.2.3