Skip to content

Commit 463fb5a

Browse files
notazsashalevin
authored andcommitted
mm/memory.c: actually remap enough memory
commit 9cb12d7 upstream. For whatever reason, generic_access_phys() only remaps one page, but actually allows to access arbitrary size. It's quite easy to trigger large reads, like printing out large structure with gdb, which leads to a crash. Fix it by remapping correct size. Fixes: 28b2ee2 ("access_process_vm device memory infrastructure") Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 42af81d commit 463fb5a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎mm/memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3558,7 +3558,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
35583558
if (follow_phys(vma, addr, write, &prot, &phys_addr))
35593559
return -EINVAL;
35603560

3561-
maddr = ioremap_prot(phys_addr, PAGE_SIZE, prot);
3561+
maddr = ioremap_prot(phys_addr, PAGE_ALIGN(len + offset), prot);
35623562
if (write)
35633563
memcpy_toio(maddr + offset, buf, len);
35643564
else

0 commit comments

Comments
 (0)