Skip to content

Commit c200e4b

Browse files
committed
ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP
User mode linux is the last user of the PT_DTRACE flag. Using the flag to indicate single stepping is a little confusing and worse changing tsk->ptrace without locking could potentionally cause problems. So use a thread info flag with a better name instead of flag in tsk->ptrace. Remove the definition PT_DTRACE as uml is the last user. Cc: [email protected] Acked-by: Johannes Berg <[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 e71ba12 commit c200e4b

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

arch/um/include/asm/thread_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static inline struct thread_info *current_thread_info(void)
6060
#define TIF_RESTORE_SIGMASK 7
6161
#define TIF_NOTIFY_RESUME 8
6262
#define TIF_SECCOMP 9 /* secure computing */
63+
#define TIF_SINGLESTEP 10 /* single stepping userspace */
6364

6465
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
6566
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -68,5 +69,6 @@ static inline struct thread_info *current_thread_info(void)
6869
#define _TIF_MEMDIE (1 << TIF_MEMDIE)
6970
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
7071
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
72+
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
7173

7274
#endif

arch/um/kernel/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
4343
{
4444
PT_REGS_IP(regs) = eip;
4545
PT_REGS_SP(regs) = esp;
46-
current->ptrace &= ~PT_DTRACE;
46+
clear_thread_flag(TIF_SINGLESTEP);
4747
#ifdef SUBARCH_EXECVE1
4848
SUBARCH_EXECVE1(regs->regs);
4949
#endif

arch/um/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int singlestepping(void * t)
335335
{
336336
struct task_struct *task = t ? t : current;
337337

338-
if (!(task->ptrace & PT_DTRACE))
338+
if (!test_thread_flag(TIF_SINGLESTEP))
339339
return 0;
340340

341341
if (task->thread.singlestep_syscall)

arch/um/kernel/ptrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
void user_enable_single_step(struct task_struct *child)
1313
{
14-
child->ptrace |= PT_DTRACE;
14+
set_tsk_thread_flag(child, TIF_SINGLESTEP);
1515
child->thread.singlestep_syscall = 0;
1616

1717
#ifdef SUBARCH_SET_SINGLESTEPPING
@@ -21,7 +21,7 @@ void user_enable_single_step(struct task_struct *child)
2121

2222
void user_disable_single_step(struct task_struct *child)
2323
{
24-
child->ptrace &= ~PT_DTRACE;
24+
clear_tsk_thread_flag(child, TIF_SINGLESTEP);
2525
child->thread.singlestep_syscall = 0;
2626

2727
#ifdef SUBARCH_SET_SINGLESTEPPING
@@ -120,7 +120,7 @@ static void send_sigtrap(struct uml_pt_regs *regs, int error_code)
120120
}
121121

122122
/*
123-
* XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
123+
* XXX Check TIF_SINGLESTEP for singlestepping check and
124124
* PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check
125125
*/
126126
int syscall_trace_enter(struct pt_regs *regs)
@@ -144,7 +144,7 @@ void syscall_trace_leave(struct pt_regs *regs)
144144
audit_syscall_exit(regs);
145145

146146
/* Fake a debug trap */
147-
if (ptraced & PT_DTRACE)
147+
if (test_thread_flag(TIF_SINGLESTEP))
148148
send_sigtrap(&regs->regs, 0);
149149

150150
if (!test_thread_flag(TIF_SYSCALL_TRACE))

arch/um/kernel/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
5353
unsigned long sp;
5454
int err;
5555

56-
if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
56+
if (test_thread_flag(TIF_SINGLESTEP) && (current->ptrace & PT_PTRACED))
5757
singlestep = 1;
5858

5959
/* Did we come from a system call? */
@@ -128,7 +128,7 @@ void do_signal(struct pt_regs *regs)
128128
* on the host. The tracing thread will check this flag and
129129
* PTRACE_SYSCALL if necessary.
130130
*/
131-
if (current->ptrace & PT_DTRACE)
131+
if (test_thread_flag(TIF_SINGLESTEP))
132132
current->thread.singlestep_syscall =
133133
is_syscall(PT_REGS_IP(&current->thread.regs));
134134

include/linux/ptrace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
3030

3131
#define PT_SEIZED 0x00010000 /* SEIZE used, enable new behavior */
3232
#define PT_PTRACED 0x00000001
33-
#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */
3433

3534
#define PT_OPT_FLAG_SHIFT 3
3635
/* PT_TRACE_* event enable flags */

0 commit comments

Comments
 (0)