Skip to content

Commit 5f09c77

Browse files
committed
Blackfin: simplify SYSCFG code a bit and ignore attempts to change it
We don't want to let user space modify the SYSCFG register arbitrarily as the settings are system wide (SNEN/CNEN) and can cause misbehavior. The only other bit here (SSSTEP) has proper controls via PTRACE_SINGLESTEP. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
1 parent f5b9962 commit 5f09c77

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

‎arch/blackfin/kernel/ptrace.c‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
* in exit.c or in signal.c.
3232
*/
3333

34-
/* determines which bits in the SYSCFG reg the user has access to. */
35-
/* 1 = access 0 = no access */
36-
#define SYSCFG_MASK 0x0007 /* SYSCFG reg */
37-
/* sets the trace bits. */
38-
#define TRACE_BITS 0x0001
39-
4034
/* Find the stack offset for a register, relative to thread.esp0. */
4135
#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
4236

@@ -162,9 +156,8 @@ static inline int is_user_addr_valid(struct task_struct *child,
162156

163157
void ptrace_enable(struct task_struct *child)
164158
{
165-
unsigned long tmp;
166-
tmp = get_reg(child, PT_SYSCFG) | (TRACE_BITS);
167-
put_reg(child, PT_SYSCFG, tmp);
159+
struct pt_regs *regs = task_pt_regs(child);
160+
regs->syscfg |= SYSCFG_SSSTEP;
168161
}
169162

170163
/*
@@ -174,10 +167,8 @@ void ptrace_enable(struct task_struct *child)
174167
*/
175168
void ptrace_disable(struct task_struct *child)
176169
{
177-
unsigned long tmp;
178-
/* make sure the single step bit is not set. */
179-
tmp = get_reg(child, PT_SYSCFG) & ~TRACE_BITS;
180-
put_reg(child, PT_SYSCFG, tmp);
170+
struct pt_regs *regs = task_pt_regs(child);
171+
regs->syscfg &= ~SYSCFG_SSSTEP;
181172
}
182173

183174
long arch_ptrace(struct task_struct *child, long request, long addr, long data)
@@ -343,14 +334,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
343334
break;
344335
}
345336

346-
if (addr >= (sizeof(struct pt_regs))) {
337+
/* Ignore writes to SYSCFG and other pseudo regs */
338+
if (addr >= PT_SYSCFG) {
347339
ret = 0;
348340
break;
349341
}
350-
if (addr == PT_SYSCFG) {
351-
data &= SYSCFG_MASK;
352-
data |= get_reg(child, PT_SYSCFG);
353-
}
354342
ret = put_reg(child, addr, data);
355343
break;
356344

0 commit comments

Comments
 (0)