All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] kmemcheck: fix dynamic enable/disable
@ 2008-11-24 12:20 Vegard Nossum
  2008-11-24 12:43 ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Vegard Nossum @ 2008-11-24 12:20 UTC (permalink / raw)
  To: Sitsofe Wheeler, linux-kernel; +Cc: Ingo Molnar, Pekka Enberg

(Ingo: Will send pull request for this later :-))


>From 6f505f59011e565c2dbb7a220702feb0447cc854 Mon Sep 17 00:00:00 2001
From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Mon, 24 Nov 2008 11:52:05 +0100
Subject: [PATCH] kmemcheck: fix dynamic enable/disable

On Fri, Oct 10, 2008 at 1:40 PM, Sitsofe Wheeler <sitsofe@yahoo.com> wrote:
> I received a lot of errors after manually enabling kmemcheck
> in /proc (it had been turned off due to oneshot mode). It
> might be a good idea to put a warning that errrors found after
> enabling it at any time other than boot might be spurious.

Fixed. This was the problem: Instructions with multiple address
operands could look up the shadow of an address that had
previously been un-hidden. After handling the memory access, the
page would get hidden again. The fix is to verify that the page
is present before we return a shadow pointer.

Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
 arch/x86/mm/kmemcheck/kmemcheck.c |   10 ++++++++++
 arch/x86/mm/kmemcheck/shadow.c    |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
index 056b4f1..12a4bbd 100644
--- a/arch/x86/mm/kmemcheck/kmemcheck.c
+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
@@ -707,6 +707,16 @@ bool kmemcheck_trap(struct pt_regs *regs)
 	}
 
 	/*
+	 * At this point, we know that the trap was kmemcheck's. However, if
+	 * kmemcheck was disabled, we need to return immediately (and stop
+	 * emulating the REP instruction).
+	 */
+	if (!kmemcheck_enabled) {
+		kmemcheck_hide(regs);
+		return true;
+	}
+
+	/*
 	 * We're emulating a REP MOVS/STOS instruction. Are we done yet?
 	 * Of course, 64-bit needs to handle CX/ECX/RCX differently...
 	 */
diff --git a/arch/x86/mm/kmemcheck/shadow.c b/arch/x86/mm/kmemcheck/shadow.c
index 196dddc..62a0f63 100644
--- a/arch/x86/mm/kmemcheck/shadow.c
+++ b/arch/x86/mm/kmemcheck/shadow.c
@@ -27,6 +27,8 @@ void *kmemcheck_shadow_lookup(unsigned long address)
 	pte = kmemcheck_pte_lookup(address);
 	if (!pte)
 		return NULL;
+	if (pte_present(*pte))
+		return NULL;
 
 	page = virt_to_page(address);
 	if (!page->shadow)
-- 
1.5.6.5


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

end of thread, other threads:[~2008-11-24 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-24 12:20 [PATCH -tip] kmemcheck: fix dynamic enable/disable Vegard Nossum
2008-11-24 12:43 ` Pekka Enberg
2008-11-24 15:00   ` Vegard Nossum

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.