]> git.pld-linux.org Git - packages/lttng-modules.git/blob - 0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch
- upstream fixes for kernel 5.18 compatibility, rel 2
[packages/lttng-modules.git] / 0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch
1 From 3c46ddc134621dba65030263aa321dd6bdae3ba3 Mon Sep 17 00:00:00 2001
2 From: Michael Jeanson <mjeanson@efficios.com>
3 Date: Mon, 4 Apr 2022 15:02:10 -0400
4 Subject: [PATCH 07/13] fix: kprobes: Use rethook for kretprobe if possible
5  (v5.18)
6
7 See upstream commit :
8
9   commit 73f9b911faa74ac5107879de05c9489c419f41bb
10   Author: Masami Hiramatsu <mhiramat@kernel.org>
11   Date:   Sat Mar 26 11:27:05 2022 +0900
12
13     kprobes: Use rethook for kretprobe if possible
14
15     Use rethook for kretprobe function return hooking if the arch sets
16     CONFIG_HAVE_RETHOOK=y. In this case, CONFIG_KRETPROBE_ON_RETHOOK is
17     set to 'y' automatically, and the kretprobe internal data fields
18     switches to use rethook. If not, it continues to use kretprobe
19     specific function return hooks.
20
21 Change-Id: I2b7670dc04e4769c1e3c372582ad2f555f6d7a66
22 Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
23 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
24 ---
25  include/wrapper/kprobes.h     | 17 +++++++++++++++++
26  src/probes/lttng-kretprobes.c |  2 +-
27  2 files changed, 18 insertions(+), 1 deletion(-)
28
29 diff --git a/include/wrapper/kprobes.h b/include/wrapper/kprobes.h
30 index b546d615..51d32b7c 100644
31 --- a/include/wrapper/kprobes.h
32 +++ b/include/wrapper/kprobes.h
33 @@ -29,4 +29,21 @@ struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri)
34  
35  #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0) */
36  
37 +
38 +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
39 +static inline
40 +unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri)
41 +{
42 +       return get_kretprobe_retaddr(ri);
43 +}
44 +
45 +#else
46 +
47 +static inline
48 +unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri)
49 +{
50 +       return (unsigned long) ri->ret_addr;
51 +}
52 +#endif
53 +
54  #endif /* _LTTNG_WRAPPER_KPROBES_H */
55 diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c
56 index 5cb2e953..565df739 100644
57 --- a/src/probes/lttng-kretprobes.c
58 +++ b/src/probes/lttng-kretprobes.c
59 @@ -81,7 +81,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
60                 int ret;
61  
62                 payload.ip = (unsigned long) lttng_get_kretprobe(krpi)->kp.addr;
63 -               payload.parent_ip = (unsigned long) krpi->ret_addr;
64 +               payload.parent_ip = lttng_get_kretprobe_retaddr(krpi);
65  
66                 lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(payload),
67                                          lttng_alignof(payload), &lttng_probe_ctx);
68 -- 
69 2.36.1
70
This page took 0.053821 seconds and 3 git commands to generate.