hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/arch/um/kernel/ptrace.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3
- * Licensed under the GPL
44 */
55
66 #include <linux/audit.h>
....@@ -12,7 +12,7 @@
1212
1313 void user_enable_single_step(struct task_struct *child)
1414 {
15
- child->ptrace |= PT_DTRACE;
15
+ set_tsk_thread_flag(child, TIF_SINGLESTEP);
1616 child->thread.singlestep_syscall = 0;
1717
1818 #ifdef SUBARCH_SET_SINGLESTEPPING
....@@ -22,7 +22,7 @@
2222
2323 void user_disable_single_step(struct task_struct *child)
2424 {
25
- child->ptrace &= ~PT_DTRACE;
25
+ clear_tsk_thread_flag(child, TIF_SINGLESTEP);
2626 child->thread.singlestep_syscall = 0;
2727
2828 #ifdef SUBARCH_SET_SINGLESTEPPING
....@@ -66,7 +66,7 @@
6666
6767 #ifdef PTRACE_GETREGS
6868 case PTRACE_GETREGS: { /* Get all gp regs from the child. */
69
- if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) {
69
+ if (!access_ok(p, MAX_REG_OFFSET)) {
7070 ret = -EIO;
7171 break;
7272 }
....@@ -81,7 +81,7 @@
8181 #ifdef PTRACE_SETREGS
8282 case PTRACE_SETREGS: { /* Set all gp regs in the child. */
8383 unsigned long tmp = 0;
84
- if (!access_ok(VERIFY_READ, p, MAX_REG_OFFSET)) {
84
+ if (!access_ok(p, MAX_REG_OFFSET)) {
8585 ret = -EIO;
8686 break;
8787 }
....@@ -112,17 +112,16 @@
112112 return ret;
113113 }
114114
115
-static void send_sigtrap(struct task_struct *tsk, struct uml_pt_regs *regs,
116
- int error_code)
115
+static void send_sigtrap(struct uml_pt_regs *regs, int error_code)
117116 {
118117 /* Send us the fake SIGTRAP */
119118 force_sig_fault(SIGTRAP, TRAP_BRKPT,
120119 /* User-mode eip? */
121
- UPT_IS_USER(regs) ? (void __user *) UPT_IP(regs) : NULL, tsk);
120
+ UPT_IS_USER(regs) ? (void __user *) UPT_IP(regs) : NULL);
122121 }
123122
124123 /*
125
- * XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
124
+ * XXX Check TIF_SINGLESTEP for singlestepping check and
126125 * PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check
127126 */
128127 int syscall_trace_enter(struct pt_regs *regs)
....@@ -146,8 +145,8 @@
146145 audit_syscall_exit(regs);
147146
148147 /* Fake a debug trap */
149
- if (ptraced & PT_DTRACE)
150
- send_sigtrap(current, &regs->regs, 0);
148
+ if (test_thread_flag(TIF_SINGLESTEP))
149
+ send_sigtrap(&regs->regs, 0);
151150
152151 if (!test_thread_flag(TIF_SYSCALL_TRACE))
153152 return;