Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f94b4468 authored by Lokesh Batra's avatar Lokesh Batra Committed by Tarun Karra
Browse files

msm: kgsl: Do not allow CPU mappings of secure buffers



We should not be mapping secure buffers into the CPU pagetables
since these buffers should only be accessed by the GPU in secure
mode. If the userspace does try to access this buffer, that will
trigger a stage 2 page fault and crash the device. This change
was earlier merged in 'commit 926e9ca3 ("msm: kgsl: Do not
allow CPU mappings of secure buffers")' but it was accidently
removed in 'commit a2184922 ("msm: kgsl: Refactor GPU
addressing")'.

Change-Id: I054d34b39e301799c8216a6ffba1099348d8c268
Signed-off-by: default avatarShrenuj Bansal <shrenujb@codeaurora.org>
Signed-off-by: default avatarLokesh Batra <lbatra@codeaurora.org>
parent ef6d7f98
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -3501,14 +3501,19 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
	struct kgsl_process_private *private = dev_priv->process_priv;
	struct kgsl_device *device = dev_priv->device;
	struct kgsl_mem_entry *entry = NULL;
	int ret;

	if (vma_offset == (unsigned long) device->memstore.gpuaddr)
		return get_unmapped_area(NULL, addr, len, pgoff, flags);

	ret = get_mmap_entry(private, &entry, pgoff, len);
	if (ret)
		return ret;
	val = get_mmap_entry(private, &entry, pgoff, len);
	if (val)
		return val;

	/* Do not allow CPU mappings for secure buffers */
	if (kgsl_memdesc_is_secured(&entry->memdesc)) {
		val = -EPERM;
		goto put;
	}

	if (!kgsl_memdesc_use_cpu_map(&entry->memdesc)) {
		val = get_unmapped_area(NULL, addr, len, 0, flags);
@@ -3524,6 +3529,7 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
				private->pid, addr, pgoff, len, (int) val);
	}

put:
	kgsl_mem_entry_put(entry);
	return val;
}