security: nv_tee_driver: make wait_for_completion calls freezable
Varun Wadekar [Tue, 11 Jun 2013 10:03:20 +0000 (15:03 +0530)]
Bug 1305672

Change-Id: I21efcac292bfc2001087614437a4fee68fe5db69
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/237571
(cherry picked from commit 3d8d572a2aabe7d6943cd39ce42d82394c87ff5a)
Reviewed-on: http://git-master/r/249868
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Aaron Gamble <jgamble@nvidia.com>
Reviewed-by: James Zhao <jamesz@nvidia.com>
Tested-by: James Zhao <jamesz@nvidia.com>

security/nv_tee_driver/tee_fs.c

index 192bc2d..a52ea25 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/completion.h>
 #include <linux/workqueue.h>
+#include <linux/freezer.h>
 
 #include <asm/uaccess.h>
 
@@ -65,8 +66,11 @@ int tee_handle_fs_ioctl(struct file *file, unsigned int ioctl_num,
 
                ptr_user_req = (TEEC_FileReq *)ioctl_param;
 
+               set_freezable();
+
                /* wait for a new request */
-               wait_for_completion(&req_ready);
+               while (wait_for_completion_interruptible(&req_ready))
+                       try_to_freeze();
 
                /* dequeue new request from the secure world */
                req_node = list_first_entry(&req_list, struct tee_file_req_node,
@@ -171,8 +175,11 @@ static void _tee_fs_file_operation(const char *name, void *buf, int len,
        list_add_tail(&req_list, &req_node->node);
        complete(&req_ready);
 
+       set_freezable();
+
        /* wait for the consumer's signal */
-       wait_for_completion(&req_complete);
+       while (wait_for_completion_interruptible(&req_complete))
+               try_to_freeze();
 
        kfree(new_req);