MGS-2786 [#imx-479] fix gpu kernel panic with debugfs
authorXianzhong <xianzhong.li@nxp.com>
Thu, 30 Mar 2017 03:58:04 +0000 (11:58 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:47 +0000 (15:21 -0500)
the user space data cannot be directly accessible in 4.9 kernel.
add copy_from_user to fix this kernel painic for gpu debugfs.

Date: Mar 30, 2017
Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debugfs.c

index 76414fe..e6526b0 100644 (file)
@@ -215,7 +215,11 @@ gc_debugfs_write(
 
     if (info->write)
     {
-        info->write(buf, count, node);
+        char tmpbuf[256] = {0};
+        if (count >= sizeof(tmpbuf) || copy_from_user(tmpbuf, buf, count) > 0)
+            return 0;
+
+        info->write(tmpbuf, count, node);
     }
 
     return count;