[PATCH 1/2] utrace: finish_resume_report: don't do user_xxx_step() if ptrace_wants_step()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



finish_resume_report() should not enable/disable the stepping if
ptrace_wants_step() == T. If ptrace wants block_step while utrace
wants single_step we could "promote" the stepping, but I do not
think this really makes sense.

Unless the tracee is killed this can't race with ptrace, this is
called by the tracee itself. If it is killed we do not care.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
---
 include/linux/tracehook.h |    8 ++++----
 kernel/utrace.c           |    9 ++++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 06edb52..5612d2d 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -121,8 +121,8 @@ static inline __must_check int tracehook_report_syscall_entry(
 	return 0;
 }
 
-#define ptrace_wants_step()	\
-	(current->ptrace & (PT_SINGLE_STEP | PT_SINGLE_BLOCK))
+#define ptrace_wants_step(task)	\
+	((task)->ptrace & (PT_SINGLE_STEP | PT_SINGLE_BLOCK))
 
 /**
  * tracehook_report_syscall_exit - task has just finished a system call
@@ -146,7 +146,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
 	if (task_utrace_flags(current) & UTRACE_EVENT(SYSCALL_EXIT))
 		utrace_report_syscall_exit(regs);
 
-	if (step && ptrace_wants_step()) {
+	if (step && ptrace_wants_step(current)) {
 		siginfo_t info;
 		user_single_step_siginfo(current, regs, &info);
 		force_sig_info(SIGTRAP, &info, current);
@@ -439,7 +439,7 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,
 {
 	if (task_utrace_flags(current))
 		utrace_signal_handler(current, stepping);
-	if (stepping && ptrace_wants_step())
+	if (stepping && ptrace_wants_step(current))
 		ptrace_notify(SIGTRAP);
 }
 
diff --git a/kernel/utrace.c b/kernel/utrace.c
index 508c13c..fbabb81 100644
--- a/kernel/utrace.c
+++ b/kernel/utrace.c
@@ -1828,7 +1828,8 @@ static void finish_resume_report(struct task_struct *task,
 
 	case UTRACE_BLOCKSTEP:
 		if (likely(arch_has_block_step())) {
-			user_enable_block_step(task);
+			if (!ptrace_wants_step(task))
+				user_enable_block_step(task);
 			break;
 		}
 
@@ -1841,7 +1842,8 @@ static void finish_resume_report(struct task_struct *task,
 
 	case UTRACE_SINGLESTEP:
 		if (likely(arch_has_single_step())) {
-			user_enable_single_step(task);
+			if (!ptrace_wants_step(task))
+				user_enable_single_step(task);
 		} else {
 			/*
 			 * This means some callback is to blame for failing
@@ -1856,7 +1858,8 @@ static void finish_resume_report(struct task_struct *task,
 	case UTRACE_REPORT:
 	case UTRACE_RESUME:
 	default:
-		user_disable_single_step(task);
+		if (!ptrace_wants_step(task))
+			user_disable_single_step(task);
 		break;
 	}
 }
-- 
1.5.5.1


_______________________________________________
kernel mailing list
kernel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/kernel


[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux