summaryrefslogtreecommitdiffstats
path: root/cryptfs_hw.c
diff options
context:
space:
mode:
authorDinesh K Garg <dineshg@codeaurora.org>2015-10-28 14:41:10 -0700
committerZhao Wei Liew <zhaoweiliew@gmail.com>2017-02-12 20:45:34 +0800
commitf09ae181c55ab6cf1a3af4be11031a27e0fe3915 (patch)
treee9f3ca4fdea468b1fcc86cbc33b1add3281ed603 /cryptfs_hw.c
parent55fd88fafa074b54a1c455f3692a0853662d87b2 (diff)
downloadandroid_vendor_qcom_opensource_cryptfs_hw-f09ae181c55ab6cf1a3af4be11031a27e0fe3915.tar.gz
android_vendor_qcom_opensource_cryptfs_hw-f09ae181c55ab6cf1a3af4be11031a27e0fe3915.tar.bz2
android_vendor_qcom_opensource_cryptfs_hw-f09ae181c55ab6cf1a3af4be11031a27e0fe3915.zip
Wait for QSEECom listeners before calling KMS APIs
Sometime it is possible that KMS APIs are invoked and QSEECom listeners are not up. This would cause failure from secure side and KMS API will fail eventually. This change waits for QSEECom listeners to be up before calling KMS APIs. If QSEECom listeners are not up even after wait period, API would fail without going to secure side. Change-Id: I211248645f92fc0fcfe6f250cb1f26661f5fb06c
Diffstat (limited to 'cryptfs_hw.c')
-rwxr-xr-xcryptfs_hw.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/cryptfs_hw.c b/cryptfs_hw.c
index b2efa4a..c7adfd1 100755
--- a/cryptfs_hw.c
+++ b/cryptfs_hw.c
@@ -67,6 +67,8 @@
#define KEYMASTER_PARTITION_NAME "/dev/block/bootdevice/by-name/keymaster"
+#define QSEECOM_UP_CHECK_COUNT 10
+
static int loaded_library = 0;
static int (*qseecom_create_key)(int, void*);
static int (*qseecom_update_key)(int, void*, void*);
@@ -118,12 +120,32 @@ static void wipe_userdata()
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
}
+static int is_qseecom_up()
+{
+ int i = 0;
+ char value[PROPERTY_VALUE_MAX] = {0};
+
+ for (; i<QSEECOM_UP_CHECK_COUNT; i++) {
+ property_get("sys.listeners.registered", value, "");
+ if (!strncmp(value, "true", PROPERTY_VALUE_MAX))
+ return 1;
+ usleep(100000);
+ }
+ return 0;
+}
+
+
static int load_qseecom_library()
{
const char *error = NULL;
if (loaded_library)
return loaded_library;
+ if (!is_qseecom_up()) {
+ SLOGE("Timed out waiting for QSEECom listeners..aborting FDE key operation");
+ return 0;
+ }
+
void * handle = dlopen(QSEECOM_LIBRARY_PATH, RTLD_NOW);
if(handle) {
dlerror(); /* Clear any existing error */