tracehook_report_syscall_exit() && PT_PTRACED (Was: [PATCH 133] stepping, accommodate to utrace-cleanup changes)

Oleg Nesterov oleg at redhat.com
Tue Nov 17 22:07:57 UTC 2009


On 11/16, Roland McGrath wrote:
>
> The change we talked about before seems simple enough and should cover this
> without new kludges in the ptrace layer.  I did this (commit f19442c).

I will reply to this in the next email, I'd like to discuss
another minor related issue first.

I noticed this change in your tree

	commit 2583b3267ed599cb25f6f893c24465204e06b3a6
	utrace: nit for utrace-ptrace

	--- a/include/linux/tracehook.h
	+++ b/include/linux/tracehook.h
	@@ -143,7 +143,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 && task_ptrace(current)) {
	+	if (step && (task_ptrace(current) & PT_PTRACED)) {
			siginfo_t info;
			user_single_step_siginfo(current, regs, &info);
			force_sig_info(SIGTRAP, &info, current);

Yes, and in fact I already had this change in my tree but didn't
send it to you yet.

But, I can't understand whats going on,

	-       if (step && task_ptrace(current)) {
	+       if (step && (task_ptrace(current) & PT_PTRACED)) {

The code after ptrace-change-tracehook_report_syscall_exit-to-handle-stepping.patch
is "if (step)", not "if (step && task_ptrace(current))", can't understand
where did this "&& task_ptrace(current)" come from. The previous commit in
your tree is

	462a57bb7a6a5c67b70e4388f97239f1e4da98df
	ptrace: change tracehook_report_syscall_exit() to handle stepping


Initially I was going to add the change below into
"tracehooks: prepare for utrace-ptrace",

	--- a/include/linux/tracehook.h
	+++ b/include/linux/tracehook.h
	@@ -134,6 +134,9 @@ static inline __must_check int tracehook
	  */
	 static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
	 {
	+	if (!(task_ptrace(current) & PT_PTRACED))
	+		return;
	+
		if (step) {
			siginfo_t info;
			user_single_step_siginfo(current, regs, &info);

but now I think perhaps it would be better to send
ptrace-change-tracehook_report_syscall_exit-to-handle-stepping_fix
to akpm right now:

	--- a/include/linux/tracehook.h
	+++ b/include/linux/tracehook.h
	@@ -134,7 +134,7 @@ static inline __must_check int tracehook
	  */
	 static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
	 {
	-	if (step) {
	+	if (step && (task_ptrace(current) & PT_PTRACED)) {
			siginfo_t info;
			user_single_step_siginfo(current, regs, &info);
			force_sig_info(SIGTRAP, &info, current);

What do you think?

Now, let's return to the original topic. Please note that utrace
does not need "int step" at all, see the next email.

Oleg.




More information about the utrace-devel mailing list