All of lore.kernel.org
 help / color / mirror / Atom feed
From: SUGIOKA Toshinobu <sugioka@itonet.co.jp>
To: linux-sh@vger.kernel.org
Subject: fix unaligned and nonexistent address handling
Date: Wed, 21 Jan 2009 00:42:10 +0000	[thread overview]
Message-ID: <4.2.0.58.J.20090121090500.00b5e5d0@router.itonet.co.jp> (raw)

unaligned and nonexistent address causes wrong exception
handling in traps_32.c(handle_unaligned_access).

'handle_unalinged_ins' should return -EFAULT if address error
is fixed up with kernel exception table, otherwise 
'handle_unaligned_access' increases already fixed program counter
and then crash.

for example
   ioctl(fd, TCGETA, (struct termio *)-1)
never return and stay in TASK_UNINTERRUPTIBLE state forever
in my kernel.

Signed-off-by: SUGIOKA Toshinobu <sugioka@itonet.co.jp>

diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index c0aa3d8..60dcf87 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -125,20 +125,18 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs,
  * - userspace errors just cause EFAULT to be returned, resulting in SEGV
  * - kernel/userspace interfaces cause a jump to an appropriate handler
  * - other kernel errors are bad
- * - return 0 if fixed-up, -EFAULT if non-fatal (to the kernel) fault
  */
-static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
+static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
 {
 	if (!user_mode(regs)) {
 		const struct exception_table_entry *fixup;
 		fixup = search_exception_tables(regs->pc);
 		if (fixup) {
 			regs->pc = fixup->fixup;
-			return 0;
+			return;
 		}
 		die(str, regs, err);
 	}
-	return -EFAULT;
 }
 
 static inline void sign_extend(unsigned int count, unsigned char *dst)
@@ -314,7 +312,8 @@ static int handle_unaligned_ins(opcode_t instruction, struct pt_regs *regs,
 	/* Argh. Address not only misaligned but also non-existent.
 	 * Raise an EFAULT and see if it's trapped
 	 */
-	return die_if_no_fixup("Fault in unaligned fixup", regs, 0);
+	die_if_no_fixup("Fault in unaligned fixup", regs, 0);
+	return -EFAULT;
 }
 
 /*

SUGIOKA Toshinobu


             reply	other threads:[~2009-01-21  0:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21  0:42 SUGIOKA Toshinobu [this message]
2009-01-21 10:37 ` fix unaligned and nonexistent address handling Paul Mundt

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=4.2.0.58.J.20090121090500.00b5e5d0@router.itonet.co.jp \
    --to=sugioka@itonet.co.jp \
    --cc=linux-sh@vger.kernel.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 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.