summaryrefslogtreecommitdiffstats
path: root/arch
Commit message (Collapse)AuthorAgeFilesLines
* uprobes/x86: Only rep+nop can be emulated correctlyOleg Nesterov2012-10-291-14/+2
| | | | | | | | | | | | | | | __skip_sstep() correctly detects the "nontrivial" nop insns, but since it doesn't update regs->ip we can not really skip "0x0f 0x1f | 0x0f 0x19 | 0x87 0xc0", the probed application is killed by SIGILL'ed handle_swbp(). Remove these additional checks. If we want to implement this correctly we need to know the full insn length to update ->ip. rep* + nop is fine even without updating ->ip. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes: Move clear_thread_flag(TIF_UPROBE) to uprobe_notify_resume()Oleg Nesterov2012-10-291-3/+1
| | | | | | | | Move clear_thread_flag(TIF_UPROBE) from do_notify_resume() to uprobe_notify_resume() for !CONFIG_UPROBES case. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes: Make arch_uprobe_task->saved_trap_nr "unsigned int"Oleg Nesterov2012-10-291-1/+1
| | | | | | | | Make arch_uprobe_task->saved_trap_nr "unsigned int" and move it down after ->saved_scratch_register, this changes sizeof() from 24 to 16. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes/x86: Fix arch_uprobe_disable_step() && UTASK_SSTEP_TRAPPED interactionOleg Nesterov2012-10-291-4/+10
| | | | | | | | | | | | arch_uprobe_disable_step() should also take UTASK_SSTEP_TRAPPED into account. In this case the probed insn was not executed, we need to clear X86_EFLAGS_TF if it was set by us and that is all. Again, this code will look more clean when we move it into arch_uprobe_post_xol() and arch_uprobe_abort_xol(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes/x86: Xol should send SIGTRAP if X86_EFLAGS_TF was setOleg Nesterov2012-10-292-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | arch_uprobe_disable_step() correctly preserves X86_EFLAGS_TF and returns to user-mode. But this means the application gets SIGTRAP only after the next insn. This means that UPROBE_CLEAR_TF logic is not really right. _enable should only record the state of X86_EFLAGS_TF, and _disable should check it separately from UPROBE_FIX_SETF. Remove arch_uprobe_task->restore_flags, add ->saved_tf instead, and change enable/disable accordingly. This assumes that the probed insn was not trapped, see the next patch. arch_uprobe_skip_sstep() logic has the same problem, change it to check X86_EFLAGS_TF and send SIGTRAP as well. We will cleanup this all after we fold enable/disable_step into pre/post_hol hooks. Note: send_sig(SIGTRAP) is not actually right, we need send_sigtrap(). But this needs more changes, handle_swbp() does the same and this is equally wrong. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes/x86: Do not (ab)use TIF_SINGLESTEP/user_*_single_step() for ↵Oleg Nesterov2012-10-293-15/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | single-stepping user_enable/disable_single_step() was designed for ptrace, it assumes a single user and does unnecessary and wrong things for uprobes. For example: - arch_uprobe_enable_step() can't trust TIF_SINGLESTEP, an application itself can set X86_EFLAGS_TF which must be preserved after arch_uprobe_disable_step(). - we do not want to set TIF_SINGLESTEP/TIF_FORCED_TF in arch_uprobe_enable_step(), this only makes sense for ptrace. - otoh we leak TIF_SINGLESTEP if arch_uprobe_disable_step() doesn't do user_disable_single_step(), the application will be killed after the next syscall. - arch_uprobe_enable_step() does access_process_vm() we do not need/want. Change arch_uprobe_enable/disable_step() to set/clear X86_EFLAGS_TF directly, this is much simpler and more correct. However, we need to clear TIF_BLOCKSTEP/DEBUGCTLMSR_BTF before executing the probed insn, add set_task_blockstep(false). Note: with or without this patch, there is another (hopefully minor) problem. A probed "pushf" insn can see the wrong X86_EFLAGS_TF set by uprobes. Perhaps we should change _disable to update the stack, or teach arch_uprobe_skip_sstep() to emulate this insn. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* ptrace/x86: Partly fix set_task_blockstep()->update_debugctlmsr() logicOleg Nesterov2012-10-291-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Afaics the usage of update_debugctlmsr() and TIF_BLOCKSTEP in step.c was always very wrong. 1. update_debugctlmsr() was simply unneeded. The child sleeps TASK_TRACED, __switch_to_xtra(next_p => child) should notice TIF_BLOCKSTEP and set/clear DEBUGCTLMSR_BTF after resume if needed. 2. It is wrong. The state of DEBUGCTLMSR_BTF bit in CPU register should always match the state of current's TIF_BLOCKSTEP bit. 3. Even get_debugctlmsr() + update_debugctlmsr() itself does not look right. Irq can change other bits in MSR_IA32_DEBUGCTLMSR register or the caller can be preempted in between. 4. It is not safe to play with TIF_BLOCKSTEP if task != current. DEBUGCTLMSR_BTF and TIF_BLOCKSTEP should always match each other if the task is running. The tracee is stopped but it can be SIGKILL'ed right before set/clear_tsk_thread_flag(). However, now that uprobes uses user_enable_single_step(current) we can't simply remove update_debugctlmsr(). So this patch adds the additional "task == current" check and disables irqs to avoid the race with interrupts/preemption. Unfortunately this patch doesn't solve the last problem, we need another fix. Probably we should teach ptrace_stop() to set/clear single/block stepping after resume. And afaics there is yet another problem: perf can play with MSR_IA32_DEBUGCTLMSR from nmi, this obviously means that even __switch_to_xtra() has problems. Signed-off-by: Oleg Nesterov <oleg@redhat.com>
* ptrace/x86: Introduce set_task_blockstep() helperOleg Nesterov2012-10-291-20/+21
| | | | | | | | | | | No functional changes, preparation for the next fix and for uprobes single-step fixes. Move the code playing with TIF_BLOCKSTEP/DEBUGCTLMSR_BTF into the new helper, set_task_blockstep(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* uprobes/x86: Implement x86 specific arch_uprobe_*_stepSebastian Andrzej Siewior2012-10-292-0/+35
| | | | | | | | | | | | | | | | | | The arch specific implementation behaves like user_enable_single_step() except that it does not disable single stepping if it was already enabled by ptrace. This allows the debugger to single step over an uprobe. The state of block stepping is not restored. It makes only sense together with TF and if that was enabled then the debugger is notified. Note: this is still not correct. For example, TIF_SINGLESTEP check is not right, the application itself can set X86_EFLAGS_TF. And otoh we leak TIF_SINGLESTEP (set by enable) if the probed insn is "popf". See the next patches, we need the changes in arch/x86/kernel/step.c first. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
* fedora kernel: cd394142aac30b5c751f25b517572e2448695641v3.6.3-2f17Anton Arapov2012-10-292093-32889/+66178
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: 021ce7bee3cfdcbf16da1256b2c9f40f7e9bbd9ev3.5.3-1Anton Arapov2012-09-1237-148/+389
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: 222b075b3ff0d9e88aa9353e3c80667756ed7361v3.5.0-4Anton Arapov2012-08-072834-89605/+98449
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: 6c6f1b8594284404f143c407081ebe65fe068c81v3.4.4-1Anton Arapov2012-06-2513-4/+822
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: 3d47c715a4a94b9d700c9e4ec1fc3a786bfde746v3.4.3-3Anton Arapov2012-06-216-25/+64
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: a8283add14054ab2cdd473edb61f21ff05848650v3.4.2-1Anton Arapov2012-06-1212-118/+96
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: b920e9b748c595f970bf80ede7832d39f8d567dav3.4.1-2Anton Arapov2012-06-083600-66964/+75499
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: be402e5a53d5ac42b5a17e0a207dae63a67f2786v3.3.6-1Anton Arapov2012-05-1515-58/+84
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: 5963c7872d2bee76ac20ba1ccd2ffbbfe9eb5f8bv3.3.5-2Anton Arapov2012-05-0940-166/+266
| | | | Signed-off-by: Anton Arapov <anton@redhat.com>
* fedora kernel: d9aad82f3319f3cfd1aebc01234254ef0c37ad84v3.3.2-1Anton Arapov2012-04-1614811-0/+2962283
Signed-off-by: Anton Arapov <anton@redhat.com>