linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL for 4.9 005/219] kretprobes: Ensure probe location is at function entry
       [not found] <20180303222716.26640-1-alexander.levin@microsoft.com>
@ 2018-03-03 22:27 ` Sasha Levin
  2018-03-05  7:02   ` Naveen N. Rao
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2018-03-03 22:27 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Naveen N. Rao, Ananth N Mavinakayanahalli, Michael Ellerman,
	Steven Rostedt, linuxppc-dev, Arnaldo Carvalho de Melo,
	Sasha Levin

From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>

[ Upstream commit 90ec5e89e393c76e19afc845d8f88a5dc8315919 ]

kretprobes can be registered by specifying an absolute address or by
specifying offset to a symbol. However, we need to ensure this falls at
function entry so as to be able to determine the return address.

Validate the same during kretprobe registration. By default, there
should not be any offset from a function entry, as determined through a
kallsyms_lookup(). Introduce arch_function_offset_within_entry() as a
way for architectures to override this.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/f1583bc4839a3862cfc2acefcc56f9c8837fa2ba.148=
7770934.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 include/linux/kprobes.h |  1 +
 kernel/kprobes.c        | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e23392517db9..56a998f34bdd 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -266,6 +266,7 @@ extern int arch_init_kprobes(void);
 extern void show_registers(struct pt_regs *regs);
 extern void kprobes_inc_nmissed_count(struct kprobe *p);
 extern bool arch_within_kprobe_blacklist(unsigned long addr);
+extern bool arch_function_offset_within_entry(unsigned long offset);
=20
 extern bool within_kprobe_blacklist(unsigned long addr);
=20
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a1a07cf1101f..2ede39e4227f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1834,12 +1834,25 @@ static int pre_handler_kretprobe(struct kprobe *p, =
struct pt_regs *regs)
 }
 NOKPROBE_SYMBOL(pre_handler_kretprobe);
=20
+bool __weak arch_function_offset_within_entry(unsigned long offset)
+{
+	return !offset;
+}
+
 int register_kretprobe(struct kretprobe *rp)
 {
 	int ret =3D 0;
 	struct kretprobe_instance *inst;
 	int i;
 	void *addr;
+	unsigned long offset;
+
+	addr =3D kprobe_addr(&rp->kp);
+	if (!kallsyms_lookup_size_offset((unsigned long)addr, NULL, &offset))
+		return -EINVAL;
+
+	if (!arch_function_offset_within_entry(offset))
+		return -EINVAL;
=20
 	if (kretprobe_blacklist_size) {
 		addr =3D kprobe_addr(&rp->kp);
--=20
2.14.1

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

* Re: [PATCH AUTOSEL for 4.9 005/219] kretprobes: Ensure probe location is at function entry
  2018-03-03 22:27 ` [PATCH AUTOSEL for 4.9 005/219] kretprobes: Ensure probe location is at function entry Sasha Levin
@ 2018-03-05  7:02   ` Naveen N. Rao
  2018-03-05 20:06     ` Sasha Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Naveen N. Rao @ 2018-03-05  7:02 UTC (permalink / raw)
  To: Sasha Levin, linux-kernel, stable
  Cc: Arnaldo Carvalho de Melo, Ananth N Mavinakayanahalli,
	linuxppc-dev, Michael Ellerman, Steven Rostedt, Masami Hiramatsu

Hi Sasha,

Sasha Levin wrote:
> From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
>=20
> [ Upstream commit 90ec5e89e393c76e19afc845d8f88a5dc8315919 ]
>=20

Sorry if this is obvious, but why was this patch picked up for -stable? =20
I don't see the upstream commit tagging -stable, so curious why this was=20
done.

I don't think this patch should be pushed to -stable since this is not=20
really a bug fix. There are also other dependencies for this change (see=20
commit a64e3f35a45f4a, for instance), including how userspace (perf)=20
builds out the retprobe argument. As such, please drop this from -stable=20
(for 3.18. 4.4 and 4.9).

Thanks,
Naveen

=

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

* Re: [PATCH AUTOSEL for 4.9 005/219] kretprobes: Ensure probe location is at function entry
  2018-03-05  7:02   ` Naveen N. Rao
@ 2018-03-05 20:06     ` Sasha Levin
  0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2018-03-05 20:06 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: linux-kernel, stable, Arnaldo Carvalho de Melo,
	Ananth N Mavinakayanahalli, linuxppc-dev, Michael Ellerman,
	Steven Rostedt, Masami Hiramatsu

On Mon, Mar 05, 2018 at 12:32:57PM +0530, Naveen N. Rao wrote:
>Hi Sasha,
>
>Sasha Levin wrote:
>>From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
>>
>>[ Upstream commit 90ec5e89e393c76e19afc845d8f88a5dc8315919 ]
>>
>
>Sorry if this is obvious, but why was this patch picked up for=20
>-stable?  I don't see the upstream commit tagging -stable, so curious=20
>why this was done.
>
>I don't think this patch should be pushed to -stable since this is not=20
>really a bug fix. There are also other dependencies for this change=20
>(see commit a64e3f35a45f4a, for instance), including how userspace=20
>(perf) builds out the retprobe argument. As such, please drop this=20
>from -stable (for 3.18. 4.4 and 4.9).

Hi Naveen,

It's an automatic selection process that attempts to find commits that
should be in stable but weren't tagged as such.

I'll drop this patch, thanks!

--=20

Thanks,
Sasha=

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

end of thread, other threads:[~2018-03-05 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180303222716.26640-1-alexander.levin@microsoft.com>
2018-03-03 22:27 ` [PATCH AUTOSEL for 4.9 005/219] kretprobes: Ensure probe location is at function entry Sasha Levin
2018-03-05  7:02   ` Naveen N. Rao
2018-03-05 20:06     ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).