From: Sonic Zhang Date: Wed, 27 Sep 2006 08:50:17 +0000 (-0700) Subject: [PATCH] Check if start address is in vma region in NOMMU function get_user_pages() X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=910e46da4b4e93d56ffea318c64afa41868d5e6d;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.git [PATCH] Check if start address is in vma region in NOMMU function get_user_pages() In NOMMU arch, if run "cat /proc/self/mem", data from physical address 0 are read. This behavior is different from MMU arch. In IA32, message "cat: /proc/self/mem: Input/output error" is reported. This issue is rootcaused by not validate the start address in NOMMU function get_user_pages(). Following patch solves this issue. Signed-off-by: Sonic Zhang Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/nommu.c b/mm/nommu.c index 00ffa974c90c..2af50831183f 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -129,16 +129,20 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, struct page **pages, struct vm_area_struct **vmas) { int i; - static struct vm_area_struct dummy_vma; + struct vm_area_struct *vma; for (i = 0; i < len; i++) { + vma = find_vma(mm, start); + if(!vma) + return i ? : -EFAULT; + if (pages) { pages[i] = virt_to_page(start); if (pages[i]) page_cache_get(pages[i]); } if (vmas) - vmas[i] = &dummy_vma; + vmas[i] = vma; start += PAGE_SIZE; } return(i);