]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Don't map the same page too much
authorHugh Dickins <hugh@veritas.com>
Tue, 11 Oct 2005 18:16:26 +0000 (19:16 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 11 Oct 2005 19:03:47 +0000 (12:03 -0700)
Refuse to install a page into a mapping if the mapping count is already
ridiculously large.

You probably cannot trigger this on 32-bit architectures, but on a
64-bit setup we should protect against it.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/fremap.c

index 3235fb77c1331499c18510ceda2dd87867a73a23..ab23a0673c351cc8ed263cfcea5f280c4736bbc9 100644 (file)
@@ -89,6 +89,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
        if (!page->mapping || page->index >= size)
                goto err_unlock;
+       err = -ENOMEM;
+       if (page_mapcount(page) > INT_MAX/2)
+               goto err_unlock;
 
        zap_pte(mm, vma, addr, pte);