Re: [patch][rfc] nommu: reverse mappings for nommu to solve get_user_pagesproblem

From: Nick Piggin
Date: Fri Mar 10 2006 - 23:52:20 EST


Nick Piggin wrote:

int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
unsigned long start, int len, int write, int force,
struct page **pages, struct vm_area_struct **vmas)
{
int i;
- static struct vm_area_struct dummy_vma;
+ struct page *__page;
+ static struct vm_area_struct *__vma;
+ unsigned long addr = start;
for (i = 0; i < len; i++) {
+ __vma = find_vma(mm, addr);
+ if (!__vma)
+ goto out_failed;
+
+ __page = virt_to_page(addr);
+ if (!__page)
+ goto out_failed;
+
+ BUG_ON(page_vma(__page) != __vma);
+

Actually this check is leftover from a previous version. I think it
needs to be removed.

if (pages) {
- pages[i] = virt_to_page(start);
- if (pages[i])
- page_cache_get(pages[i]);
+ if (!__page->mapping) {
+ printk(KERN_INFO "get_user_pages on unaligned"
+ "anonymous page unsupported\n"); dump_stack();
+ goto out_failed;
+ }
+

And this could trigger for file-backed pages that have been truncated meanwhile
I think. It wouldn't be a problem for a simple test-run, but does need to be
reworked slightly in order to be correct. Sub-page anonymous mappings cause a
lot of headaches :)

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/