Skip to content

Commit 05b252c

Browse files
kraxeltorvalds
authored andcommitted
udmabuf: add back sanity check
Check vm_fault->pgoff before using it. When we removed the warning, we also removed the check. Fixes: 7b26e4e ("udmabuf: drop WARN_ON() check.") Reported-by: [email protected] Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a111daf commit 05b252c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/dma-buf/udmabuf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
3232
{
3333
struct vm_area_struct *vma = vmf->vma;
3434
struct udmabuf *ubuf = vma->vm_private_data;
35+
pgoff_t pgoff = vmf->pgoff;
3536

36-
vmf->page = ubuf->pages[vmf->pgoff];
37+
if (pgoff >= ubuf->pagecount)
38+
return VM_FAULT_SIGBUS;
39+
vmf->page = ubuf->pages[pgoff];
3740
get_page(vmf->page);
3841
return 0;
3942
}

0 commit comments

Comments
 (0)