[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150504124914.GA22512@redhat.com>
Date: Mon, 4 May 2015 14:49:14 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Ananth N Mavinakayanahalli <ananth@...ibm.com>,
Anton Arapov <arapov@...il.com>,
David Long <dave.long@...aro.org>,
Denys Vlasenko <dvlasenk@...hat.com>,
"Frank Ch. Eigler" <fche@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Jan Willeke <willeke@...ibm.com>,
Jim Keniston <jkenisto@...ibm.com>,
Mark Wielaard <mjw@...hat.com>,
Pratyush Anand <panand@...hat.com>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 07/10] uprobes/x86: Introduce arch_uretprobe_is_alive()
Add the x86-specific arch_uretprobe_is_alive() helper and define its
"weak" version for other architectures.
It returns true if the stack frame mangled by prepare_uretprobe() is
still on stack. So if it returns false, we know that the probed func
has already returned.
TODO: this assumes that the probed app can't use multiple stacks (say
sigaltstack). We will try to improve this logic later.
Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
arch/x86/include/asm/uprobes.h | 1 +
arch/x86/kernel/uprobes.c | 6 ++++++
include/linux/uprobes.h | 1 +
kernel/events/uprobes.c | 4 ++++
4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h
index f011fd0..60777f3 100644
--- a/arch/x86/include/asm/uprobes.h
+++ b/arch/x86/include/asm/uprobes.h
@@ -57,6 +57,7 @@ struct arch_uprobe {
};
struct arch_uretprobe {
+ unsigned long sp;
};
struct arch_uprobe_task {
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 0270315..868dc47 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -907,6 +907,7 @@ arch_uretprobe_hijack_return_addr(struct arch_uretprobe *auret,
int rasize = sizeof_long(), nleft;
unsigned long orig_ret_vaddr = 0; /* clear high bits for 32-bit apps */
+ auret->sp = regs->sp;
if (copy_from_user(&orig_ret_vaddr, (void __user *)regs->sp, rasize))
return -1;
@@ -927,3 +928,8 @@ arch_uretprobe_hijack_return_addr(struct arch_uretprobe *auret,
return -1;
}
+
+bool arch_uretprobe_is_alive(struct arch_uretprobe *auret, struct pt_regs *regs)
+{
+ return regs->sp <= auret->sp;
+}
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index 144571b..1ed7502 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -129,6 +129,7 @@ extern int arch_uprobe_exception_notify(struct notifier_block *self, unsigned l
extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs *regs);
extern unsigned long arch_uretprobe_hijack_return_addr(struct arch_uretprobe *auret,
unsigned long trampoline_vaddr, struct pt_regs *regs);
+extern bool arch_uretprobe_is_alive(struct arch_uretprobe *auret, struct pt_regs *regs);
extern bool arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs);
extern void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
void *src, unsigned long len);
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 19af44a..0f68ea2 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1820,6 +1820,10 @@ bool __weak arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs)
return false;
}
+bool __weak arch_uretprobe_is_alive(struct arch_uretprobe *auret, struct pt_regs *regs)
+{
+ return true;
+}
/*
* Run handler and ask thread to singlestep.
* Ensure all non-fatal signals cannot interrupt thread while it singlesteps.
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists