Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211908
b: refs/heads/master
c: f6dedec
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Robert Richter committed Oct 1, 2010
1 parent de227ab commit d4e28c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 40c6b3cb64cd1d02322df5f729cca25084580f40
refs/heads/master: f6dedecc37164a58bb80ae2ed9d204669ffc4850
53 changes: 53 additions & 0 deletions trunk/arch/x86/oprofile/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <asm/ptrace.h>
#include <asm/uaccess.h>
#include <asm/stacktrace.h>
#include <linux/compat.h>

static void backtrace_warning_symbol(void *data, char *msg,
unsigned long symbol)
Expand Down Expand Up @@ -48,6 +49,55 @@ static struct stacktrace_ops backtrace_ops = {
.walk_stack = print_context_stack,
};

#ifdef CONFIG_COMPAT
static struct stack_frame_ia32 *
dump_user_backtrace_32(struct stack_frame_ia32 *head)
{
struct stack_frame_ia32 bufhead[2];
struct stack_frame_ia32 *fp;

/* Also check accessibility of one struct frame_head beyond */
if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
return NULL;
if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
return NULL;

fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);

oprofile_add_trace(bufhead[0].return_address);

/* frame pointers should strictly progress back up the stack
* (towards higher addresses) */
if (head >= fp)
return NULL;

return fp;
}

static inline int
x86_backtrace_32(struct pt_regs * const regs, unsigned int depth)
{
struct stack_frame_ia32 *head;

/* User process is 32-bit */
if (!current || !test_thread_flag(TIF_IA32))
return 0;

head = (struct stack_frame_ia32 *) regs->bp;
while (depth-- && head)
head = dump_user_backtrace_32(head);

return 1;
}

#else
static inline int
x86_backtrace_32(struct pt_regs * const regs, unsigned int depth)
{
return 0;
}
#endif /* CONFIG_COMPAT */

static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
{
struct stack_frame bufhead[2];
Expand Down Expand Up @@ -81,6 +131,9 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
return;
}

if (x86_backtrace_32(regs, depth))
return;

while (depth-- && head)
head = dump_user_backtrace(head);
}

0 comments on commit d4e28c4

Please sign in to comment.