Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 996
b: refs/heads/master
c: 7d37c6d
h: refs/heads/master
v: v3
  • Loading branch information
Bodo Stroesser authored and Linus Torvalds committed May 5, 2005
1 parent 4f8677d commit a02acd6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 60 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: c52ac046757deebc514483e407dca39a9c774aa3
refs/heads/master: 7d37c6d52fce13008f20344790a81a6a5a0003b3
39 changes: 22 additions & 17 deletions trunk/arch/um/include/sysdep-i386/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@
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 unsigned char *src, unsigned char *dst,
int len, int sum, int *err_ptr);
unsigned int csum_partial_copy_from(const unsigned char *src, unsigned 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.
Expand All @@ -52,11 +39,24 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
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 unsigned char *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);
}

/*
Expand All @@ -67,7 +67,6 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char
*/

#define csum_partial_copy_fromuser csum_partial_copy_from_user
unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);

/*
* This is a version of ip_compute_csum() optimized for IP headers,
Expand Down Expand Up @@ -196,8 +195,14 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
unsigned char *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;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extra-y := vmlinux.lds
clean-files :=

obj-y = checksum.o config.o exec_kern.o exitcode.o \
obj-y = config.o exec_kern.o exitcode.o \
helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \
physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \
sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \
Expand Down
36 changes: 0 additions & 36 deletions trunk/arch/um/kernel/checksum.c
Original file line number Diff line number Diff line change
@@ -1,36 +0,0 @@
#include "asm/uaccess.h"
#include "linux/errno.h"
#include "linux/module.h"

unsigned int arch_csum_partial(const unsigned char *buff, int len, int sum);

unsigned int csum_partial(unsigned char *buff, int len, int sum)
{
return arch_csum_partial(buff, len, sum);
}

EXPORT_SYMBOL(csum_partial);

unsigned int csum_partial_copy_to(const unsigned char *src,
unsigned char __user *dst, int len, int sum,
int *err_ptr)
{
if(copy_to_user(dst, src, len)){
*err_ptr = -EFAULT;
return(-1);
}

return(arch_csum_partial(src, len, sum));
}

unsigned int csum_partial_copy_from(const unsigned char __user *src,
unsigned char *dst, int len, int sum,
int *err_ptr)
{
if(copy_from_user(dst, src, len)){
*err_ptr = -EFAULT;
return(-1);
}

return arch_csum_partial(dst, len, sum);
}
6 changes: 3 additions & 3 deletions trunk/arch/um/sys-i386/checksum.S
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)

.text
.align 4
.globl arch_csum_partial
.globl csum_partial

#ifndef CONFIG_X86_USE_PPRO_CHECKSUM

Expand All @@ -49,7 +49,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
* Fortunately, it is easy to convert 2-byte alignment to 4-byte
* alignment for the unrolled loop.
*/
arch_csum_partial:
csum_partial:
pushl %esi
pushl %ebx
movl 20(%esp),%eax # Function arg: unsigned int sum
Expand Down Expand Up @@ -119,7 +119,7 @@ arch_csum_partial:

/* Version for PentiumII/PPro */

arch_csum_partial:
csum_partial:
pushl %esi
pushl %ebx
movl 20(%esp),%eax # Function arg: unsigned int sum
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/um/sys-i386/ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ EXPORT_SYMBOL(__down_failed_trylock);
EXPORT_SYMBOL(__up_wakeup);

/* Networking helper routines. */
EXPORT_SYMBOL(csum_partial_copy_from);
EXPORT_SYMBOL(csum_partial_copy_to);
EXPORT_SYMBOL(csum_partial);

0 comments on commit a02acd6

Please sign in to comment.