Bug 16061
Summary: | single stepping in a signal handler can cause the single step flag to get "stuck" | ||
---|---|---|---|
Product: | Other | Reporter: | Evan Teran (eteran) |
Component: | Other | Assignee: | Oleg Nesterov (oleg) |
Status: | RESOLVED OBSOLETE | ||
Severity: | normal | CC: | akpm, alan, b7.10110111, roland |
Priority: | P1 | ||
Hardware: | x86-64 | ||
OS: | Linux | ||
Kernel Version: | 2.6.32 (gentoo patchset r7) | Subsystem: | |
Regression: | No | Bisected commit-id: | |
Attachments: | [patch] the quick hack for illustration |
Description
Evan Teran
2010-05-27 19:26:14 UTC
Agreed, this looks like a bug to me. Perhaps TIF_FORCED_TF logic. I'll try to investigate on Monday. Thanks Evan! Agreed, this looks like a bug to me. Perhaps TIF_FORCED_TF logic. I'll try to investigate on Monday. Thanks Evan! Created attachment 26587 [details]
[patch] the quick hack for illustration
This patch fixes the problem, but I doubt it is really right.
I'll try to think more.
So:
- the tracee reports a signal SIG
- the tracer does ptrace(SINGLESTEP, SIG), this approves the signal
and also sets TF
- the tracee dequeues the signal, changes its IP to sig_handler().
then it notices TIF_SINGLESTEP and notifies the tracer without
return to user-space _and_ without clearing TF or TIF_SINGLESTEP
- the tracer does ptrace(SINGLESTEP) again, but now enable_single_step()
looses TIF_FORCED_TF.
- the tracer does ptrace(CONT), but user_disable_single_step() doesn't
clear TF since TIF_FORCED_TF is not set
- the tracee returns to user-space with X86_EFLAGS_TF in eflags
I am not sure what would be the "right" fix. I read enable_single_step()
billion times, and I still can't say I understand the comments/logic.
But perhaps this patch makes sense anyway?
Damn, I was in a hurry, the description is not accurate... (In reply to comment #3) > > then it notices TIF_SINGLESTEP and notifies the tracer without > return to user-space _and_ without clearing TF or TIF_SINGLESTEP ... _and_ without clearing TIF_SINGLESTEP, but TF is cleared (right before setup_rt_frame()) > - the tracer does ptrace(SINGLESTEP) again, but now enable_single_step() > looses TIF_FORCED_TF. and that is why enable_single_step() doesn't set FORCED. > But perhaps this patch makes sense anyway? As for x86, we can just change handle_signal to use test_and_clear(TIF_SINGLESTEP) as an argument to the tracehook, but then we probably need fixes for other machines. Roland, what do you think? Oleg, please get an appropriate test case for this into the ptrace-tests suite. That change might be the right one, but we should discuss it more in email, and look at the situation on other machines. Why is this marked OBSOLETE? Has this been fixed in any version? I still reproduce it in 3.16.0-43-generic from Kubuntu 14.04. > --- Comment #6 from Ruslan <b7.10110111@gmail.com> --- > Why is this marked OBSOLETE? Has this been fixed in any version? I still > reproduce it in 3.16.0-43-generic from Kubuntu 14.04. This was hopefully fixed by https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=fd0f86b66425bd8c6af8985881e82b28c30fd450 Oleg. |