.. | .. |
---|
8 | 8 | #include <linux/uaccess.h> |
---|
9 | 9 | #include <asm/errno.h> |
---|
10 | 10 | #include <asm/synch.h> |
---|
11 | | -#include <asm/asm-405.h> |
---|
12 | 11 | |
---|
13 | 12 | #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ |
---|
14 | 13 | __asm__ __volatile ( \ |
---|
15 | 14 | PPC_ATOMIC_ENTRY_BARRIER \ |
---|
16 | 15 | "1: lwarx %0,0,%2\n" \ |
---|
17 | 16 | insn \ |
---|
18 | | - PPC405_ERR77(0, %2) \ |
---|
19 | 17 | "2: stwcx. %1,0,%2\n" \ |
---|
20 | 18 | "bne- 1b\n" \ |
---|
21 | 19 | PPC_ATOMIC_EXIT_BARRIER \ |
---|
.. | .. |
---|
35 | 33 | { |
---|
36 | 34 | int oldval = 0, ret; |
---|
37 | 35 | |
---|
38 | | - allow_write_to_user(uaddr, sizeof(*uaddr)); |
---|
39 | | - pagefault_disable(); |
---|
| 36 | + if (!access_ok(uaddr, sizeof(u32))) |
---|
| 37 | + return -EFAULT; |
---|
| 38 | + allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
---|
40 | 39 | |
---|
41 | 40 | switch (op) { |
---|
42 | 41 | case FUTEX_OP_SET: |
---|
.. | .. |
---|
58 | 57 | ret = -ENOSYS; |
---|
59 | 58 | } |
---|
60 | 59 | |
---|
61 | | - pagefault_enable(); |
---|
62 | | - |
---|
63 | 60 | *oval = oldval; |
---|
64 | 61 | |
---|
65 | | - prevent_write_to_user(uaddr, sizeof(*uaddr)); |
---|
| 62 | + prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
---|
66 | 63 | return ret; |
---|
67 | 64 | } |
---|
68 | 65 | |
---|
.. | .. |
---|
73 | 70 | int ret = 0; |
---|
74 | 71 | u32 prev; |
---|
75 | 72 | |
---|
76 | | - if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
---|
| 73 | + if (!access_ok(uaddr, sizeof(u32))) |
---|
77 | 74 | return -EFAULT; |
---|
78 | 75 | |
---|
79 | | - allow_write_to_user(uaddr, sizeof(*uaddr)); |
---|
| 76 | + allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
---|
| 77 | + |
---|
80 | 78 | __asm__ __volatile__ ( |
---|
81 | 79 | PPC_ATOMIC_ENTRY_BARRIER |
---|
82 | 80 | "1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\ |
---|
83 | 81 | cmpw 0,%1,%4\n\ |
---|
84 | 82 | bne- 3f\n" |
---|
85 | | - PPC405_ERR77(0,%3) |
---|
86 | 83 | "2: stwcx. %5,0,%3\n\ |
---|
87 | 84 | bne- 1b\n" |
---|
88 | 85 | PPC_ATOMIC_EXIT_BARRIER |
---|
.. | .. |
---|
97 | 94 | : "cc", "memory"); |
---|
98 | 95 | |
---|
99 | 96 | *uval = prev; |
---|
100 | | - prevent_write_to_user(uaddr, sizeof(*uaddr)); |
---|
| 97 | + prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
---|
| 98 | + |
---|
101 | 99 | return ret; |
---|
102 | 100 | } |
---|
103 | 101 | |
---|