Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / um / include / sysdep-i386 / checksum.h
index bb6b343..052bb06 100644 (file)
 unsigned int csum_partial(const unsigned char * buff, int len, 
                          unsigned int sum);
 
-/*
- * the same as csum_partial, but copies from src while it
- * checksums, and handles user-space pointer exceptions correctly, when needed.
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-unsigned int csum_partial_copy_to(const char *src, char *dst, int len, 
-                                 int sum, int *err_ptr);
-unsigned int csum_partial_copy_from(const char *src, char *dst, int len, 
-                                   int sum, int *err_ptr);
-
 /*
  *     Note: when you get a NULL pointer exception here this means someone
  *     passed in an incorrect kernel address to one of these functions.
  *
  *     If you use these functions directly please don't forget the
- *     verify_area().
+ *     access_ok().
  */
 
 static __inline__
-unsigned int csum_partial_copy_nocheck(const char *src, char *dst,
+unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst,
                                       int len, int sum)
 {
        memcpy(dst, src, len);
-       return(csum_partial(dst, len, sum));
+       return csum_partial(dst, len, sum);
 }
 
+/*
+ * the same as csum_partial, but copies from src while it
+ * checksums, and handles user-space pointer exceptions correctly, when needed.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
 static __inline__
-unsigned int csum_partial_copy_from_user(const char *src, char *dst,
+unsigned int csum_partial_copy_from_user(const unsigned char __user *src,
+                                        unsigned char *dst,
                                         int len, int sum, int *err_ptr)
 {
-       return csum_partial_copy_from(src, dst, len, sum, err_ptr);
+       if(copy_from_user(dst, src, len)){
+               *err_ptr = -EFAULT;
+               return(-1);
+       }
+
+       return csum_partial(dst, len, sum);
 }
 
 /*
@@ -67,7 +68,6 @@ unsigned int csum_partial_copy_from_user(const char *src, char *dst,
  */
 
 #define csum_partial_copy_fromuser csum_partial_copy_from_user
-unsigned int csum_partial_copy( const char *src, char *dst, int len, int sum);
 
 /*
  *     This is a version of ip_compute_csum() optimized for IP headers,
@@ -105,7 +105,7 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
        : "=r" (sum), "=r" (iph), "=r" (ihl)
        : "1" (iph), "2" (ihl)
        : "memory");
-       return(sum);
+       return sum;
 }
 
 /*
@@ -192,12 +192,18 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
  *     Copy and checksum to user
  */
 #define HAVE_CSUM_COPY_USER
-static __inline__ unsigned int csum_and_copy_to_user(const char *src, 
-                                                    char *dst, int len,
-                                                    int sum, int *err_ptr)
+static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
+                                                    unsigned char __user *dst,
+                                                    int len, int sum, int *err_ptr)
 {
-       if (access_ok(VERIFY_WRITE, dst, len))
-               return(csum_partial_copy_to(src, dst, len, sum, err_ptr));
+       if (access_ok(VERIFY_WRITE, dst, len)){
+               if(copy_to_user(dst, src, len)){
+                       *err_ptr = -EFAULT;
+                       return(-1);
+               }
+
+               return csum_partial(src, len, sum);
+       }
 
        if (len)
                *err_ptr = -EFAULT;