]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] might_sleep() checks for x86 usercopy functions
authorAndrew Morton <akpm@osdl.org>
Thu, 7 Aug 2003 04:13:58 +0000 (21:13 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 7 Aug 2003 04:13:58 +0000 (21:13 -0700)
From: Matt Mackall <mpm@selenic.com>

This only checks in the non-__ versions, as those are occassionally
called inside things like kmap_atomic pairs which take a spinlock in
with highmem. It's all conditional on CONFIG_DEBUG_SPINLOCK_SLEEP
(which isn't quite the right name) so there's no overhead for normal
builds.

arch/i386/lib/usercopy.c
include/asm-i386/uaccess.h

index 647b54eef4dc418a59eda319f48c2e0822f0c21b..2361c79f8b1d329beadc235aaec358bcb2a6b5bd 100644 (file)
@@ -149,6 +149,7 @@ do {                                                                        \
 unsigned long
 clear_user(void __user *to, unsigned long n)
 {
+       might_sleep();
        if (access_ok(VERIFY_WRITE, to, n))
                __do_clear_user(to, n);
        return n;
@@ -188,6 +189,8 @@ long strnlen_user(const char __user *s, long n)
        unsigned long mask = -__addr_ok(s);
        unsigned long res, tmp;
 
+       might_sleep();
+
        __asm__ __volatile__(
                "       testl %0, %0\n"
                "       jz 3f\n"
index b7744806aed68cbf4bcd83071663cd8cadc42857..d3eabf5b95c7ffa374fdc7ad0c0bebc6079fc28d 100644 (file)
@@ -260,6 +260,7 @@ extern void __put_user_bad(void);
 ({                                                                     \
        long __pu_err = -EFAULT;                                        \
        __typeof__(*(ptr)) *__pu_addr = (ptr);                          \
+       might_sleep();                                          \
        if (access_ok(VERIFY_WRITE,__pu_addr,size))                     \
                __put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT); \
        __pu_err;                                                       \
@@ -469,6 +470,7 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
 static inline unsigned long
 copy_to_user(void __user *to, const void *from, unsigned long n)
 {
+       might_sleep();
        if (access_ok(VERIFY_WRITE, to, n))
                n = __copy_to_user(to, from, n);
        return n;
@@ -493,6 +495,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
 static inline unsigned long
 copy_from_user(void *to, const void __user *from, unsigned long n)
 {
+       might_sleep();
        if (access_ok(VERIFY_READ, from, n))
                n = __copy_from_user(to, from, n);
        else