History

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.

Eric W. Biederman committed 4 years ago

Commit c200e4b1 parent e71ba126 files · +10 −9Browse files

Unified · Split

6 files
  1. arch/um/include/asm/thread_info.h +2 −0
  2. arch/um/kernel/exec.c +1 −1
  3. arch/um/kernel/process.c +1 −1
  4. arch/um/kernel/ptrace.c +4 −4
  5. arch/um/kernel/signal.c +2 −2
  6. include/linux/ptrace.h +0 −1
arch/um/include/asm/thread_info.h+2−0
@@ -60,6 +60,7 @@ static inline struct thread_info *current_thread_info(void) · 59 unmodified lines
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) · 2 unmodified lines
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+1−1
@@ -43,7 +43,7 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) · 42 unmodified lines
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+1−1
@@ -335,7 +335,7 @@ int singlestepping(void * t) · 334 unmodified lines
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+4−4
@@ -11,7 +11,7 @@ · 10 unmodified lines
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) · 3 unmodified lines
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) · 92 unmodified lines
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) · 17 unmodified lines
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+2−2
@@ -53,7 +53,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) · 52 unmodified lines
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) · 68 unmodified lines
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+0−1
@@ -30,7 +30,6 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr, · 29 unmodified lines
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 */