gpu: fixed fence handling error [1/2]
authorJiyu Yang <jiyu.yang@amlogic.com>
Wed, 26 Jun 2019 06:02:13 +0000 (14:02 +0800)
committerJiyu Yang <jiyu.yang@amlogic.com>
Wed, 3 Jul 2019 06:00:38 +0000 (23:00 -0700)
PD#SWPL-10285

Problem:
Security issue with fence handling error path on
Linux 4.9.68 and later

Solution:
Modify the function kbase_sync_fence_out_create() in file
drivers/gpu/arm/midgard/mali_kbase_sync_file.c to Insert
Lines as follows to ensure the dma_fence_put() call only happens on
Linux 4.9.67 or lower

Verify:
franklin

Change-Id: I5832be0b8a1065107e2ff092abfe43910e5ddad5
Signed-off-by: Jiyu Yang <jiyu.yang@amlogic.com>
bifrost/r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c
bifrost/r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c
bifrost/r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c
bifrost/r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c
dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c

index 16d3563256e235c0776ee4cae6442e65065fed1c..7f77fe73b4b18497ee26a574ddd427d2eb63fbdb 100644 (file)
@@ -85,7 +85,9 @@ int kbase_sync_fence_out_create(struct kbase_jd_atom *katom, int stream_fd)
        /* create a sync_file fd representing the fence */
        sync_file = sync_file_create(fence);
        if (!sync_file) {
+#if (KERNEL_VERSION(4, 9, 67) >= LINUX_VERSION_CODE)
                dma_fence_put(fence);
+#endif
                kbase_fence_out_remove(katom);
                return -ENOMEM;
        }
index 23123994135270db2d74f19d63e62a4d62a88d72..3daeb935ac3db8649c11f971c9f124bd7c9f5509 100644 (file)
@@ -85,7 +85,9 @@ int kbase_sync_fence_out_create(struct kbase_jd_atom *katom, int stream_fd)
        /* create a sync_file fd representing the fence */
        sync_file = sync_file_create(fence);
        if (!sync_file) {
+#if (KERNEL_VERSION(4, 9, 67) >= LINUX_VERSION_CODE)
                dma_fence_put(fence);
+#endif
                kbase_fence_out_remove(katom);
                return -ENOMEM;
        }
index 23123994135270db2d74f19d63e62a4d62a88d72..3daeb935ac3db8649c11f971c9f124bd7c9f5509 100644 (file)
@@ -85,7 +85,9 @@ int kbase_sync_fence_out_create(struct kbase_jd_atom *katom, int stream_fd)
        /* create a sync_file fd representing the fence */
        sync_file = sync_file_create(fence);
        if (!sync_file) {
+#if (KERNEL_VERSION(4, 9, 67) >= LINUX_VERSION_CODE)
                dma_fence_put(fence);
+#endif
                kbase_fence_out_remove(katom);
                return -ENOMEM;
        }
index 062ec00aaf93b139b5f2627d048397be60945247..9aa9e2dbb055a75a8e8a7fbb1fa79b408d6450ff 100644 (file)
@@ -80,7 +80,9 @@ int kbase_sync_fence_out_create(struct kbase_jd_atom *katom, int stream_fd)
        /* create a sync_file fd representing the fence */
        sync_file = sync_file_create(fence);
        if (!sync_file) {
+#if (KERNEL_VERSION(4, 9, 67) >= LINUX_VERSION_CODE)
                dma_fence_put(fence);
+#endif
                kbase_fence_out_remove(katom);
                return -ENOMEM;
        }
index 23123994135270db2d74f19d63e62a4d62a88d72..3daeb935ac3db8649c11f971c9f124bd7c9f5509 100755 (executable)
@@ -85,7 +85,9 @@ int kbase_sync_fence_out_create(struct kbase_jd_atom *katom, int stream_fd)
        /* create a sync_file fd representing the fence */
        sync_file = sync_file_create(fence);
        if (!sync_file) {
+#if (KERNEL_VERSION(4, 9, 67) >= LINUX_VERSION_CODE)
                dma_fence_put(fence);
+#endif
                kbase_fence_out_remove(katom);
                return -ENOMEM;
        }