linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Make alignment exception always check exception table
@ 2006-11-01  3:09 Benjamin Herrenschmidt
  2006-11-01  3:42 ` [PATCH] powerpc: Make alignment exception always check exception table (#2) Benjamin Herrenschmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2006-11-01  3:09 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev list, Greg KH

The alignment exception used to only check the exception table for
-EFAULT, not for other errors. That opens an oops window if we can
coerce the kernel into getting an alignment exception for other reasons
in what would normally be a user-protected accessor, which can be done
via some of the futex ops. This fixes it by always checking the
exception tables.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

This is 2.6.19 material and should probably go into stable as well.
(Greg: take it if paulus acks it and it applies :)

Index: linux-work/arch/powerpc/kernel/traps.c
===================================================================
--- linux-work.orig/arch/powerpc/kernel/traps.c	2006-10-23 14:41:37.000000000 +1000
+++ linux-work/arch/powerpc/kernel/traps.c	2006-10-30 13:59:41.000000000 +1100
@@ -843,7 +843,7 @@ void __kprobes program_check_exception(s
 
 void alignment_exception(struct pt_regs *regs)
 {
-	int fixed = 0;
+	int sig, fixed = 0;
 
 	/* we don't implement logging of alignment exceptions */
 	if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
@@ -856,15 +856,11 @@ void alignment_exception(struct pt_regs 
 	}
 
 	/* Operand address was bad */
-	if (fixed == -EFAULT) {
-		if (user_mode(regs))
-			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
-		else
-			/* Search exception table */
-			bad_page_fault(regs, regs->dar, SIGSEGV);
-		return;
-	}
-	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
+	sig = fixed == -EFAULT ? SIGSEGV : SIGBUS;
+	if (user_mode(regs))
+		_exception(sig, regs, SEGV_ACCERR, regs->dar);
+	else
+		bad_page_fault(regs, regs->dar, sig);
 }
 
 void StackOverflow(struct pt_regs *regs)

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

* [PATCH] powerpc: Make alignment exception always check exception table (#2)
  2006-11-01  3:09 [PATCH] powerpc: Make alignment exception always check exception table Benjamin Herrenschmidt
@ 2006-11-01  3:42 ` Benjamin Herrenschmidt
  2006-11-01  4:11 ` [PATCH] powerpc: Make alignment exception always check exception table (#3) Benjamin Herrenschmidt
  2006-11-01  6:34 ` [PATCH] powerpc: Make alignment exception always check exception table Greg KH
  2 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2006-11-01  3:42 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev list, Greg KH

The alignment exception used to only check the exception table for
-EFAULT, not for other errors. That opens an oops window if we can
coerce the kernel into getting an alignment exception for other reasons
in what would normally be a user-protected accessor, which can be done
via some of the futex ops. This fixes it by always checking the
exception tables.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

Paul: this version also fixes arch/ppc

This is 2.6.19 material and should probably go into stable as well.
(Greg: take it if paulus acks it and it applies :)

Index: linux-work/arch/powerpc/kernel/traps.c
===================================================================
--- linux-work.orig/arch/powerpc/kernel/traps.c	2006-10-23 14:41:37.000000000 +1000
+++ linux-work/arch/powerpc/kernel/traps.c	2006-10-30 13:59:41.000000000 +1100
@@ -843,7 +843,7 @@ void __kprobes program_check_exception(s
 
 void alignment_exception(struct pt_regs *regs)
 {
-	int fixed = 0;
+	int sig, fixed = 0;
 
 	/* we don't implement logging of alignment exceptions */
 	if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
@@ -856,15 +856,11 @@ void alignment_exception(struct pt_regs 
 	}
 
 	/* Operand address was bad */
-	if (fixed == -EFAULT) {
-		if (user_mode(regs))
-			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
-		else
-			/* Search exception table */
-			bad_page_fault(regs, regs->dar, SIGSEGV);
-		return;
-	}
-	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
+	sig = fixed == -EFAULT ? SIGSEGV : SIGBUS;
+	if (user_mode(regs))
+		_exception(sig, regs, SEGV_ACCERR, regs->dar);
+	else
+		bad_page_fault(regs, regs->dar, sig);
 }
 
 void StackOverflow(struct pt_regs *regs)
Index: linux-work/arch/ppc/kernel/traps.c
===================================================================
--- linux-work.orig/arch/ppc/kernel/traps.c	2006-10-06 13:47:55.000000000 +1000
+++ linux-work/arch/ppc/kernel/traps.c	2006-11-01 14:39:44.000000000 +1100
@@ -708,7 +708,7 @@ void single_step_exception(struct pt_reg
 
 void alignment_exception(struct pt_regs *regs)
 {
-	int fixed;
+	int sig, fixed = 0;
 
 	fixed = fix_alignment(regs);
 	if (fixed == 1) {
@@ -716,15 +716,11 @@ void alignment_exception(struct pt_regs 
 		emulate_single_step(regs);
 		return;
 	}
-	if (fixed == -EFAULT) {
-		/* fixed == -EFAULT means the operand address was bad */
-		if (user_mode(regs))
-			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
-		else
-			bad_page_fault(regs, regs->dar, SIGSEGV);
-		return;
-	}
-	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
+	sig = fixed == -EFAULT ? SIGSEGV : SIGBUS;
+	if (user_mode(regs))
+		_exception(sig, regs, SEGV_ACCERR, regs->dar);
+	else
+		bad_page_fault(regs, regs->dar, sig);
 }
 
 void StackOverflow(struct pt_regs *regs)

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

* [PATCH] powerpc: Make alignment exception always check exception table (#3)
  2006-11-01  3:09 [PATCH] powerpc: Make alignment exception always check exception table Benjamin Herrenschmidt
  2006-11-01  3:42 ` [PATCH] powerpc: Make alignment exception always check exception table (#2) Benjamin Herrenschmidt
@ 2006-11-01  4:11 ` Benjamin Herrenschmidt
  2006-11-01  6:34 ` [PATCH] powerpc: Make alignment exception always check exception table Greg KH
  2 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2006-11-01  4:11 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev list, Greg KH

The alignment exception used to only check the exception table for
-EFAULT, not for other errors. That opens an oops window if we can
coerce the kernel into getting an alignment exception for other reasons
in what would normally be a user-protected accessor, which can be done
via some of the futex ops. This fixes it by always checking the
exception tables.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

Paul: this version sets the correct si_code

This is 2.6.19 material and should probably go into stable as well.
(Greg: take it if paulus acks it and it applies :)

Index: linux-work/arch/powerpc/kernel/traps.c
===================================================================
--- linux-work.orig/arch/powerpc/kernel/traps.c	2006-11-01 14:59:07.000000000 +1100
+++ linux-work/arch/powerpc/kernel/traps.c	2006-11-01 15:01:06.000000000 +1100
@@ -843,7 +843,7 @@ void __kprobes program_check_exception(s
 
 void alignment_exception(struct pt_regs *regs)
 {
-	int fixed = 0;
+	int sig, code, fixed = 0;
 
 	/* we don't implement logging of alignment exceptions */
 	if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
@@ -857,14 +857,16 @@ void alignment_exception(struct pt_regs 
 
 	/* Operand address was bad */
 	if (fixed == -EFAULT) {
-		if (user_mode(regs))
-			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
-		else
-			/* Search exception table */
-			bad_page_fault(regs, regs->dar, SIGSEGV);
-		return;
+		sig = SIGSEGV;
+		code = SEGV_ACCERR;
+	} else {
+		sig = SIGBUS;
+		code = BUS_ADRALN;
 	}
-	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
+	if (user_mode(regs))
+		_exception(sig, regs, code, regs->dar);
+	else
+		bad_page_fault(regs, regs->dar, sig);
 }
 
 void StackOverflow(struct pt_regs *regs)
Index: linux-work/arch/ppc/kernel/traps.c
===================================================================
--- linux-work.orig/arch/ppc/kernel/traps.c	2006-11-01 14:59:07.000000000 +1100
+++ linux-work/arch/ppc/kernel/traps.c	2006-11-01 15:01:32.000000000 +1100
@@ -708,7 +708,7 @@ void single_step_exception(struct pt_reg
 
 void alignment_exception(struct pt_regs *regs)
 {
-	int fixed;
+	int sig, code, fixed = 0;
 
 	fixed = fix_alignment(regs);
 	if (fixed == 1) {
@@ -717,14 +717,16 @@ void alignment_exception(struct pt_regs 
 		return;
 	}
 	if (fixed == -EFAULT) {
-		/* fixed == -EFAULT means the operand address was bad */
-		if (user_mode(regs))
-			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
-		else
-			bad_page_fault(regs, regs->dar, SIGSEGV);
-		return;
+		sig = SIGSEGV;
+		code = SEGV_ACCERR;
+	} else {
+		sig = SIGBUS;
+		code = BUS_ADRALN;
 	}
-	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
+	if (user_mode(regs))
+		_exception(sig, regs, code, regs->dar);
+	else
+		bad_page_fault(regs, regs->dar, sig);
 }
 
 void StackOverflow(struct pt_regs *regs)

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

* Re: [PATCH] powerpc: Make alignment exception always check exception table
  2006-11-01  3:09 [PATCH] powerpc: Make alignment exception always check exception table Benjamin Herrenschmidt
  2006-11-01  3:42 ` [PATCH] powerpc: Make alignment exception always check exception table (#2) Benjamin Herrenschmidt
  2006-11-01  4:11 ` [PATCH] powerpc: Make alignment exception always check exception table (#3) Benjamin Herrenschmidt
@ 2006-11-01  6:34 ` Greg KH
  2006-11-01 20:43   ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-11-01  6:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, Paul Mackerras

On Wed, Nov 01, 2006 at 02:09:30PM +1100, Benjamin Herrenschmidt wrote:
> The alignment exception used to only check the exception table for
> -EFAULT, not for other errors. That opens an oops window if we can
> coerce the kernel into getting an alignment exception for other reasons
> in what would normally be a user-protected accessor, which can be done
> via some of the futex ops. This fixes it by always checking the
> exception tables.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 
> This is 2.6.19 material and should probably go into stable as well.
> (Greg: take it if paulus acks it and it applies :)

Please forward the final patch (which ever version it is :) to the
stable@kernel.org address when this goes into mainline.

thanks,

greg k-h

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

* Re: [PATCH] powerpc: Make alignment exception always check exception table
  2006-11-01  6:34 ` [PATCH] powerpc: Make alignment exception always check exception table Greg KH
@ 2006-11-01 20:43   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2006-11-01 20:43 UTC (permalink / raw)
  To: Greg KH; +Cc: linuxppc-dev list, Paul Mackerras

On Tue, 2006-10-31 at 22:34 -0800, Greg KH wrote:
> On Wed, Nov 01, 2006 at 02:09:30PM +1100, Benjamin Herrenschmidt wrote:
> > The alignment exception used to only check the exception table for
> > -EFAULT, not for other errors. That opens an oops window if we can
> > coerce the kernel into getting an alignment exception for other reasons
> > in what would normally be a user-protected accessor, which can be done
> > via some of the futex ops. This fixes it by always checking the
> > exception tables.
> > 
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> > 
> > This is 2.6.19 material and should probably go into stable as well.
> > (Greg: take it if paulus acks it and it applies :)
> 
> Please forward the final patch (which ever version it is :) to the
> stable@kernel.org address when this goes into mainline.

Ok, will do. I wan't sure what the proper procedure was.

Cheers,
Ben.

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

end of thread, other threads:[~2006-11-01 20:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-01  3:09 [PATCH] powerpc: Make alignment exception always check exception table Benjamin Herrenschmidt
2006-11-01  3:42 ` [PATCH] powerpc: Make alignment exception always check exception table (#2) Benjamin Herrenschmidt
2006-11-01  4:11 ` [PATCH] powerpc: Make alignment exception always check exception table (#3) Benjamin Herrenschmidt
2006-11-01  6:34 ` [PATCH] powerpc: Make alignment exception always check exception table Greg KH
2006-11-01 20:43   ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).