public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: lguest <lguest@ozlabs.org>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix lguest page-pinning logic ("lguest: bad stack page 0xc057a000")
Date: Thu, 30 Aug 2007 06:35:08 +1000	[thread overview]
Message-ID: <1188419708.5531.137.camel@localhost.localdomain> (raw)

If the stack pointer is 0xc057a000, then the first stack page is at
0xc0579000 (the stack pointer is decremented before use).  Not
calculating this correctly caused guests with CONFIG_DEBUG_PAGEALLOC=y
to be killed with a "bad stack page" message: the initial kernel stack
was just proceeding the .smp_locks section which
CONFIG_DEBUG_PAGEALLOC marks read-only when freeing.

Thanks to Frederik Deweerdt for the bug report!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/lguest/interrupts_and_traps.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

===================================================================
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -270,8 +270,11 @@ void pin_stack_pages(struct lguest *lg)
 	/* Depending on the CONFIG_4KSTACKS option, the Guest can have one or
 	 * two pages of stack space. */
 	for (i = 0; i < lg->stack_pages; i++)
-		/* The stack grows *upwards*, hence the subtraction */
-		pin_page(lg, lg->esp1 - i * PAGE_SIZE);
+		/* The stack grows *upwards*, so the address we're given is the
+		 * start of the page after the kernel stack.  Subtract one to
+		 * get back onto the first stack page, and keep subtracting to
+		 * get to the rest of the stack pages. */
+		pin_page(lg, lg->esp1 - 1 - i * PAGE_SIZE);
 }
 
 /* Direct traps also mean that we need to know whenever the Guest wants to use



             reply	other threads:[~2007-08-29 20:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-29 20:35 Rusty Russell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-08-22  9:06 2.6.23-rc3-mm1 Andrew Morton
2007-08-22 20:25 ` [-mm patch] enforce noreplace-smp in alternative_instructions() Frederik Deweerdt
2007-08-23 21:50   ` Andrew Morton
2007-08-24  6:04     ` Frederik Deweerdt
2007-08-24  6:46       ` Jeremy Fitzhardinge
2007-08-24  8:22         ` Frederik Deweerdt
2007-08-25 12:07           ` Rusty Russell
2007-08-25 12:23             ` Frederik Deweerdt
2007-08-25 21:14               ` Frederik Deweerdt
2007-08-27 16:09                 ` [PATCH] Fix lguest page-pinning logic ("lguest: bad stack page 0xc057a000") Rusty Russell
2007-08-30 16:38                   ` Frederik Deweerdt
2007-08-30 22:12                     ` Rusty Russell

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=1188419708.5531.137.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=lguest@ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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