]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
parisc: Fix backtrace on PA-RISC
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 28 Jun 2011 22:48:19 +0000 (00:48 +0200)
committerHelge Deller <deller@gmx.de>
Sat, 4 Jun 2016 20:05:07 +0000 (22:05 +0200)
commitbe24a89700eef61bedaba40f3b05ef07f5806e38
tree818288f6657c04b9d2ec91f1572ab78c49ef7bb8
parent049ec1b5a76d34a6980cccdb7c0baeb4eed7a993
parisc: Fix backtrace on PA-RISC

This patch fixes backtrace on PA-RISC

There were several problems:

1) The code that decodes instructions handles instructions that subtract
from the stack pointer incorrectly. If the instruction subtracts the
number X from the stack pointer the code increases the frame size by
(0x100000000-X).  This results in invalid accesses to memory and
recursive page faults.

2) Because gcc reorders blocks, handling instructions that subtract from
the frame pointer is incorrect. For example, this function
int f(int a)
{
if (__builtin_expect(a, 1))
return a;
g();
return a;
}
is compiled in such a way, that the code that decreases the stack
pointer for the first "return a" is placed before the code for "g" call.
If we recognize this decrement, we mistakenly believe that the frame
size for the "g" call is zero.

To fix problems 1) and 2), the patch doesn't recognize instructions that
decrease the stack pointer at all. To further safeguard the unwind code
against nonsense values, we don't allow frame size larger than
Total_frame_size.

3) The backtrace is not locked. If stack dump races with module unload,
invalid table can be accessed.

This patch adds a spinlock when processing module tables.

Note, that for correct backtrace, you need recent binutils.
Binutils 2.18 from Debian 5 produce garbage unwind tables.
Binutils 2.21 work better (it sometimes forgets function frames, but at
least it doesn't generate garbage).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/kernel/unwind.c