summaryrefslogtreecommitdiffstats
path: root/arch/sparc/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-25 13:54:37 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-25 13:54:37 -0700
commit77d431641e2b402fe98af3540e8fb1c77bf92c25 (patch)
treee12e03874dab30dc42247fa130dcd09d719a9bb1 /arch/sparc/include
parent55a7d4b85ca1f723d26b8956e8faeff730d0d240 (diff)
parentf01cae4e1a9bc845ee125cdb763ccf18298d3fdc (diff)
downloadlinux-77d431641e2b402fe98af3540e8fb1c77bf92c25.tar.bz2
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull sparc fixes from David Miller: "Sparc perf stack traversal fixes from David Ahern" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc64: perf: Use UREG_FP rather than UREG_I6 sparc64: perf: Add sanity checking on addresses in user stack sparc64: Convert BUG_ON to warning sparc: perf: Disable pagefaults while walking userspace stacks
Diffstat (limited to 'arch/sparc/include')
-rw-r--r--arch/sparc/include/asm/uaccess_64.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index a35194b7dba0..ea6e9a20f3ff 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -49,6 +49,28 @@ do { \
__asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \
} while(0)
+/*
+ * Test whether a block of memory is a valid user space address.
+ * Returns 0 if the range is valid, nonzero otherwise.
+ */
+static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, unsigned long limit)
+{
+ if (__builtin_constant_p(size))
+ return addr > limit - size;
+
+ addr += size;
+ if (addr < size)
+ return true;
+
+ return addr > limit;
+}
+
+#define __range_not_ok(addr, size, limit) \
+({ \
+ __chk_user_ptr(addr); \
+ __chk_range_not_ok((unsigned long __force)(addr), size, limit); \
+})
+
static inline int __access_ok(const void __user * addr, unsigned long size)
{
return 1;