All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mremap move ZERO_PAGE fix
@ 2005-09-24 10:30 Hugh Dickins
  2005-09-25  1:21 ` Nick Piggin
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2005-09-24 10:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Nick Piggin, linux-kernel

Fix nasty little bug we've missed in Nick's mremap move ZERO_PAGE patch.
The "pte" at that point may be a swap entry or a pte_file entry: we must
check pte_present before perhaps corrupting such an entry.

Patch below against 2.6.14-rc2-mm1, but the same bug is in 2.6.14-rc2's
mm/mremap.c, and more dangerous there since it's affecting all arches:
I think the safest course is to send Nick's patch and Yoichi's build fix
and this fix (build tested) on to Linus - so only MIPS can be affected.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.14-rc2-mm1/include/asm-generic/pgtable.h	2005-09-22 12:32:00.000000000 +0100
+++ linux/include/asm-generic/pgtable.h	2005-09-24 10:51:41.000000000 +0100
@@ -164,7 +164,8 @@ static inline void ptep_set_wrprotect(st
 #define move_pte(pte, prot, old_addr, new_addr)				\
 ({									\
  	pte_t newpte = (pte);						\
-	if (pfn_valid(pte_pfn(pte)) && pte_page(pte) == ZERO_PAGE(old_addr)) \
+	if (pte_present(pte) && pfn_valid(pte_pfn(pte)) &&		\
+			pte_page(pte) == ZERO_PAGE(old_addr))		\
 		newpte = mk_pte(ZERO_PAGE(new_addr), (prot));		\
 	newpte;								\
 })

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-25  1:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-24 10:30 [PATCH] mremap move ZERO_PAGE fix Hugh Dickins
2005-09-25  1:21 ` Nick Piggin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.