summaryrefslogtreecommitdiff
path: root/mali_kbase
diff options
context:
space:
mode:
authorSuzanne Candanedo <suzanne.candanedo@arm.com>2023-04-12 12:18:55 +0100
committerGuus Sliepen <gsliepen@google.com>2023-04-21 16:23:23 +0000
commitf284834befcee9a9e4031de3604fe7e16759de14 (patch)
tree07e8c16553335e6a9b041e84f0a352b7c7f301b8 /mali_kbase
parentb2006a9bbee737e9e6c0277deb670f63f2b90a2a (diff)
downloadgpu-f284834befcee9a9e4031de3604fe7e16759de14.tar.gz
[Official] MIDCET-4458, GPUCORE-36429: Prevent JIT allocations following unmap of tracking page
This commit introduces new checks to ensure that, like allocations of native memory, JIT memory allocations are blocked after the unmap of the tracking page. Bug: 275615867 Provenance: https://code.ipdelivery.arm.com/c/GPU/mali-ddk/+/5168/ Change-Id: I32460df4e8898784e75084193e038a912f67b33e (cherry picked from commit 240d4e9206528a43340c22aa69b124436f9a4e01)
Diffstat (limited to 'mali_kbase')
-rw-r--r--mali_kbase/csf/mali_kbase_csf_kcpu.c8
-rw-r--r--mali_kbase/mali_kbase_softjobs.c7
2 files changed, 15 insertions, 0 deletions
diff --git a/mali_kbase/csf/mali_kbase_csf_kcpu.c b/mali_kbase/csf/mali_kbase_csf_kcpu.c
index 24fc969..dc66f62 100644
--- a/mali_kbase/csf/mali_kbase_csf_kcpu.c
+++ b/mali_kbase/csf/mali_kbase_csf_kcpu.c
@@ -364,6 +364,14 @@ static int kbase_kcpu_jit_allocate_prepare(
lockdep_assert_held(&kcpu_queue->lock);
+ if (!kbase_mem_allow_alloc(kctx)) {
+ dev_dbg(kctx->kbdev->dev,
+ "Invalid attempt to allocate JIT memory by %s/%d for ctx %d_%d",
+ current->comm, current->pid, kctx->tgid, kctx->id);
+ ret = -EINVAL;
+ goto out;
+ }
+
if (!data || count > kcpu_queue->kctx->jit_max_allocations ||
count > ARRAY_SIZE(kctx->jit_alloc)) {
ret = -EINVAL;
diff --git a/mali_kbase/mali_kbase_softjobs.c b/mali_kbase/mali_kbase_softjobs.c
index f9de37f..ad9147c 100644
--- a/mali_kbase/mali_kbase_softjobs.c
+++ b/mali_kbase/mali_kbase_softjobs.c
@@ -974,6 +974,13 @@ static int kbase_jit_allocate_prepare(struct kbase_jd_atom *katom)
jit_info_copy_size_for_jit_version[kctx->jit_version];
WARN_ON(jit_info_user_copy_size > sizeof(*info));
+ if (!kbase_mem_allow_alloc(kctx)) {
+ dev_dbg(kbdev->dev, "Invalid attempt to allocate JIT memory by %s/%d for ctx %d_%d",
+ current->comm, current->pid, kctx->tgid, kctx->id);
+ ret = -EINVAL;
+ goto fail;
+ }
+
/* For backwards compatibility, and to prevent reading more than 1 jit
* info struct on jit version 1
*/