Skip to contentSkip to conversation

Bug in get_insn_opcode.

PATCH Carsten Langgaard 4 participants 5 messages Mar 2, 2001 – Mar 4, 2001 MIPS

lore
Share & tools
lore
#0 lore raw

There is a bug in the function get_insn_opcode in traps.c

As 'epc' is an int pointer here, it should only be increased by 1 (4 byte) and not by 4 (4*4 = 16 bytes).
See the patch below.

/Carsten

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /home/repository/sw/linux-2.4.0/arch/mips/kernel/traps.c,v retrieving revision 1.10

03/02 16:50:27 renamed from 02/28 13:46:43 1.10 +1 -1
diff -u -r1.10 traps.c
@@ -410,7 +410,7 @@
 
        epc = (unsigned int *) (unsigned long) regs->cp0_epc;
        if (regs->cp0_cause & CAUSEF_BD)
-               epc += 4;
+               epc++;
 
        if (verify_area(VERIFY_READ, epc, 4)) {
                force_sig(SIGSEGV, current);

Index: arch/mips64/kernel/traps.c
===================================================================
RCS file: /home/repository/sw/linux-2.4.0/arch/mips64/kernel/traps.c,v retrieving revision 1.5

03/02 16:50:13 renamed from 02/19 16:02:52 1.5 +1 -1
diff -u -r1.5 traps.c
@@ -371,7 +371,7 @@
 
        epc = (unsigned int *) (unsigned long) regs->cp0_epc;
        if (regs->cp0_cause & CAUSEF_BD)
-               epc += 4;
+               epc++;
 
        if (verify_area(VERIFY_READ, epc, 4)) {
                force_sig(SIGSEGV, current);

--

_    _ ____  ___   Carsten Langgaard   Mailto:[email protected]
|\  /|||___)(___   MIPS Denmark        Direct: +45 4486 5527
| \/ |||    ____)  Lautrupvang 4B      Switch: +45 4486 5555
  TECHNOLOGIES     2750 Ballerup       Fax...: +45 4486 5556
                   Denmark             http://www.mips.com
#1 lore raw
Quoted 8 lines · Carsten Langgaard

There is a bug in the function get_insn_opcode in traps.c

As 'epc' is an int pointer here, it should only be increased by 1 (4 byte) and not by 4 (4*4 = 16 bytes).
See the patch below.

/Carsten

Good catch!

I am surprised that trap on branch delay slot is rare that we only discover this bug now ...

Jun

#2 lore raw
In reply to Carsten Langgaard

03/02 16:50:27

Quoted 18 lines · Carsten Langgaard

Date: Fri, 02 Mar 2001 17:56:48 +0100
From: Carsten Langgaard <[email protected]>
To: [email protected]
Subject: Bug in get_insn_opcode.

There is a bug in the function get_insn_opcode in traps.c

As 'epc' is an int pointer here, it should only be increased by 1 (4 byte) and not by 4 (4*4 = 16 bytes).
See the patch below.

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /home/repository/sw/linux-2.4.0/arch/mips/kernel/traps.c,v retrieving revision 1.10
diff -u -r1.10 traps.c

03/02 16:50:27 renamed from 02/28 13:46:43 1.10 +0 -0

Patch will behave (un-)funny on a cvs diff generated patch like this which lacks full pathnames in the --- and +++ lines. Patches for this behaviour are available on ftp.cyclic.com (so it still exists ...) or in more recent cvs rpms.

Applied anyway, of course.

Ralf

#3 lore raw
Quoted 13 lines · Ralf Baechle

03/02 16:50:27

Quoted 7 lines · Carsten Langgaard

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /home/repository/sw/linux-2.4.0/arch/mips/kernel/traps.c,v retrieving revision 1.10
diff -u -r1.10 traps.c

03/02 16:50:27 renamed from 02/28 13:46:43 1.10 +0 -0

Patch will behave (un-)funny on a cvs diff generated patch like this which lacks full pathnames in the --- and +++ lines. Patches for this behaviour are available on ftp.cyclic.com (so it still exists ...) or in more recent cvs rpms.

Isn't patch supposed to look at the `Index' line?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw
Quoted 13 lines · Geert Uytterhoeven
Quoted 4 lines
Quoted 4 lines

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /home/repository/sw/linux-2.4.0/arch/mips/kernel/traps.c,v retrieving revision 1.10

Quoted 8 lines

03/02 16:50:27

Quoted 3 lines

diff -u -r1.10 traps.c

03/02 16:50:27 renamed from 02/28 13:46:43 1.10 +0 -0

Patch will behave (un-)funny on a cvs diff generated patch like this which lacks full pathnames in the --- and +++ lines. Patches for this behaviour are available on ftp.cyclic.com (so it still exists ...) or in more recent cvs rpms.

Quoted 1 line

Isn't patch supposed to look at the `Index' line?

Only when the environment variable POSIXLY_CORRECT is set to y which has a ton of other unwanted side effects, so patch would need wrapper scripts or what not else.

Ralf