Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: tommy.christensen@eicon.com
To: Ralf Baechle <ralf@oss.sgi.com>
Cc: linux-mips@oss.sgi.com
Subject: Fixup in unaligned.c
Date: Mon, 29 Oct 2001 14:35:45 +0100	[thread overview]
Message-ID: <3BDD5B31.E12DE812@eicon.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1710 bytes --]


It seems we don't always handle bad user-mode pointers correctly.
If put_user is called with an unmapped AND unaligned address it
kills the current process instead of returning EFAULT.

The reason for this is that we do compute_return_epc() in do_ade()
before the exception table is searched, so we never get a match.

Below is a simple patch to fix it (attached as well).
The second part is not related, but it makes sense to only consult
the MF_FIXADE flag on exceptions originating from user-mode, right?

-Tommy


--- arch/mips/kernel/unaligned.c        2001/10/05 15:13:25     1.14
+++ arch/mips/kernel/unaligned.c        2001/10/29 12:39:56
@@ -353,12 +353,12 @@

 fault:
        /* Did we have an exception handler installed? */
-       fixup = search_exception_table(regs->cp0_epc);
+       fixup = search_exception_table(pc);
        if (fixup) {
                long new_epc;
-               new_epc = fixup_exception(dpf_reg, fixup, regs->cp0_epc);
+               new_epc = fixup_exception(dpf_reg, fixup, pc);
                printk(KERN_DEBUG "%s: Forwarding exception at [<%lx>]
(%lx)\n",
-                      current->comm, regs->cp0_epc, new_epc);
+                      current->comm, pc, new_epc);
                regs->cp0_epc = new_epc;
                return;
        }
@@ -408,7 +408,7 @@
        pc = regs->cp0_epc + ((regs->cp0_cause & CAUSEF_BD) ? 4 : 0);
        if (compute_return_epc(regs))
                return;
-       if ((current->thread.mflags & MF_FIXADE) == 0)
+       if (user_mode(regs) && (current->thread.mflags & MF_FIXADE) == 0)
                goto sigbus;

        emulate_load_store_insn(regs, regs->cp0_badvaddr, pc);
(See attached file: unaligned.c.patch.gz)

[-- Attachment #2: unaligned.c.patch.gz --]
[-- Type: application/octet-stream, Size: 569 bytes --]

             reply	other threads:[~2001-10-29 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-29 13:35 tommy.christensen [this message]
2001-10-30  9:17 ` Fixup in unaligned.c Ralf Baechle

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=3BDD5B31.E12DE812@eicon.com \
    --to=tommy.christensen@eicon.com \
    --cc=linux-mips@oss.sgi.com \
    --cc=ralf@oss.sgi.com \
    /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