mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>, linux-kernel@vger.kernel.org
Subject: [PATCH] mremap move ZERO_PAGE fix
Date: Sat, 24 Sep 2005 11:30:43 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0509241127420.11579@goblin.wat.veritas.com> (raw)

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;								\
 })

             reply	other threads:[~2005-09-24 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-24 10:30 Hugh Dickins [this message]
2005-09-25  1:21 ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0509241127420.11579@goblin.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®