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

Commit 5eb952a6 authored by Jordan Crouse's avatar Jordan Crouse Committed by Harshitha Sai Neelati
Browse files

msm: kgsl: Verify the offset of the profiling buffer



If a command is using a profiling buffer, make sure that the offset
is within the bounds of the specified memory descriptor.

Change-Id: Ic0dedbadc77e8eccd957136467bd0c56a1af2dab
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent e0da3764
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -598,13 +598,29 @@ static void add_profiling_buffer(struct kgsl_device *device,
		return;
	}

	cmdobj->profiling_buf_entry = entry;

	if (id != 0)
	if (!id) {
		cmdobj->profiling_buffer_gpuaddr = gpuaddr;
	} else {
		u64 off = offset + sizeof(struct kgsl_drawobj_profiling_buffer);

		/*
		 * Make sure there is enough room in the object to store the
		 * entire profiling buffer object
		 */
		if (off < offset || off >= entry->memdesc.size) {
			dev_err(device->dev,
				"ignore invalid profile offset ctxt %d id %d offset %lld gpuaddr %llx size %lld\n",
			drawobj->context->id, id, offset, gpuaddr, size);
			kgsl_mem_entry_put(entry);
			return;
		}

		cmdobj->profiling_buffer_gpuaddr =
			entry->memdesc.gpuaddr + offset;
	else
		cmdobj->profiling_buffer_gpuaddr = gpuaddr;
	}

	cmdobj->profiling_buf_entry = entry;
}

/**