summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2013-06-12 11:23:54 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:34:22 -0700
commitdac6c1c7844bdfbf901a1af37c6de467130dbfca (patch)
tree372b23a7a9df78a5f8e27692e537c77bf897f11b /security
parent86eda3416aca4f4863704bb0f6db08a5f6faf09c (diff)
security: nv_tee_driver: handle "daemon not present" scenario
During each request from the daemon, set a bit in a global variable indicating that the daemon is alive and kicking. For each request from secure world, check this bit to see if the daemon is present, and send error if not present. Bug 1291402 Change-Id: Ie8c59a465451b1781b4f379c0b6f661b05a417da Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/237850 (cherry picked from commit 205baa9bb3f4d2ba150253284ac7af9733938a01) Reviewed-on: http://git-master/r/249869 Reviewed-by: Automatic_Commit_Validation_User Tested-by: Aaron Gamble <jgamble@nvidia.com>
Diffstat (limited to 'security')
-rw-r--r--security/nv_tee_driver/tee_fs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/security/nv_tee_driver/tee_fs.c b/security/nv_tee_driver/tee_fs.c
index a52ea255a8f5..a5dbdfdf6102 100644
--- a/security/nv_tee_driver/tee_fs.c
+++ b/security/nv_tee_driver/tee_fs.c
@@ -22,6 +22,7 @@
#include <linux/completion.h>
#include <linux/workqueue.h>
#include <linux/freezer.h>
+#include <linux/bitops.h>
#include <asm/uaccess.h>
@@ -30,6 +31,8 @@
#define TEE_SHMEM_FNAME_SZ SZ_64
#define TEE_SHMEM_DATA_SZ SZ_128K
+#define TEE_FS_READY_BIT 1
+
struct tee_shmem {
char file_name[TEE_SHMEM_FNAME_SZ];
char file_data[TEE_SHMEM_DATA_SZ];
@@ -39,6 +42,7 @@ struct list_head req_list;
DECLARE_COMPLETION(req_ready);
DECLARE_COMPLETION(req_complete);
static unsigned long secure_error;
+static unsigned long fs_ready;
static void indicate_complete(unsigned long ret)
{
@@ -68,6 +72,8 @@ int tee_handle_fs_ioctl(struct file *file, unsigned int ioctl_num,
set_freezable();
+ set_bit(TEE_FS_READY_BIT, &fs_ready);
+
/* wait for a new request */
while (wait_for_completion_interruptible(&req_ready))
try_to_freeze();
@@ -148,6 +154,12 @@ static void _tee_fs_file_operation(const char *name, void *buf, int len,
TEEC_FileReq *new_req;
struct tee_file_req_node *req_node;
+ if (!test_and_clear_bit(TEE_FS_READY_BIT, &fs_ready)) {
+ pr_err("%s: daemon not loaded yet\n", __func__);
+ secure_error = TEEC_ERROR_NO_DATA;
+ goto fail;
+ }
+
BUG_ON(!name);
if (type == TEEC_FILE_REQ_READ || type == TEEC_FILE_REQ_WRITE)
@@ -183,6 +195,7 @@ static void _tee_fs_file_operation(const char *name, void *buf, int len,
kfree(new_req);
+fail:
/* signal completion to the secure world */
indicate_complete(secure_error);
}