From: Michael Ellerman <michael@ellerman.id.au>
To: Anton Blanchard <anton@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc: Check end of stack canary at oops time
Date: Wed, 25 Aug 2010 11:29:38 +1000 [thread overview]
Message-ID: <1282699778.21145.54.camel@concordia> (raw)
In-Reply-To: <20100824231528.GC28360@kryten>
[-- Attachment #1: Type: text/plain, Size: 1678 bytes --]
On Wed, 2010-08-25 at 09:15 +1000, Anton Blanchard wrote:
> Add a check for the stack canary when we oops, similar to x86. This should make
> it clear that we overran our stack:
>
> Unable to handle kernel paging request for data at address 0x24652f63700ac689
> Faulting instruction address: 0xc000000000063d24
> Thread overran stack, or stack corrupted
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
>
> Index: powerpc.git/arch/powerpc/mm/fault.c
> ===================================================================
> --- powerpc.git.orig/arch/powerpc/mm/fault.c 2010-08-25 08:41:08.230086186 +1000
> +++ powerpc.git/arch/powerpc/mm/fault.c 2010-08-25 09:12:38.276553103 +1000
> @@ -30,6 +30,7 @@
> #include <linux/kprobes.h>
> #include <linux/kdebug.h>
> #include <linux/perf_event.h>
> +#include <linux/magic.h>
>
> #include <asm/firmware.h>
> #include <asm/page.h>
> @@ -385,6 +386,7 @@ do_sigbus:
> void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
> {
> const struct exception_table_entry *entry;
> + unsigned long *stackend;
>
> /* Are we prepared to handle this fault? */
> if ((entry = search_exception_tables(regs->nip)) != NULL) {
> @@ -413,5 +415,9 @@ void bad_page_fault(struct pt_regs *regs
> printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n",
> regs->nip);
>
> + stackend = end_of_stack(current);
> + if (current != &init_task && *stackend != STACK_END_MAGIC)
> + printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");
The check for init is just because we haven't set the magic value for
init's stack right? But we could.
cheers
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2010-08-25 1:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-24 23:15 [PATCH] powerpc: Check end of stack canary at oops time Anton Blanchard
2010-08-25 1:29 ` Michael Ellerman [this message]
2010-08-25 1:51 ` Anton Blanchard
2010-08-30 0:18 ` Benjamin Herrenschmidt
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=1282699778.21145.54.camel@concordia \
--to=michael@ellerman.id.au \
--cc=anton@samba.org \
--cc=linuxppc-dev@lists.ozlabs.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