summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2021-05-15 11:45:32 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-16 08:29:59 +0100
commit4f7ea3fef7278d0f1f521b346a2cbe87aa2b9202 (patch)
treed29f7990c44f31c077903030aebdc7ba3c056baf /meta
parentf98ea33f637a95d166691d1dfa2fe546be840d4d (diff)
downloadpoky-4f7ea3fef7278d0f1f521b346a2cbe87aa2b9202.tar.gz
lttng-modules: update to v2.12.6
To support building against v5.12+ and v5.13+ kernels, bumping to the v2.12.6 lttng-release. We drop the previously backported patches, and bring in the following commits: 0d8e4ab9 Version 2.12.6 78f56ae3 fix: adjust ranges for RHEL 8.2 and 8.3 4c996ea7 Disable block rwbs bitwise enum in default build 4ac46085 Disable sched_switch bitwise enum in default build 5e22c27b Add experimental bitwise enum config option 937d307e Add defaults to Kconfig options 4a114d43 Sync `show_inode_state()` macro with upstream stable kernels 3bd6ac3e fix: block: remove disk_part_iter (v5.12) 8bbb8c9d Fix: Backport of "Fix: increment buffer offset when failing to copy from user-space" 30cddf69 Fix: increment buffer offset when failing to copy from user-space 4733b9ab Sync `show_inode_state()` macro with Ubuntu 4.15 kernel ff21ec48 fix: mm, tracing: kfree event name mismatching with provider kmem (v5.12) b2b02c29 Set 'stable-2.12' branch in git review config 00b42dbf fix backport: block: add a disk_uevent helper (v5.12) 771ff089 fix: Adjust ranges for Ubuntu 5.4.0-67 kernel d8933959 fix: block: add a disk_uevent helper (v5.12) 71034df1 Fix: properly compare type enumeration 4d879d23 compiler warning cleanup: is_signed_type: compare -1 to 1 fead3a9c Fix: bytecode linker: validate event and field array/sequence encoding 92cc3e7f Fix: kretprobe: null ptr deref on session destroy 49c603ef fix: mm, tracing: record slab name for kmem_cache_free() (v5.12) 23a2f61f Fix: filter interpreter early-exits on uninitialized value b3fdf78b Fix: memory leaks on event destroy (From OE-Core rev: c2f027b8e2f842915a0ffdfd6c2c0597f3b02bce) Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch58
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch159
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch91
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch41
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0005-fix-block-add-a-disk_uevent-helper-v5.12.patch305
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0006-fix-backport-block-add-a-disk_uevent-helper-v5.12.patch48
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0007-fix-mm-tracing-kfree-event-name-mismatching-with-pro.patch71
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules_2.12.6.bb (renamed from meta/recipes-kernel/lttng/lttng-modules_2.12.5.bb)9
8 files changed, 1 insertions, 781 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch
deleted file mode 100644
index 21da932a75..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From b3fdf78b15beb940918da1e41eb68e24ba31bb87 Mon Sep 17 00:00:00 2001
2From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3Date: Wed, 3 Mar 2021 10:10:16 -0500
4Subject: [PATCH 1/4] Fix: memory leaks on event destroy
5
6Both filter runtime and event enabler ref objects are owned by the
7event, but are not freed upon destruction of the event object, thus
8leaking memory.
9
10Upstream-status: backport
11
12Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13Change-Id: Ice9b1c18b47584838aea2b965494d3c8391f4c84
14---
15 lttng-events.c | 7 +++++++
16 lttng-events.h | 1 +
17 2 files changed, 8 insertions(+)
18
19diff --git a/lttng-events.c b/lttng-events.c
20index f3398adc..984bd341 100644
21--- a/lttng-events.c
22+++ b/lttng-events.c
23@@ -919,6 +919,8 @@ int _lttng_event_unregister(struct lttng_event *event)
24 static
25 void _lttng_event_destroy(struct lttng_event *event)
26 {
27+ struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
28+
29 switch (event->instrumentation) {
30 case LTTNG_KERNEL_TRACEPOINT:
31 lttng_event_put(event->desc);
32@@ -944,6 +946,11 @@ void _lttng_event_destroy(struct lttng_event *event)
33 }
34 list_del(&event->list);
35 lttng_destroy_context(event->ctx);
36+ lttng_free_event_filter_runtime(event);
37+ /* Free event enabler refs */
38+ list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
39+ &event->enablers_ref_head, node)
40+ kfree(enabler_ref);
41 kmem_cache_free(event_cache, event);
42 }
43
44diff --git a/lttng-events.h b/lttng-events.h
45index 1b9ab167..13b6abf5 100644
46--- a/lttng-events.h
47+++ b/lttng-events.h
48@@ -716,6 +716,7 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
49 struct lttng_kernel_filter_bytecode __user *bytecode);
50 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
51 struct lttng_enabler *enabler);
52+void lttng_free_event_filter_runtime(struct lttng_event *event);
53
54 int lttng_probes_init(void);
55
56--
572.19.1
58
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch b/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch
deleted file mode 100644
index 609690f05c..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch
+++ /dev/null
@@ -1,159 +0,0 @@
1From 23a2f61ffc6a656f136fa2044c0c3b8f79766779 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=
3 <jeremie.galarneau@efficios.com>
4Date: Wed, 3 Mar 2021 18:52:19 -0500
5Subject: [PATCH 2/4] Fix: filter interpreter early-exits on uninitialized
6 value
7MIME-Version: 1.0
8Content-Type: text/plain; charset=UTF-8
9Content-Transfer-Encoding: 8bit
10
11I observed that syscall filtering on string arguments wouldn't work on
12my development machines, both running 5.11.2-arch1-1 (Arch Linux).
13
14For instance, enabling the tracing of the `openat()` syscall with the
15'filename == "/proc/cpuinfo"' filter would not produce events even
16though matching events were present in another session that had no
17filtering active. The same problem occurred with `execve()`.
18
19I tried a couple of kernel versions before (5.11.1 and 5.10.13, if
20memory serves me well) and I had the same problem. Meanwhile, I couldn't
21reproduce the problem on various Debian machines (the LTTng CI) nor on a
22fresh Ubuntu 20.04 with both the stock kernel and with an updated 5.11.2
23kernel.
24
25I built the lttng-modules with the interpreter debugging printout and
26saw the following warning:
27 LTTng: [debug bytecode in /home/jgalar/EfficiOS/src/lttng-modules/src/lttng-bytecode-interpreter.c:bytecode_interpret@1508] Bytecode warning: loading a NULL string.
28
29After a shedload (yes, a _shed_load) of digging, I figured that the
30problem was hidden in plain sight near that logging statement.
31
32In the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING` operation, the 'ax'
33register's 'user_str' is initialized with the stack value (the user
34space string's address in our case). However, a NULL check is performed
35against the register's 'str' member.
36
37I initialy suspected that both members would be part of the same union
38and alias each-other, but they are actually contiguous in a structure.
39
40On the unaffected machines, I could confirm that the `str` member was
41uninitialized to a non-zero value causing the condition to evaluate to
42false.
43
44Francis Deslauriers reproduced the problem by initializing the
45interpreter stack to zero.
46
47I am unsure of the exact kernel configuration option that reveals this
48issue on Arch Linux, but my kernel has the following option enabled:
49
50CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL:
51 Zero-initialize any stack variables that may be passed by reference
52 and had not already been explicitly initialized. This is intended to
53 eliminate all classes of uninitialized stack variable exploits and
54 information exposures.
55
56I have not tried to build without this enabled as, anyhow, this seems
57to be a legitimate issue.
58
59I have spotted what appears to be an identical problem in
60`BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE` and corrected it. However,
61I have not exercised that code path.
62
63The commit that introduced this problem is 5b4ad89.
64
65The debug print-out of the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING`
66operation is modified to print the user string (truncated to 31 chars).
67
68Upstream-status: backport
69
70Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
71Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
72Change-Id: I2da3c31b9e3ce0e1b164cf3d2711c0893cbec273
73---
74 lttng-filter-interpreter.c | 41 ++++++++++++++++++++++++++++++++++----
75 1 file changed, 37 insertions(+), 4 deletions(-)
76
77diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c
78index 5d572437..6e5a5139 100644
79--- a/lttng-filter-interpreter.c
80+++ b/lttng-filter-interpreter.c
81@@ -22,7 +22,7 @@ LTTNG_STACK_FRAME_NON_STANDARD(lttng_filter_interpret_bytecode);
82 * to handle user-space read.
83 */
84 static
85-char get_char(struct estack_entry *reg, size_t offset)
86+char get_char(const struct estack_entry *reg, size_t offset)
87 {
88 if (unlikely(offset >= reg->u.s.seq_len))
89 return '\0';
90@@ -593,6 +593,39 @@ end:
91 return ret;
92 }
93
94+#ifdef DEBUG
95+
96+#define DBG_USER_STR_CUTOFF 32
97+
98+/*
99+ * In debug mode, print user string (truncated, if necessary).
100+ */
101+static inline
102+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg)
103+{
104+ size_t pos = 0;
105+ char last_char;
106+ char user_str[DBG_USER_STR_CUTOFF];
107+
108+ pagefault_disable();
109+ do {
110+ last_char = get_char(user_str_reg, pos);
111+ user_str[pos] = last_char;
112+ pos++;
113+ } while (last_char != '\0' && pos < sizeof(user_str));
114+ pagefault_enable();
115+
116+ user_str[sizeof(user_str) - 1] = '\0';
117+ dbg_printk("load field ref user string: '%s%s'\n", user_str,
118+ last_char != '\0' ? "[...]" : "");
119+}
120+#else
121+static inline
122+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg)
123+{
124+}
125+#endif
126+
127 /*
128 * Return 0 (discard), or raise the 0x1 flag (log event).
129 * Currently, other flags are kept for future extensions and have no
130@@ -1313,7 +1346,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
131 estack_push(stack, top, ax, bx);
132 estack_ax(stack, top)->u.s.user_str =
133 *(const char * const *) &filter_stack_data[ref->offset];
134- if (unlikely(!estack_ax(stack, top)->u.s.str)) {
135+ if (unlikely(!estack_ax(stack, top)->u.s.user_str)) {
136 dbg_printk("Filter warning: loading a NULL string.\n");
137 ret = -EINVAL;
138 goto end;
139@@ -1322,7 +1355,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
140 estack_ax(stack, top)->u.s.literal_type =
141 ESTACK_STRING_LITERAL_TYPE_NONE;
142 estack_ax(stack, top)->u.s.user = 1;
143- dbg_printk("ref load string %s\n", estack_ax(stack, top)->u.s.str);
144+ dbg_load_ref_user_str_printk(estack_ax(stack, top));
145 next_pc += sizeof(struct load_op) + sizeof(struct field_ref);
146 PO;
147 }
148@@ -1340,7 +1373,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
149 estack_ax(stack, top)->u.s.user_str =
150 *(const char **) (&filter_stack_data[ref->offset
151 + sizeof(unsigned long)]);
152- if (unlikely(!estack_ax(stack, top)->u.s.str)) {
153+ if (unlikely(!estack_ax(stack, top)->u.s.user_str)) {
154 dbg_printk("Filter warning: loading a NULL sequence.\n");
155 ret = -EINVAL;
156 goto end;
157--
1582.19.1
159
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch b/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch
deleted file mode 100644
index 71f99b80a3..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch
+++ /dev/null
@@ -1,91 +0,0 @@
1From 49c603ef2dc6969f4454f0d849af00ee24bb7f04 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Thu, 4 Mar 2021 16:50:12 -0500
4Subject: [PATCH 3/4] fix: mm, tracing: record slab name for kmem_cache_free()
5 (v5.12)
6
7See upstream commit:
8
9 commit 3544de8ee6e4817278b15fe08658de49abf58954
10 Author: Jacob Wen <jian.w.wen@oracle.com>
11 Date: Wed Feb 24 12:00:55 2021 -0800
12
13 mm, tracing: record slab name for kmem_cache_free()
14
15 Currently, a trace record generated by the RCU core is as below.
16
17 ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f3b49a66
18
19 It doesn't tell us what the RCU core has freed.
20
21 This patch adds the slab name to trace_kmem_cache_free().
22 The new format is as follows.
23
24 ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000037f79c8d name=dentry
25 ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f78cb7b5 name=sock_inode_cache
26 ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000018768985 name=pool_workqueue
27 ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=000000006a6cb484 name=radix_tree_node
28
29 We can use it to understand what the RCU core is going to free. For
30 example, some users maybe interested in when the RCU core starts
31 freeing reclaimable slabs like dentry to reduce memory pressure.
32
33 Link: https://lkml.kernel.org/r/20201216072804.8838-1-jian.w.wen@oracle.com
34
35Upstream-status: backport
36
37Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
38Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
39Change-Id: I1ee2fc476614cadcc8d3ac5d8feddc7910e1aa3a
40---
41 instrumentation/events/lttng-module/kmem.h | 27 ++++++++++++++++++++++
42 1 file changed, 27 insertions(+)
43
44diff --git a/instrumentation/events/lttng-module/kmem.h b/instrumentation/events/lttng-module/kmem.h
45index b134620a..d787ea54 100644
46--- a/instrumentation/events/lttng-module/kmem.h
47+++ b/instrumentation/events/lttng-module/kmem.h
48@@ -87,6 +87,32 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_alloc_node, kmem_cache_alloc_node,
49 TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
50 )
51
52+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,12,0))
53+LTTNG_TRACEPOINT_EVENT(kfree,
54+
55+ TP_PROTO(unsigned long call_site, const void *ptr),
56+
57+ TP_ARGS(call_site, ptr),
58+
59+ TP_FIELDS(
60+ ctf_integer_hex(unsigned long, call_site, call_site)
61+ ctf_integer_hex(const void *, ptr, ptr)
62+ )
63+)
64+
65+LTTNG_TRACEPOINT_EVENT(kmem_cache_free,
66+
67+ TP_PROTO(unsigned long call_site, const void *ptr, const char *name),
68+
69+ TP_ARGS(call_site, ptr, name),
70+
71+ TP_FIELDS(
72+ ctf_integer_hex(unsigned long, call_site, call_site)
73+ ctf_integer_hex(const void *, ptr, ptr)
74+ ctf_string(name, name)
75+ )
76+)
77+#else
78 LTTNG_TRACEPOINT_EVENT_CLASS(kmem_free,
79
80 TP_PROTO(unsigned long call_site, const void *ptr),
81@@ -114,6 +140,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_free, kmem_cache_free,
82
83 TP_ARGS(call_site, ptr)
84 )
85+#endif
86
87 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0))
88 LTTNG_TRACEPOINT_EVENT_MAP(mm_page_free, kmem_mm_page_free,
89--
902.19.1
91
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch b/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch
deleted file mode 100644
index 8a839c2b43..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From 92cc3e7f76a545a2cd4828576971f1eea83f4e68 Mon Sep 17 00:00:00 2001
2From: Francis Deslauriers <francis.deslauriers@efficios.com>
3Date: Wed, 17 Mar 2021 10:40:56 -0400
4Subject: [PATCH 4/4] Fix: kretprobe: null ptr deref on session destroy
5
6The `filter_bytecode_runtime_head` list is currently not initialized for
7the return event of the kretprobe. This caused a kernel null ptr
8dereference when destroying a session. It can reproduced with the
9following commands:
10
11 lttng create
12 lttng enable-event -k --function=lttng_test_filter_event_write my_event
13 lttng start
14 lttng stop
15 lttng destroy
16
17Upstream-status: backport
18
19Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
20Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
21Change-Id: I1162ce8b10dd7237a26331531f048346b984eee7
22---
23 lttng-events.c | 2 ++
24 1 file changed, 2 insertions(+)
25
26diff --git a/lttng-events.c b/lttng-events.c
27index 984bd341..3450fa40 100644
28--- a/lttng-events.c
29+++ b/lttng-events.c
30@@ -704,6 +704,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
31 event_return->enabled = 0;
32 event_return->registered = 1;
33 event_return->instrumentation = itype;
34+ INIT_LIST_HEAD(&event_return->bytecode_runtime_head);
35+ INIT_LIST_HEAD(&event_return->enablers_ref_head);
36 /*
37 * Populate lttng_event structure before kretprobe registration.
38 */
39--
402.19.1
41
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0005-fix-block-add-a-disk_uevent-helper-v5.12.patch b/meta/recipes-kernel/lttng/lttng-modules/0005-fix-block-add-a-disk_uevent-helper-v5.12.patch
deleted file mode 100644
index 3a2280ccdc..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0005-fix-block-add-a-disk_uevent-helper-v5.12.patch
+++ /dev/null
@@ -1,305 +0,0 @@
1From 17cd2dc91cb82ed342b0da699f2b1a70c1bf6a03 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Mon, 15 Mar 2021 14:54:02 -0400
4Subject: [PATCH 2/4] fix: block: add a disk_uevent helper (v5.12)
5
6See upstream commit:
7
8 commit bc359d03c7ec1bf3b86d03bafaf6bbb21e6414fd
9 Author: Christoph Hellwig <hch@lst.de>
10 Date: Sun Jan 24 11:02:39 2021 +0100
11
12 block: add a disk_uevent helper
13
14 Add a helper to call kobject_uevent for the disk and all partitions, and
15 unexport the disk_part_iter_* helpers that are now only used in the core
16 block code.
17
18Upstream-status: Backport [2.12.6]
19
20Change-Id: If6e8797049642ab382d5699660ee1dd734e92c90
21Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
22Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
23---
24 Makefile | 1 +
25 lttng-statedump-impl.c | 34 +++++++++----
26 src/wrapper/genhd.c | 111 +++++++++++++++++++++++++++++++++++++++++
27 wrapper/genhd.h | 62 +++++++++++++++++++++++
28 4 files changed, 198 insertions(+), 10 deletions(-)
29 create mode 100644 src/wrapper/genhd.c
30
31diff --git a/Makefile b/Makefile
32index a9aff3f1..34043cfb 100644
33--- a/Makefile
34+++ b/Makefile
35@@ -80,6 +80,7 @@ ifneq ($(KERNELRELEASE),)
36 wrapper/kallsyms.o \
37 wrapper/irqdesc.o \
38 wrapper/fdtable.o \
39+ wrapper/genhd.o \
40 lttng-wrapper-impl.o
41
42 ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),)
43diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c
44index 60b937c9..5511c7e8 100644
45--- a/lttng-statedump-impl.c
46+++ b/lttng-statedump-impl.c
47@@ -250,13 +250,17 @@ int lttng_enumerate_block_devices(struct lttng_session *session)
48 struct device_type *ptr_disk_type;
49 struct class_dev_iter iter;
50 struct device *dev;
51+ int ret = 0;
52
53 ptr_block_class = wrapper_get_block_class();
54- if (!ptr_block_class)
55- return -ENOSYS;
56+ if (!ptr_block_class) {
57+ ret = -ENOSYS;
58+ goto end;
59+ }
60 ptr_disk_type = wrapper_get_disk_type();
61 if (!ptr_disk_type) {
62- return -ENOSYS;
63+ ret = -ENOSYS;
64+ goto end;
65 }
66 class_dev_iter_init(&iter, ptr_block_class, NULL, ptr_disk_type);
67 while ((dev = class_dev_iter_next(&iter))) {
68@@ -272,22 +276,32 @@ int lttng_enumerate_block_devices(struct lttng_session *session)
69 (disk->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
70 continue;
71
72- disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
73- while ((part = disk_part_iter_next(&piter))) {
74+ /*
75+ * The original 'disk_part_iter_init' returns void, but our
76+ * wrapper can fail to lookup the original symbol.
77+ */
78+ if (wrapper_disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0) < 0) {
79+ ret = -ENOSYS;
80+ goto iter_exit;
81+ }
82+
83+ while ((part = wrapper_disk_part_iter_next(&piter))) {
84 char name_buf[BDEVNAME_SIZE];
85
86 if (lttng_get_part_name(disk, part, name_buf) == -ENOSYS) {
87- disk_part_iter_exit(&piter);
88- class_dev_iter_exit(&iter);
89- return -ENOSYS;
90+ wrapper_disk_part_iter_exit(&piter);
91+ ret = -ENOSYS;
92+ goto iter_exit;
93 }
94 trace_lttng_statedump_block_device(session,
95 lttng_get_part_devt(part), name_buf);
96 }
97- disk_part_iter_exit(&piter);
98+ wrapper_disk_part_iter_exit(&piter);
99 }
100+iter_exit:
101 class_dev_iter_exit(&iter);
102- return 0;
103+end:
104+ return ret;
105 }
106
107 #ifdef CONFIG_INET
108diff --git a/src/wrapper/genhd.c b/src/wrapper/genhd.c
109new file mode 100644
110index 00000000..a5a6c410
111--- /dev/null
112+++ b/src/wrapper/genhd.c
113@@ -0,0 +1,111 @@
114+/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
115+ *
116+ * wrapper/genhd.c
117+ *
118+ * Wrapper around disk_part_iter_(init|next|exit). Using KALLSYMS to get the
119+ * addresses when available, else we need to have a kernel that exports this
120+ * function to GPL modules. This export was removed in 5.12.
121+ *
122+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
123+ */
124+
125+#include <lttng/kernel-version.h>
126+#include <linux/module.h>
127+#include <wrapper/genhd.h>
128+
129+#if (defined(CONFIG_KALLSYMS) && \
130+ (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,12,0)))
131+
132+#include <wrapper/kallsyms.h>
133+
134+static
135+void (*disk_part_iter_init_sym)(struct disk_part_iter *piter, struct gendisk *disk,
136+ unsigned int flags);
137+
138+static
139+LTTNG_DISK_PART_TYPE *(*disk_part_iter_next_sym)(struct disk_part_iter *piter);
140+
141+static
142+void (*disk_part_iter_exit_sym)(struct disk_part_iter *piter);
143+
144+/*
145+ * This wrapper has an 'int' return type instead of the original 'void', to be
146+ * able to report the symbol lookup failure to the caller.
147+ *
148+ * Return 0 on success, -1 on error.
149+ */
150+int wrapper_disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
151+ unsigned int flags)
152+{
153+ if (!disk_part_iter_init_sym)
154+ disk_part_iter_init_sym = (void *) kallsyms_lookup_funcptr("disk_part_iter_init");
155+
156+ if (disk_part_iter_init_sym) {
157+ disk_part_iter_init_sym(piter, disk, flags);
158+ } else {
159+ printk_once(KERN_WARNING "LTTng: disk_part_iter_init symbol lookup failed.\n");
160+ return -1;
161+ }
162+ return 0;
163+}
164+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_init);
165+
166+LTTNG_DISK_PART_TYPE *wrapper_disk_part_iter_next(struct disk_part_iter *piter)
167+{
168+ if (!disk_part_iter_next_sym)
169+ disk_part_iter_next_sym = (void *) kallsyms_lookup_funcptr("disk_part_iter_next");
170+
171+ if (disk_part_iter_next_sym) {
172+ return disk_part_iter_next_sym(piter);
173+ } else {
174+ printk_once(KERN_WARNING "LTTng: disk_part_iter_next symbol lookup failed.\n");
175+ return NULL;
176+ }
177+}
178+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_next);
179+
180+/*
181+ * We don't return an error on symbol lookup failure here because there is
182+ * nothing the caller can do to cleanup the iterator.
183+ */
184+void wrapper_disk_part_iter_exit(struct disk_part_iter *piter)
185+{
186+ if (!disk_part_iter_exit_sym)
187+ disk_part_iter_exit_sym = (void *) kallsyms_lookup_funcptr("disk_part_iter_exit");
188+
189+ if (disk_part_iter_exit_sym) {
190+ disk_part_iter_exit_sym(piter);
191+ } else {
192+ printk_once(KERN_WARNING "LTTng: disk_part_iter_exit symbol lookup failed.\n");
193+ }
194+}
195+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_exit);
196+
197+#else
198+
199+/*
200+ * This wrapper has an 'int' return type instead of the original 'void', so the
201+ * kallsyms variant can report the symbol lookup failure to the caller.
202+ *
203+ * This variant always succeeds and returns 0.
204+ */
205+int wrapper_disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
206+ unsigned int flags)
207+{
208+ disk_part_iter_init(piter, disk, flags);
209+ return 0;
210+}
211+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_init);
212+
213+LTTNG_DISK_PART_TYPE *wrapper_disk_part_iter_next(struct disk_part_iter *piter)
214+{
215+ return disk_part_iter_next(piter);
216+}
217+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_next);
218+
219+void wrapper_disk_part_iter_exit(struct disk_part_iter *piter)
220+{
221+ disk_part_iter_exit(piter);
222+}
223+EXPORT_SYMBOL_GPL(wrapper_disk_part_iter_exit);
224+#endif
225diff --git a/wrapper/genhd.h b/wrapper/genhd.h
226index 98feb57b..6bae239d 100644
227--- a/wrapper/genhd.h
228+++ b/wrapper/genhd.h
229@@ -13,6 +13,13 @@
230 #define _LTTNG_WRAPPER_GENHD_H
231
232 #include <linux/genhd.h>
233+#include <lttng/kernel-version.h>
234+
235+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
236+#define LTTNG_DISK_PART_TYPE struct block_device
237+#else
238+#define LTTNG_DISK_PART_TYPE struct hd_struct
239+#endif
240
241 #ifdef CONFIG_KALLSYMS_ALL
242
243@@ -94,4 +101,59 @@ struct device_type *wrapper_get_disk_type(void)
244
245 #endif
246
247+/*
248+ * This wrapper has an 'int' return type instead of the original 'void', to be
249+ * able to report the symbol lookup failure to the caller.
250+ *
251+ * Return 0 on success, -1 on error.
252+ */
253+int wrapper_disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
254+ unsigned int flags);
255+LTTNG_DISK_PART_TYPE *wrapper_disk_part_iter_next(struct disk_part_iter *piter);
256+void wrapper_disk_part_iter_exit(struct disk_part_iter *piter);
257+
258+/*
259+ * Canary function to check for 'disk_part_iter_init()' at compile time.
260+ *
261+ * From 'include/linux/genhd.h':
262+ *
263+ * extern void disk_part_iter_init(struct disk_part_iter *piter,
264+ * struct gendisk *disk, unsigned int flags);
265+ *
266+ */
267+static inline
268+void __canary__disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
269+ unsigned int flags)
270+{
271+ disk_part_iter_init(piter, disk, flags);
272+}
273+
274+/*
275+ * Canary function to check for 'disk_part_iter_next()' at compile time.
276+ *
277+ * From 'include/linux/genhd.h':
278+ *
279+ * struct block_device *disk_part_iter_next(struct disk_part_iter *piter);
280+ *
281+ */
282+static inline
283+LTTNG_DISK_PART_TYPE *__canary__disk_part_iter_next(struct disk_part_iter *piter)
284+{
285+ return disk_part_iter_next(piter);
286+}
287+
288+/*
289+ * Canary function to check for 'disk_part_iter_exit()' at compile time.
290+ *
291+ * From 'include/linux/genhd.h':
292+ *
293+ * extern void disk_part_iter_exit(struct disk_part_iter *piter);
294+ *
295+ */
296+static inline
297+void __canary__disk_part_iter_exit(struct disk_part_iter *piter)
298+{
299+ return disk_part_iter_exit(piter);
300+}
301+
302 #endif /* _LTTNG_WRAPPER_GENHD_H */
303--
3042.25.1
305
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0006-fix-backport-block-add-a-disk_uevent-helper-v5.12.patch b/meta/recipes-kernel/lttng/lttng-modules/0006-fix-backport-block-add-a-disk_uevent-helper-v5.12.patch
deleted file mode 100644
index e32b3e7a2e..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0006-fix-backport-block-add-a-disk_uevent-helper-v5.12.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From 127135b6a45d5fca828815c62308f72de97e5739 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Thu, 15 Apr 2021 13:56:24 -0400
4Subject: [PATCH 3/4] fix backport: block: add a disk_uevent helper (v5.12)
5
6Upstream-Status: Backport [2.12.6]
7
8Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
9Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10Change-Id: I717162069990577abe78e5e7fed28816f32b2c84
11---
12 {src/wrapper => wrapper}/genhd.c | 2 +-
13 wrapper/genhd.h | 2 +-
14 2 files changed, 2 insertions(+), 2 deletions(-)
15 rename {src/wrapper => wrapper}/genhd.c (98%)
16
17diff --git a/src/wrapper/genhd.c b/wrapper/genhd.c
18similarity index 98%
19rename from src/wrapper/genhd.c
20rename to wrapper/genhd.c
21index a5a6c410..cbec06f7 100644
22--- a/src/wrapper/genhd.c
23+++ b/wrapper/genhd.c
24@@ -9,7 +9,7 @@
25 * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
26 */
27
28-#include <lttng/kernel-version.h>
29+#include <lttng-kernel-version.h>
30 #include <linux/module.h>
31 #include <wrapper/genhd.h>
32
33diff --git a/wrapper/genhd.h b/wrapper/genhd.h
34index 6bae239d..1b4a4201 100644
35--- a/wrapper/genhd.h
36+++ b/wrapper/genhd.h
37@@ -13,7 +13,7 @@
38 #define _LTTNG_WRAPPER_GENHD_H
39
40 #include <linux/genhd.h>
41-#include <lttng/kernel-version.h>
42+#include <lttng-kernel-version.h>
43
44 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
45 #define LTTNG_DISK_PART_TYPE struct block_device
46--
472.25.1
48
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0007-fix-mm-tracing-kfree-event-name-mismatching-with-pro.patch b/meta/recipes-kernel/lttng/lttng-modules/0007-fix-mm-tracing-kfree-event-name-mismatching-with-pro.patch
deleted file mode 100644
index dfc9427dca..0000000000
--- a/meta/recipes-kernel/lttng/lttng-modules/0007-fix-mm-tracing-kfree-event-name-mismatching-with-pro.patch
+++ /dev/null
@@ -1,71 +0,0 @@
1From 853d5903a200d8a15b3f38780ddaea5c92fa1a03 Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com>
3Date: Mon, 19 Apr 2021 09:09:28 +0000
4Subject: [PATCH 4/4] fix: mm, tracing: kfree event name mismatching with
5 provider kmem (v5.12)
6
7a8bc8ae5c932 ("fix: mm, tracing: record slab name for kmem_cache_free() (v5.12)")
8introduces the following call trace for kfree. This is caused by mismatch
9between kfree event and its provider kmem.
10
11This patch maps kfree to kmem_kfree.
12
13WARNING: CPU: 2 PID: 42294 at src/lttng-probes.c:81 fixup_lazy_probes+0xb0/0x1b0 [lttng_tracer]
14CPU: 2 PID: 42294 Comm: modprobe Tainted: G O 5.12.0-rc6-yoctodev-standard #1
15Hardware name: Intel Corporation JACOBSVILLE/JACOBSVILLE, BIOS JBVLCRB2.86B.0014.P20.2004020248 04/02/2020
16RIP: 0010:fixup_lazy_probes+0xb0/0x1b0 [lttng_tracer]
17Code: 75 28 83 c3 01 3b 5d c4 74 22 48 8b 4d d0 48 63
18 c3 4c 89 e2 4c 89 f6 48 8b 04 c1 4c 8b 38 4c 89
19 ff e8 64 9f 4b de 85 c0 74 c3 <0f> 0b 48 8b 05 bf
20 f2 1e 00 48 8d 50 e8 48 3d f0 a0 98 c0 75 18 eb
21RSP: 0018:ffffb976807bfbe0 EFLAGS: 00010286
22RAX: 00000000ffffffff RBX: 0000000000000004 RCX: 0000000000000004
23RDX: 0000000000000066 RSI: ffffffffc03c10a7 RDI: ffffffffc03c11a1
24RBP: ffffb976807bfc28 R08: 0000000000000000 R09: 0000000000000001
25R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000004
26R13: ffffffffc03c2000 R14: ffffffffc03c10a7 R15: ffffffffc03c11a1
27FS: 00007f0ef9533740(0000) GS:ffffa100faa00000(0000) knlGS:0000000000000000
28CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
29CR2: 0000561e8f0aa000 CR3: 000000015b318000 CR4: 0000000000350ee0
30Call Trace:
31 lttng_probe_register+0x38/0xe0 [lttng_tracer]
32 ? __event_probe__module_load+0x520/0x520 [lttng_probe_module]
33 __lttng_events_init__module+0x15/0x20 [lttng_probe_module]
34 do_one_initcall+0x68/0x310
35 ? kmem_cache_alloc_trace+0x2ad/0x4c0
36 ? do_init_module+0x28/0x280
37 do_init_module+0x62/0x280
38 load_module+0x26e4/0x2920
39 ? kernel_read_file+0x22e/0x290
40 __do_sys_finit_module+0xb1/0xf0
41 __x64_sys_finit_module+0x1a/0x20
42 do_syscall_64+0x38/0x50
43 entry_SYSCALL_64_after_hwframe+0x44/0xae
44
45Upstream-Status: Backport [2.12.6]
46
47Signed-off-by: He Zhe <zhe.he@windriver.com>
48Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
49Change-Id: I00e8ee2b8c35f6f8602c88295f5113fbbd139709
50---
51 instrumentation/events/lttng-module/kmem.h | 4 +++-
52 1 file changed, 3 insertions(+), 1 deletion(-)
53
54diff --git a/instrumentation/events/lttng-module/kmem.h b/instrumentation/events/lttng-module/kmem.h
55index d787ea54..c9edee61 100644
56--- a/instrumentation/events/lttng-module/kmem.h
57+++ b/instrumentation/events/lttng-module/kmem.h
58@@ -88,7 +88,9 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_alloc_node, kmem_cache_alloc_node,
59 )
60
61 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,12,0))
62-LTTNG_TRACEPOINT_EVENT(kfree,
63+LTTNG_TRACEPOINT_EVENT_MAP(kfree,
64+
65+ kmem_kfree,
66
67 TP_PROTO(unsigned long call_site, const void *ptr),
68
69--
702.25.1
71
diff --git a/meta/recipes-kernel/lttng/lttng-modules_2.12.5.bb b/meta/recipes-kernel/lttng/lttng-modules_2.12.6.bb
index c5efbb061a..94e849de59 100644
--- a/meta/recipes-kernel/lttng/lttng-modules_2.12.5.bb
+++ b/meta/recipes-kernel/lttng/lttng-modules_2.12.6.bb
@@ -11,16 +11,9 @@ include lttng-platforms.inc
11 11
12SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \ 12SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \
13 file://Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch \ 13 file://Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch \
14 file://0001-Fix-memory-leaks-on-event-destroy.patch \
15 file://0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch \
16 file://0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch \
17 file://0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch \
18 file://0005-fix-block-add-a-disk_uevent-helper-v5.12.patch \
19 file://0006-fix-backport-block-add-a-disk_uevent-helper-v5.12.patch \
20 file://0007-fix-mm-tracing-kfree-event-name-mismatching-with-pro.patch \
21 " 14 "
22 15
23SRC_URI[sha256sum] = "c4d1a1b42c728e37b6b7947ae16563a011c4b297311aa04d56f9a1791fb5a30a" 16SRC_URI[sha256sum] = "95ac2a2cf92d85d23ffbdaca6a1ec0d7c167211d1e0fb850ab90004a3f475eaa"
24 17
25export INSTALL_MOD_DIR="kernel/lttng-modules" 18export INSTALL_MOD_DIR="kernel/lttng-modules"
26 19