From patchwork Wed Jan 21 00:42:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SUGIOKA Toshinobu X-Patchwork-Id: 3376 X-Patchwork-Delegate: lethal@linux-sh.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0L0bdDj004693 for ; Tue, 20 Jan 2009 16:37:39 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756976AbZAUAmN (ORCPT ); Tue, 20 Jan 2009 19:42:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757431AbZAUAmN (ORCPT ); Tue, 20 Jan 2009 19:42:13 -0500 Received: from ns.itonet.jp ([61.199.205.34]:46233 "EHLO ns.itonet.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756976AbZAUAmM (ORCPT ); Tue, 20 Jan 2009 19:42:12 -0500 Received: from xpsugioka (xpsugioka.itonet.co.jp [192.168.0.200]) by ns.itonet.jp (8.11.6/8.11.6) with ESMTP id n0L0gAp05050; Wed, 21 Jan 2009 09:42:10 +0900 Message-Id: <4.2.0.58.J.20090121090500.00b5e5d0@router.itonet.co.jp> X-Sender: sugioka@gate.itonet.co.jp X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58.J Date: Wed, 21 Jan 2009 09:42:10 +0900 To: Paul Mundt From: SUGIOKA Toshinobu Subject: fix unaligned and nonexistent address handling Cc: linux-sh Mime-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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 Toshinobu --- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; } /*