All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kretprobes: reject registration if a symbol offset is specified
@ 2017-02-14  8:31 Naveen N. Rao
  2017-02-14  8:41 ` Ananth N Mavinakayanahalli
  2017-02-14 10:32 ` Masami Hiramatsu
  0 siblings, 2 replies; 25+ messages in thread
From: Naveen N. Rao @ 2017-02-14  8:31 UTC (permalink / raw)
  To: Ananth N Mavinakayanahalli, Masami Hiramatsu, Ingo Molnar; +Cc: linux-kernel

Users shouldn't be able to specify an offset with kretprobes, as we always
want to probe at function entry. Otherwise, we won't be able to capture
the proper return address resulting in the kretprobe never firing.

With samples/kprobes/kretprobe_example.c including an offset:
	my_kretprobe.kp.offset = 40;

Before this patch, the probe gets planted but never fires.

After this patch:
	$ sudo insmod samples/kprobes/kretprobe_example.ko
	[sudo] password for naveen: 
	insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted

And dmesg:
	[48253.757629] register_kretprobe failed, returned -22

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 kernel/kprobes.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 60a702a05684..83ad7e440417 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1847,6 +1847,9 @@ int register_kretprobe(struct kretprobe *rp)
 	int i;
 	void *addr;
 
+	if (rp->kp.offset)
+		return -EINVAL;
+
 	if (kretprobe_blacklist_size) {
 		addr = kprobe_addr(&rp->kp);
 		if (IS_ERR(addr))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2017-02-22 13:40 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-14  8:31 [PATCH] kretprobes: reject registration if a symbol offset is specified Naveen N. Rao
2017-02-14  8:41 ` Ananth N Mavinakayanahalli
2017-02-14 10:32 ` Masami Hiramatsu
2017-02-15 17:53   ` Naveen N. Rao
2017-02-15 18:17     ` [PATCH 1/3] kretprobes: ensure probe location is at function entry Naveen N. Rao
2017-02-15 18:17       ` [PATCH 2/3] trace/kprobes: allow return probes with offsets and absolute addresses Naveen N. Rao
2017-02-15 23:43         ` Masami Hiramatsu
2017-02-15 18:17       ` [PATCH 3/3] perf: revert "perf probe: Fix probing kretprobes" Naveen N. Rao
2017-02-15 23:43         ` Masami Hiramatsu
2017-02-15 23:39       ` [PATCH 1/3] kretprobes: ensure probe location is at function entry Masami Hiramatsu
2017-02-16  7:51         ` Naveen N. Rao
2017-02-16  8:17       ` [PATCH 0/2] powerpc: kretprobe updates Naveen N. Rao
2017-02-16  8:17         ` [PATCH 1/2] powerpc: kretprobes: override default function entry offset Naveen N. Rao
2017-02-16  8:17         ` [PATCH 2/2] perf: powerpc: choose LEP with kretprobes Naveen N. Rao
2017-02-17 10:44         ` [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu
2017-02-17 20:42           ` Arnaldo Carvalho de Melo
2017-02-17 20:50             ` PowerMac G5 Quad Strage lspci luigi burdo
2017-02-19  4:42             ` [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu
2017-02-20  9:50               ` Naveen N. Rao
2017-02-21 13:07                 ` Masami Hiramatsu
2017-02-22 13:39                   ` Naveen N. Rao
2017-02-20  9:46             ` Naveen N. Rao
2017-02-20 11:43             ` Naveen N. Rao
2017-02-21 13:06               ` Masami Hiramatsu
2017-02-15 23:28     ` [PATCH] kretprobes: reject registration if a symbol offset is specified Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.