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

Commit 6c58829f authored by Harshitha Sai Neelati's avatar Harshitha Sai Neelati
Browse files

msm: kgsl: Validate page offset before vmf_insert_page



Validate page offset before vmf_insert_page to avoid out of bound access.

Change-Id: I8fe91934ce0a955238dca25e518dc48d00de6941
Signed-off-by: default avatarHarshitha Sai Neelati <hsaine@codeaurora.org>
parent e4d3a647
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -366,8 +366,12 @@ static vm_fault_t kgsl_paged_vmfault(struct kgsl_memdesc *memdesc,
				struct vm_fault *vmf)
{
	int pgoff;
	unsigned int offset = vmf->address - vma->vm_start;

	pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
	if (offset >= memdesc->size)
		return VM_FAULT_SIGBUS;

	pgoff = offset >> PAGE_SHIFT;

	return vmf_insert_page(vma, vmf->address, memdesc->pages[pgoff]);
}