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

Commit 43c9e4ae authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Fail import if secure buffer is not accessible to CP_PIXEL"

parents 80ec7c12 f5266ee4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved.
 */

#include <uapi/linux/msm_ion.h>
#include <uapi/linux/sched/types.h>
#include <linux/ctype.h>
#include <linux/debugfs.h>
@@ -3008,6 +3009,29 @@ static int kgsl_setup_dma_buf(struct kgsl_device *device,
	entry->priv_data = meta;
	entry->memdesc.sgt = sg_table;

	if (entry->memdesc.priv & KGSL_MEMDESC_SECURE) {
		unsigned long dma_buf_flags;

		ret = dma_buf_get_flags(dmabuf, &dma_buf_flags);
		if (ret) {
			dev_info(device->dev,
				"Unable to get dma buf flags, err = %d. Skipped access check\n",
				ret);
			ret = 0;
			goto skip_access_check;
		}

		/*
		 * Secure buffer is not accessible to CP_PIXEL, there is no point
		 * in importing this buffer.
		 */
		if (!(dma_buf_flags & ION_FLAG_CP_PIXEL)) {
			ret = -EPERM;
			goto out;
		}
	}

skip_access_check:
	/* Calculate the size of the memdesc from the sglist */
	for (s = entry->memdesc.sgt->sgl; s != NULL; s = sg_next(s)) {
		int priv = (entry->memdesc.priv & KGSL_MEMDESC_SECURE) ? 1 : 0;