aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-10-27 18:33:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:10 -0400
commit475a4b813816fe9af4cdf7833799036b679f46d0 (patch)
tree8147812d582934768f7425c415e14019901ff302
parentaeebd3a3d9f5b67a254f04e6eac91a74c5e1065e (diff)
ptrace: cleanup arch_ptrace() on cris
Use new 'regno' variable in order to remove redandunt expression and remove checking @addr less than 0 because @addr is now unsigned. Also update 'datap' on PTRACE_GET/SETREGS to fix a bug on arch-v10. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Acked-by: Mikael Starvik <starvik@axis.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/cris/arch-v10/kernel/ptrace.c17
-rw-r--r--arch/cris/arch-v32/kernel/ptrace.c13
2 files changed, 14 insertions, 16 deletions
diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
index d411e024e05f..320065f3cbe5 100644
--- a/arch/cris/arch-v10/kernel/ptrace.c
+++ b/arch/cris/arch-v10/kernel/ptrace.c
@@ -80,6 +80,7 @@ long arch_ptrace(struct task_struct *child, long request,
80 unsigned long addr, unsigned long data) 80 unsigned long addr, unsigned long data)
81{ 81{
82 int ret; 82 int ret;
83 unsigned int regno = addr >> 2;
83 unsigned long __user *datap = (unsigned long __user *)data; 84 unsigned long __user *datap = (unsigned long __user *)data;
84 85
85 switch (request) { 86 switch (request) {
@@ -94,10 +95,10 @@ long arch_ptrace(struct task_struct *child, long request,
94 unsigned long tmp; 95 unsigned long tmp;
95 96
96 ret = -EIO; 97 ret = -EIO;
97 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 98 if ((addr & 3) || regno > PT_MAX)
98 break; 99 break;
99 100
100 tmp = get_reg(child, addr >> 2); 101 tmp = get_reg(child, regno);
101 ret = put_user(tmp, datap); 102 ret = put_user(tmp, datap);
102 break; 103 break;
103 } 104 }
@@ -111,19 +112,17 @@ long arch_ptrace(struct task_struct *child, long request,
111 /* Write the word at location address in the USER area. */ 112 /* Write the word at location address in the USER area. */
112 case PTRACE_POKEUSR: 113 case PTRACE_POKEUSR:
113 ret = -EIO; 114 ret = -EIO;
114 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 115 if ((addr & 3) || regno > PT_MAX)
115 break; 116 break;
116 117
117 addr >>= 2; 118 if (regno == PT_DCCR) {
118
119 if (addr == PT_DCCR) {
120 /* don't allow the tracing process to change stuff like 119 /* don't allow the tracing process to change stuff like
121 * interrupt enable, kernel/user bit, dma enables etc. 120 * interrupt enable, kernel/user bit, dma enables etc.
122 */ 121 */
123 data &= DCCR_MASK; 122 data &= DCCR_MASK;
124 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK; 123 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK;
125 } 124 }
126 if (put_reg(child, addr, data)) 125 if (put_reg(child, regno, data))
127 break; 126 break;
128 ret = 0; 127 ret = 0;
129 break; 128 break;
@@ -142,7 +141,7 @@ long arch_ptrace(struct task_struct *child, long request,
142 break; 141 break;
143 } 142 }
144 143
145 data += sizeof(unsigned long); 144 datap++;
146 } 145 }
147 146
148 break; 147 break;
@@ -166,7 +165,7 @@ long arch_ptrace(struct task_struct *child, long request,
166 } 165 }
167 166
168 put_reg(child, i, tmp); 167 put_reg(child, i, tmp);
169 data += sizeof(unsigned long); 168 datap++;
170 } 169 }
171 170
172 break; 171 break;
diff --git a/arch/cris/arch-v32/kernel/ptrace.c b/arch/cris/arch-v32/kernel/ptrace.c
index 3e058a121753..511ece94a574 100644
--- a/arch/cris/arch-v32/kernel/ptrace.c
+++ b/arch/cris/arch-v32/kernel/ptrace.c
@@ -130,6 +130,7 @@ long arch_ptrace(struct task_struct *child, long request,
130 unsigned long addr, unsigned long data) 130 unsigned long addr, unsigned long data)
131{ 131{
132 int ret; 132 int ret;
133 unsigned int regno = addr >> 2;
133 unsigned long __user *datap = (unsigned long __user *)data; 134 unsigned long __user *datap = (unsigned long __user *)data;
134 135
135 switch (request) { 136 switch (request) {
@@ -164,10 +165,10 @@ long arch_ptrace(struct task_struct *child, long request,
164 unsigned long tmp; 165 unsigned long tmp;
165 166
166 ret = -EIO; 167 ret = -EIO;
167 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 168 if ((addr & 3) || regno > PT_MAX)
168 break; 169 break;
169 170
170 tmp = get_reg(child, addr >> 2); 171 tmp = get_reg(child, regno);
171 ret = put_user(tmp, datap); 172 ret = put_user(tmp, datap);
172 break; 173 break;
173 } 174 }
@@ -181,19 +182,17 @@ long arch_ptrace(struct task_struct *child, long request,
181 /* Write the word at location address in the USER area. */ 182 /* Write the word at location address in the USER area. */
182 case PTRACE_POKEUSR: 183 case PTRACE_POKEUSR:
183 ret = -EIO; 184 ret = -EIO;
184 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 185 if ((addr & 3) || regno > PT_MAX)
185 break; 186 break;
186 187
187 addr >>= 2; 188 if (regno == PT_CCS) {
188
189 if (addr == PT_CCS) {
190 /* don't allow the tracing process to change stuff like 189 /* don't allow the tracing process to change stuff like
191 * interrupt enable, kernel/user bit, dma enables etc. 190 * interrupt enable, kernel/user bit, dma enables etc.
192 */ 191 */
193 data &= CCS_MASK; 192 data &= CCS_MASK;
194 data |= get_reg(child, PT_CCS) & ~CCS_MASK; 193 data |= get_reg(child, PT_CCS) & ~CCS_MASK;
195 } 194 }
196 if (put_reg(child, addr, data)) 195 if (put_reg(child, regno, data))
197 break; 196 break;
198 ret = 0; 197 ret = 0;
199 break; 198 break;