Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123165
b: refs/heads/master
c: c10d38d
h: refs/heads/master
i:
  123163: 270b438
v: v3
  • Loading branch information
Nick Piggin authored and Ingo Molnar committed Sep 10, 2008
1 parent cddffb2 commit 7fff11e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 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: 76b189e91845eab3a9d52bb97f971d312d25652d
refs/heads/master: c10d38dda1774ed4540380333cabd229eff37094
7 changes: 6 additions & 1 deletion trunk/arch/x86/lib/usercopy_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned lon
do { \
int __d0, __d1, __d2; \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__asm__ __volatile__( \
" testl %1,%1\n" \
" jz 2f\n" \
Expand Down Expand Up @@ -120,6 +122,8 @@ EXPORT_SYMBOL(strncpy_from_user);
do { \
int __d0; \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__asm__ __volatile__( \
"0: rep; stosl\n" \
" movl %2,%0\n" \
Expand Down Expand Up @@ -148,7 +152,6 @@ 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;
Expand Down Expand Up @@ -191,6 +194,8 @@ long strnlen_user(const char __user *s, long n)
unsigned long res, tmp;

might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);

__asm__ __volatile__(
" testl %0, %0\n"
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/x86/lib/usercopy_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
do { \
long __d0, __d1, __d2; \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__asm__ __volatile__( \
" testq %1,%1\n" \
" jz 2f\n" \
Expand Down Expand Up @@ -65,6 +67,8 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
{
long __d0;
might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
/* no memory constraint because it doesn't change any memory gcc knows
about */
asm volatile(
Expand Down
14 changes: 14 additions & 0 deletions trunk/include/asm-x86/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <linux/thread_info.h>
#include <linux/prefetch.h>
#include <linux/string.h>
#include <linux/lockdep.h>
#include <linux/sched.h>
#include <asm/asm.h>
#include <asm/page.h>

Expand Down Expand Up @@ -157,6 +159,9 @@ extern int __get_user_bad(void);
int __ret_gu; \
unsigned long __val_gu; \
__chk_user_ptr(ptr); \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
switch (sizeof(*(ptr))) { \
case 1: \
__get_user_x(1, __ret_gu, __val_gu, ptr); \
Expand Down Expand Up @@ -241,6 +246,9 @@ extern void __put_user_8(void);
int __ret_pu; \
__typeof__(*(ptr)) __pu_val; \
__chk_user_ptr(ptr); \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__pu_val = x; \
switch (sizeof(*(ptr))) { \
case 1: \
Expand All @@ -265,6 +273,9 @@ extern void __put_user_8(void);
#define __put_user_size(x, ptr, size, retval, errret) \
do { \
retval = 0; \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__chk_user_ptr(ptr); \
switch (size) { \
case 1: \
Expand Down Expand Up @@ -317,6 +328,9 @@ do { \
#define __get_user_size(x, ptr, size, retval, errret) \
do { \
retval = 0; \
might_sleep(); \
if (current->mm) \
might_lock_read(&current->mm->mmap_sem); \
__chk_user_ptr(ptr); \
switch (size) { \
case 1: \
Expand Down
10 changes: 8 additions & 2 deletions trunk/include/asm-x86/uaccess_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
static __always_inline unsigned long __must_check
__copy_to_user(void __user *to, const void *from, unsigned long n)
{
might_sleep();
return __copy_to_user_inatomic(to, from, n);
might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
return __copy_to_user_inatomic(to, from, n);
}

static __always_inline unsigned long
Expand Down Expand Up @@ -138,6 +140,8 @@ static __always_inline unsigned long
__copy_from_user(void *to, const void __user *from, unsigned long n)
{
might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
if (__builtin_constant_p(n)) {
unsigned long ret;

Expand All @@ -160,6 +164,8 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
const void __user *from, unsigned long n)
{
might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
if (__builtin_constant_p(n)) {
unsigned long ret;

Expand Down
12 changes: 12 additions & 0 deletions trunk/include/asm-x86/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ static __always_inline __must_check
int __copy_from_user(void *dst, const void __user *src, unsigned size)
{
int ret = 0;

might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic(dst, (__force void *)src, size);
switch (size) {
Expand Down Expand Up @@ -70,6 +74,10 @@ static __always_inline __must_check
int __copy_to_user(void __user *dst, const void *src, unsigned size)
{
int ret = 0;

might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic((__force void *)dst, src, size);
switch (size) {
Expand Down Expand Up @@ -112,6 +120,10 @@ static __always_inline __must_check
int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
{
int ret = 0;

might_sleep();
if (current->mm)
might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic((__force void *)dst,
(__force void *)src, size);
Expand Down

0 comments on commit 7fff11e

Please sign in to comment.