Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310607
b: refs/heads/master
c: bc6ca7b
h: refs/heads/master
i:
  310605: e79fdb8
  310603: d690fc3
  310599: a862e0d
  310591: 01b4ff9
v: v3
  • Loading branch information
Arun Sharma authored and Ingo Molnar committed Jun 6, 2012
1 parent 22b51a7 commit 9737ba6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0b0d9cf6ec7bab91977da2d71c09157f110f7c2e
refs/heads/master: bc6ca7b342d5ae15c3ba3081fd40271b8039fb25
12 changes: 6 additions & 6 deletions trunk/arch/x86/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
#define segment_eq(a, b) ((a).seg == (b).seg)

#define user_addr_max() (current_thread_info()->addr_limit.seg)
#define __addr_ok(addr) \
((unsigned long __force)(addr) < \
(current_thread_info()->addr_limit.seg))
#define __addr_ok(addr) \
((unsigned long __force)(addr) < user_addr_max())

/*
* Test whether a block of memory is a valid user space address.
Expand All @@ -47,14 +46,14 @@
* This needs 33-bit (65-bit for x86_64) arithmetic. We have a carry...
*/

#define __range_not_ok(addr, size) \
#define __range_not_ok(addr, size, limit) \
({ \
unsigned long flag, roksum; \
__chk_user_ptr(addr); \
asm("add %3,%1 ; sbb %0,%0 ; cmp %1,%4 ; sbb $0,%0" \
: "=&r" (flag), "=r" (roksum) \
: "1" (addr), "g" ((long)(size)), \
"rm" (current_thread_info()->addr_limit.seg)); \
"rm" (limit)); \
flag; \
})

Expand All @@ -77,7 +76,8 @@
* checks that the pointer is in the user space range - after calling
* this function, memory access functions may still return -EFAULT.
*/
#define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
#define access_ok(type, addr, size) \
(likely(__range_not_ok(addr, size, user_addr_max()) == 0))

/*
* The exception table consists of pairs of addresses relative to the
Expand Down
12 changes: 12 additions & 0 deletions trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,12 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
dump_trace(NULL, regs, NULL, 0, &backtrace_ops, entry);
}

static inline int
valid_user_frame(const void __user *fp, unsigned long size)
{
return (__range_not_ok(fp, size, TASK_SIZE) == 0);
}

#ifdef CONFIG_COMPAT

#include <asm/compat.h>
Expand All @@ -1781,6 +1787,9 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
if (bytes != sizeof(frame))
break;

if (!valid_user_frame(fp, sizeof(frame)))
break;

perf_callchain_store(entry, frame.return_address);
fp = compat_ptr(frame.next_frame);
}
Expand Down Expand Up @@ -1824,6 +1833,9 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
if (bytes != sizeof(frame))
break;

if (!valid_user_frame(fp, sizeof(frame)))
break;

perf_callchain_store(entry, frame.return_address);
fp = frame.next_frame;
}
Expand Down

0 comments on commit 9737ba6

Please sign in to comment.