score: fix copy_from_user() and friends
Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
c2f18fa4cb
commit
b615e3c746
@ -301,35 +301,34 @@ extern int __copy_tofrom_user(void *to, const void *from, unsigned long len);
|
|||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
copy_from_user(void *to, const void *from, unsigned long len)
|
copy_from_user(void *to, const void *from, unsigned long len)
|
||||||
{
|
{
|
||||||
unsigned long over;
|
unsigned long res = len;
|
||||||
|
|
||||||
if (access_ok(VERIFY_READ, from, len))
|
if (likely(access_ok(VERIFY_READ, from, len)))
|
||||||
return __copy_tofrom_user(to, from, len);
|
res = __copy_tofrom_user(to, from, len);
|
||||||
|
|
||||||
if ((unsigned long)from < TASK_SIZE) {
|
if (unlikely(res))
|
||||||
over = (unsigned long)from + len - TASK_SIZE;
|
memset(to + (len - res), 0, res);
|
||||||
return __copy_tofrom_user(to, from, len - over) + over;
|
|
||||||
}
|
return res;
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
copy_to_user(void *to, const void *from, unsigned long len)
|
copy_to_user(void *to, const void *from, unsigned long len)
|
||||||
{
|
{
|
||||||
unsigned long over;
|
if (likely(access_ok(VERIFY_WRITE, to, len)))
|
||||||
|
len = __copy_tofrom_user(to, from, len);
|
||||||
|
|
||||||
if (access_ok(VERIFY_WRITE, to, len))
|
|
||||||
return __copy_tofrom_user(to, from, len);
|
|
||||||
|
|
||||||
if ((unsigned long)to < TASK_SIZE) {
|
|
||||||
over = (unsigned long)to + len - TASK_SIZE;
|
|
||||||
return __copy_tofrom_user(to, from, len - over) + over;
|
|
||||||
}
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __copy_from_user(to, from, len) \
|
static inline unsigned long
|
||||||
__copy_tofrom_user((to), (from), (len))
|
__copy_from_user(void *to, const void *from, unsigned long len)
|
||||||
|
{
|
||||||
|
unsigned long left = __copy_tofrom_user(to, from, len);
|
||||||
|
if (unlikely(left))
|
||||||
|
memset(to + (len - left), 0, left);
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
#define __copy_to_user(to, from, len) \
|
#define __copy_to_user(to, from, len) \
|
||||||
__copy_tofrom_user((to), (from), (len))
|
__copy_tofrom_user((to), (from), (len))
|
||||||
@ -343,17 +342,17 @@ __copy_to_user_inatomic(void *to, const void *from, unsigned long len)
|
|||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
__copy_from_user_inatomic(void *to, const void *from, unsigned long len)
|
__copy_from_user_inatomic(void *to, const void *from, unsigned long len)
|
||||||
{
|
{
|
||||||
return __copy_from_user(to, from, len);
|
return __copy_tofrom_user(to, from, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __copy_in_user(to, from, len) __copy_from_user(to, from, len)
|
#define __copy_in_user(to, from, len) __copy_tofrom_user(to, from, len)
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
copy_in_user(void *to, const void *from, unsigned long len)
|
copy_in_user(void *to, const void *from, unsigned long len)
|
||||||
{
|
{
|
||||||
if (access_ok(VERIFY_READ, from, len) &&
|
if (access_ok(VERIFY_READ, from, len) &&
|
||||||
access_ok(VERFITY_WRITE, to, len))
|
access_ok(VERFITY_WRITE, to, len))
|
||||||
return copy_from_user(to, from, len);
|
return __copy_tofrom_user(to, from, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user