Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-25 Thread Oleg Nesterov
On 09/25, Roland McGrath wrote: it being after the syscall insn, but (in vanilla ptrace, and at the time of report_clone callbacks at utrace level) without the return value register having been written yet. And how we can implement this? regs-ax is updated right after call

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-25 Thread Oleg Nesterov
On 09/25, Oleg Nesterov wrote: On 09/25, Roland McGrath wrote: it being after the syscall insn, but (in vanilla ptrace, and at the time of report_clone callbacks at utrace level) without the return value register having been written yet. And how we can implement this?

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-25 Thread Roland McGrath
It's a further oddity that you can single-step (or not) into the system call and then get a ptrace stop inside it, that being for PTRACE_EVENT_FORK et al. And utrace-ptrace should be compatible here, yes? As far as the sequence of stops that a ptracer observes, the general answer is

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-24 Thread Oleg Nesterov
On 09/23, Roland McGrath wrote: It's a further oddity that you can single-step (or not) into the system call and then get a ptrace stop inside it, that being for PTRACE_EVENT_FORK et al. From there, the thread register state shows it being after the syscall insn, but (in vanilla ptrace, and

Re: Q: what user_enable_single_step() actually means?

2009-09-23 Thread Jan Kratochvil
On Wed, 23 Sep 2009 02:36:54 +0200, Roland McGrath wrote: It would be worthwhile to cons a version of this test case that uses PTRACE_SINGLESTEP instead of PTRACE_SYSCALL. I think your situation is tickling the same issue, but we should have an empirical test. [...] I have a fix in hand that

Re: Q: what user_enable_single_step() actually means?

2009-09-23 Thread Roland McGrath
On Wed, 23 Sep 2009 02:36:54 +0200, Roland McGrath wrote: It would be worthwhile to cons a version of this test case that uses PTRACE_SINGLESTEP instead of PTRACE_SYSCALL. I think your situation is tickling the same issue, but we should have an empirical test. [...] I have a fix in hand

[PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-23 Thread Oleg Nesterov
On 09/22, Roland McGrath wrote: I think the only cases where you can have a ptrace stop followed by actually taking the ret_from_sys_call path are tracehook_report_clone stops (i.e. the stop inside a clone/fork/vfork syscall). If you last used PTRACE_CONT or whatever and then hit

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-23 Thread Roland McGrath
Yes, but this has nothing to do with utrace-ptrace. If we last used PTRACE_CONT, the tracee stops in utrace_resume() path before return to the user-mode, syscall_trace_leave() can't be called. If I follow what you mean, that is just the x86 bug (now fixed upstream). Both tests fail. The 1st

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-23 Thread Oleg Nesterov
On 09/23, Roland McGrath wrote: Yes, but this has nothing to do with utrace-ptrace. If we last used PTRACE_CONT, the tracee stops in utrace_resume() path before return to the user-mode, syscall_trace_leave() can't be called. If I follow what you mean, that is just the x86 bug (now fixed

Re: [PATCH 53-55] (Was: Q: what user_enable_single_step() actually means?)

2009-09-23 Thread Roland McGrath
The tracee stops and reports PTRACE_EVENT_FORK from do_notify_resume(), after that syscall_trace_leave() can't (and must not) be called. Oh, I see what you mean. That is all under your control from the utrace API level. You can use a syscall-exit report first if you want to for keeping track

Re: Q: what user_enable_single_step() actually means?

2009-09-22 Thread Roland McGrath
Thanks Roland. But now I am even more confused... I get that combination a lot! ;-) Just to keep everyone confused, note that this thread now has approximately nothing to do with single-step. It really does have something to do with single-step, but only in the special sense of

Re: Q: what user_enable_single_step() actually means?

2009-09-21 Thread Oleg Nesterov
Thanks Roland. But now I am even more confused... On 09/20, Roland McGrath wrote: - PTRACE_SINGLESTEP does user_enable_single_step() - when the tracee returns to user mode, the next instruction causes exception, do_debug()-send_sigtrap() sends SIGTRAP - the tracee

Re: Q: what user_enable_single_step() actually means?

2009-09-21 Thread Oleg Nesterov
On 09/21, Oleg Nesterov wrote: However, int main(void) { assert(0 == prctl(666)); printf(after prctl\n); return 0; } dies with Trace/breakpoint trap, dmesg says: prctl: before=10246 prctl: after=10346

Re: Q: what user_enable_single_step() actually means?

2009-09-21 Thread Oleg Nesterov
On 09/21, Oleg Nesterov wrote: Yes, I modified the patch a bit (see below) to print the syscall number, Forgot to attach the patch. I guess it is not really needed, but just in case. Oleg. --- TTT/kernel/sys.c~TF_FBG 2009-06-17 14:11:26.0 +0200 +++ TTT/kernel/sys.c2009-09-21

Q: what user_enable_single_step() actually means?

2009-09-20 Thread Oleg Nesterov
Help! I spent all Sunday trying to do something with PTRACE_SINGLESTEP. And I am totally confused, to the point I don't even know how/what to ask. OK. Please forget about utrace. The tracee sleeps in, say, ptrace_signal()- ptrace_stop() path. The tracer does ptrace(PTRACE_SINGLESTEP, data = 0).

Re: Q: what user_enable_single_step() actually means?

2009-09-20 Thread Roland McGrath
- PTRACE_SINGLESTEP does user_enable_single_step() - when the tracee returns to user mode, the next instruction causes exception, do_debug()-send_sigtrap() sends SIGTRAP - the tracee notices the signal and reports this SIGTRAP Correct. But if the tracee is inside