From 8e2b27ba54072ebf3c1574c81c248e4d3d6b8d8c Mon Sep 17 00:00:00 2001 From: Jiyu Yang Date: Wed, 26 Jun 2019 14:02:13 +0800 Subject: [PATCH] gpu: fixed fence handling error [1/2] 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 --- .../r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c | 2 ++ .../r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c | 2 ++ .../r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c | 2 ++ .../r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c | 2 ++ dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c | 2 ++ 5 files changed, 10 insertions(+) diff --git a/bifrost/r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c b/bifrost/r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c index 16d3563..7f77fe7 100644 --- a/bifrost/r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c +++ b/bifrost/r10p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c @@ -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; } diff --git a/bifrost/r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c b/bifrost/r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c index 2312399..3daeb93 100644 --- a/bifrost/r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c +++ b/bifrost/r12p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c @@ -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; } diff --git a/bifrost/r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c b/bifrost/r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c index 2312399..3daeb93 100644 --- a/bifrost/r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c +++ b/bifrost/r15p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c @@ -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; } diff --git a/bifrost/r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c b/bifrost/r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c index 062ec00..9aa9e2d 100644 --- a/bifrost/r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c +++ b/bifrost/r9p0/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c @@ -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; } diff --git a/dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c b/dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c index 2312399..3daeb93 100755 --- a/dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c +++ b/dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_sync_file.c @@ -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; } -- 2.20.1