]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix copy_page_range()'s handling of invalid pages
authorAndrew Morton <akpm@digeo.com>
Sat, 8 Mar 2003 11:24:48 +0000 (03:24 -0800)
committerJames Bottomley <jejb@raven.il.steeleye.com>
Sat, 8 Mar 2003 11:24:48 +0000 (03:24 -0800)
Patch from Xavier Bru  <Xavier.Bru@bull.net>

If copy_page_range encounters a pte which maps an invalid pageframe it will
proceed to try to add an rmap entry against that page.  This causes oopses
when an application which has mapped an IO device via /dev/mem forks.

Fix that up by correctly skipping the page_add_rmap() for these pte's.

mm/memory.c

index 2b0ab37d7a9f19cf86d8196948bcf33400df1657..1372176d3e5e80be1f0fe44a1263d08ecdc34b0e 100644 (file)
@@ -286,9 +286,16 @@ skip_copy_pte_range:
                                        goto cont_copy_pte_range_noset;
                                }
                                pfn = pte_pfn(pte);
+                               /* the pte points outside of valid memory, the
+                                * mapping is assumed to be good, meaningful
+                                * and not mapped via rmap - duplicate the
+                                * mapping as is.
+                                */
+                               if (!pfn_valid(pfn)) {
+                                       set_pte(dst_pte, pte);
+                                       goto cont_copy_pte_range_noset;
+                               }
                                page = pfn_to_page(pfn);
-                               if (!pfn_valid(pfn))
-                                       goto cont_copy_pte_range;
                                if (PageReserved(page))
                                        goto cont_copy_pte_range;