security: tlk_driver: serialize calls to tlk
James Zhao [Wed, 25 Sep 2013 21:10:00 +0000 (14:10 -0700)]
Add mutex lock to serialize all ioctls that will
result in a smc call to tlk.

bug 1340442
bug 1340471

Change-Id: Ie2cc1e21dcff0a78c971aad0c230f71d1f2b1c49
Signed-off-by: James Zhao <jamesz@nvidia.com>
(cherry picked from commit 2a9da9d1c1e717d7f44befb0ca84cbca413b9e3f)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

security/tlk_driver/ote_device.c

index 6292432..9016a31 100644 (file)
@@ -38,6 +38,7 @@
 #include <trace/events/nvsecurity.h>
 
 struct tlk_device tlk_dev;
+static DEFINE_MUTEX(smc_lock);
 
 u32 notrace tegra_read_cycle(void)
 {
@@ -423,7 +424,9 @@ static long tlk_device_ioctl(struct file *file, unsigned int ioctl_num,
        case TE_IOCTL_OPEN_CLIENT_SESSION:
        case TE_IOCTL_CLOSE_CLIENT_SESSION:
        case TE_IOCTL_LAUNCH_OPERATION:
+               mutex_lock(&smc_lock);
                err = te_handle_trustedapp_ioctl(file, ioctl_num, ioctl_param);
+               mutex_unlock(&smc_lock);
                break;
 
        case TE_IOCTL_FILE_NEW_REQ: