diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-04-21 12:28:02 -0400 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2014-04-30 13:10:37 -0400 |
commit | 6ded5f3848bfd3227ee208aa38f8bf8d7209d4e3 (patch) | |
tree | bb62c3b9f2b4a2be01581d9563df31bafb510f3b /arch/x86 | |
parent | 588fbd613c3d8fa73e96720761d49f1d40d34d4c (diff) |
uprobes/x86: Don't use arch_uprobe_abort_xol() in arch_uprobe_post_xol()
014940bad8e4 "uprobes/x86: Send SIGILL if arch_uprobe_post_xol() fails"
changed arch_uprobe_post_xol() to use arch_uprobe_abort_xol() if ->post_xol
fails. This was correct and helped to avoid the additional complications,
we need to clear X86_EFLAGS_TF in this case.
However, now that we have uprobe_xol_ops->abort() hook it would be better
to avoid arch_uprobe_abort_xol() here. ->post_xol() should likely do what
->abort() does anyway, we should not do the same work twice. Currently only
handle_riprel_post_xol() can be called twice, this is unnecessary but safe.
Still this is not clean and can lead to the problems in future.
Change arch_uprobe_post_xol() to clear X86_EFLAGS_TF and restore ->ip by
hand and avoid arch_uprobe_abort_xol(). This temporary uglifies the usage
of autask.saved_tf, we will cleanup this later.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jim Keniston <jkenisto@us.ibm.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/uprobes.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index b3c2a92cce6c..2efb93f96030 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c | |||
@@ -759,22 +759,24 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) | |||
759 | struct uprobe_task *utask = current->utask; | 759 | struct uprobe_task *utask = current->utask; |
760 | 760 | ||
761 | WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); | 761 | WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); |
762 | current->thread.trap_nr = utask->autask.saved_trap_nr; | ||
762 | 763 | ||
763 | if (auprobe->ops->post_xol) { | 764 | if (auprobe->ops->post_xol) { |
764 | int err = auprobe->ops->post_xol(auprobe, regs); | 765 | int err = auprobe->ops->post_xol(auprobe, regs); |
765 | if (err) { | 766 | if (err) { |
766 | arch_uprobe_abort_xol(auprobe, regs); | 767 | if (!utask->autask.saved_tf) |
768 | regs->flags &= ~X86_EFLAGS_TF; | ||
767 | /* | 769 | /* |
768 | * Restart the probed insn. ->post_xol() must ensure | 770 | * Restore ->ip for restart or post mortem analysis. |
769 | * this is really possible if it returns -ERESTART. | 771 | * ->post_xol() must not return -ERESTART unless this |
772 | * is really possible. | ||
770 | */ | 773 | */ |
774 | regs->ip = utask->vaddr; | ||
771 | if (err == -ERESTART) | 775 | if (err == -ERESTART) |
772 | return 0; | 776 | return 0; |
773 | return err; | 777 | return err; |
774 | } | 778 | } |
775 | } | 779 | } |
776 | |||
777 | current->thread.trap_nr = utask->autask.saved_trap_nr; | ||
778 | /* | 780 | /* |
779 | * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP | 781 | * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP |
780 | * so we can get an extra SIGTRAP if we do not clear TF. We need | 782 | * so we can get an extra SIGTRAP if we do not clear TF. We need |
@@ -819,9 +821,8 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val, | |||
819 | 821 | ||
820 | /* | 822 | /* |
821 | * This function gets called when XOL instruction either gets trapped or | 823 | * This function gets called when XOL instruction either gets trapped or |
822 | * the thread has a fatal signal, or if arch_uprobe_post_xol() failed. | 824 | * the thread has a fatal signal. Reset the instruction pointer to its |
823 | * Reset the instruction pointer to its probed address for the potential | 825 | * probed address for the potential restart or for post mortem analysis. |
824 | * restart or for post mortem analysis. | ||
825 | */ | 826 | */ |
826 | void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) | 827 | void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) |
827 | { | 828 | { |