]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.19.2/mm-memory.c-actually-remap-enough-memory.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.19.2 / mm-memory.c-actually-remap-enough-memory.patch
1 From 9cb12d7b4ccaa976f97ce0c5fd0f1b6a83bc2a75 Mon Sep 17 00:00:00 2001
2 From: Grazvydas Ignotas <notasas@gmail.com>
3 Date: Thu, 12 Feb 2015 15:00:19 -0800
4 Subject: mm/memory.c: actually remap enough memory
5
6 From: Grazvydas Ignotas <notasas@gmail.com>
7
8 commit 9cb12d7b4ccaa976f97ce0c5fd0f1b6a83bc2a75 upstream.
9
10 For whatever reason, generic_access_phys() only remaps one page, but
11 actually allows to access arbitrary size. It's quite easy to trigger
12 large reads, like printing out large structure with gdb, which leads to a
13 crash. Fix it by remapping correct size.
14
15 Fixes: 28b2ee20c7cb ("access_process_vm device memory infrastructure")
16 Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
17 Cc: Rik van Riel <riel@redhat.com>
18 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
19 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 mm/memory.c | 2 +-
24 1 file changed, 1 insertion(+), 1 deletion(-)
25
26 --- a/mm/memory.c
27 +++ b/mm/memory.c
28 @@ -3561,7 +3561,7 @@ int generic_access_phys(struct vm_area_s
29 if (follow_phys(vma, addr, write, &prot, &phys_addr))
30 return -EINVAL;
31
32 - maddr = ioremap_prot(phys_addr, PAGE_SIZE, prot);
33 + maddr = ioremap_prot(phys_addr, PAGE_ALIGN(len + offset), prot);
34 if (write)
35 memcpy_toio(maddr + offset, buf, len);
36 else