Skip to content

Commit 4a3d271

Browse files
committed
ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP
xtensa is the last user of the PT_SINGLESTEP flag. Changing tsk->ptrace in user_enable_single_step and user_disable_single_step without locking could potentiallly cause problems. So use a thread info flag instead of a flag in tsk->ptrace. Use TIF_SINGLESTEP that xtensa already had defined but unused. Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users. Cc: [email protected] Acked-by: Max Filippov <[email protected]> Tested-by: Kees Cook <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent c200e4b commit 4a3d271

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

arch/xtensa/kernel/ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
225225

226226
void user_enable_single_step(struct task_struct *child)
227227
{
228-
child->ptrace |= PT_SINGLESTEP;
228+
set_tsk_thread_flag(child, TIF_SINGLESTEP);
229229
}
230230

231231
void user_disable_single_step(struct task_struct *child)
232232
{
233-
child->ptrace &= ~PT_SINGLESTEP;
233+
clear_tsk_thread_flag(child, TIF_SINGLESTEP);
234234
}
235235

236236
/*

arch/xtensa/kernel/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void do_signal(struct pt_regs *regs)
473473
/* Set up the stack frame */
474474
ret = setup_frame(&ksig, sigmask_to_save(), regs);
475475
signal_setup_done(ret, &ksig, 0);
476-
if (current->ptrace & PT_SINGLESTEP)
476+
if (test_thread_flag(TIF_SINGLESTEP))
477477
task_pt_regs(current)->icountlevel = 1;
478478

479479
return;
@@ -499,7 +499,7 @@ static void do_signal(struct pt_regs *regs)
499499
/* If there's no signal to deliver, we just restore the saved mask. */
500500
restore_saved_sigmask();
501501

502-
if (current->ptrace & PT_SINGLESTEP)
502+
if (test_thread_flag(TIF_SINGLESTEP))
503503
task_pt_regs(current)->icountlevel = 1;
504504
return;
505505
}

include/linux/ptrace.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
4646
#define PT_EXITKILL (PTRACE_O_EXITKILL << PT_OPT_FLAG_SHIFT)
4747
#define PT_SUSPEND_SECCOMP (PTRACE_O_SUSPEND_SECCOMP << PT_OPT_FLAG_SHIFT)
4848

49-
/* single stepping state bits (used on ARM and PA-RISC) */
50-
#define PT_SINGLESTEP_BIT 31
51-
#define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT)
52-
#define PT_BLOCKSTEP_BIT 30
53-
#define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT)
54-
5549
extern long arch_ptrace(struct task_struct *child, long request,
5650
unsigned long addr, unsigned long data);
5751
extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);

0 commit comments

Comments
 (0)