summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch
diff options
context:
space:
mode:
authorQuanyang Wang <quanyang.wang@windriver.com>2019-12-13 14:19:52 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-31 10:37:23 +0000
commit0dc56663c6a47140fc9c3beb43d756054f995766 (patch)
treeee201b4938c71636a3c3c500d0825ce752012249 /meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch
parent07ae996d849e5edf91e2fb6712c801d10c148222 (diff)
downloadpoky-0dc56663c6a47140fc9c3beb43d756054f995766.tar.gz
lttng-modules: fix NULL pointer deference error when testing rpc_task_running
This is a backport from upstream https://github.com/lttng/lttng-modules.git stable-2.10 to fix NULL pointer deference error when running kts testcase lttng_syscall_events. (From OE-Core rev: a522ccff838ba1577255c90e64d98dd75470fb0a) (From OE-Core rev: 754d0ae5a960056468cdf50e5965a4c22515f8f9) Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch')
-rw-r--r--meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch130
1 files changed, 130 insertions, 0 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch b/meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch
new file mode 100644
index 0000000000..4dd726cf2c
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-modules/0004-sunrpc-introduce-lttng_get_clid-helper.patch
@@ -0,0 +1,130 @@
1From b6903d57e4c3234ec5b1c7f72e232023cdee0fab Mon Sep 17 00:00:00 2001
2From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3Date: Thu, 12 Dec 2019 10:39:38 -0500
4Subject: [PATCH 4/4] sunrpc: introduce lttng_get_clid helper
5
6Introduce the lttng_get_clid helper to always check for NULL pointer
7when getting the client id. While not always strictly needed depending
8on the tracepoint callsite, prefer robustness of instrumentation and
9always check for NULL rather than play whack-a-mole.
10
11Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12Upstream-Status: Backport [https://github.com/lttng/lttng-modules/commit/1330a091a687a406513c3a326c2fc2a0dbe75536]
13Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
14---
15 instrumentation/events/lttng-module/rpc.h | 43 ++++++++++++++++-------
16 1 file changed, 31 insertions(+), 12 deletions(-)
17
18diff --git a/instrumentation/events/lttng-module/rpc.h b/instrumentation/events/lttng-module/rpc.h
19index 2d06e55..ceaf9db 100644
20--- a/instrumentation/events/lttng-module/rpc.h
21+++ b/instrumentation/events/lttng-module/rpc.h
22@@ -9,6 +9,29 @@
23 #include <linux/sunrpc/sched.h>
24 #include <linux/sunrpc/clnt.h>
25
26+#ifndef ONCE_LTTNG_RPC_H
27+#define ONCE_LTTNG_RPC_H
28+
29+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
30+static inline
31+int lttng_get_clid(const struct rpc_task *task)
32+{
33+ struct rpc_clnt *tk_client;
34+
35+ tk_client = task->tk_client;
36+ if (!tk_client)
37+ return -1;
38+ /*
39+ * The cl_clid field is always initialized to positive signed
40+ * integers. Negative signed integer values are treated as
41+ * errors.
42+ */
43+ return (int) tk_client->cl_clid;
44+}
45+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
46+
47+#endif /* ONCE_LTTNG_RPC_H */
48+
49 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
50 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
51
52@@ -18,7 +41,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
53
54 TP_FIELDS(
55 ctf_integer(unsigned int, task_id, task->tk_pid)
56- ctf_integer(int, client_id, task->tk_client->cl_clid)
57+ ctf_integer(int, client_id, lttng_get_clid(task))
58 ctf_integer(int, status, task->tk_status)
59 )
60 )
61@@ -43,7 +66,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
62
63 TP_FIELDS(
64 ctf_integer(unsigned int, task_id, task->tk_pid)
65- ctf_integer(int, client_id, task->tk_client->cl_clid)
66+ ctf_integer(int, client_id, lttng_get_clid(task))
67 ctf_integer(int, status, task->tk_status)
68 )
69 )
70@@ -100,7 +123,7 @@ LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
71
72 TP_FIELDS(
73 ctf_integer(unsigned int, task_id, task->tk_pid)
74- ctf_integer(int, client_id, task->tk_client->cl_clid)
75+ ctf_integer(int, client_id, lttng_get_clid(task))
76 ctf_integer(int, status, task->tk_status)
77 )
78 )
79@@ -112,7 +135,7 @@ LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
80
81 TP_FIELDS(
82 ctf_integer(unsigned int, task_id, task->tk_pid)
83- ctf_integer(int, client_id, task->tk_client->cl_clid)
84+ ctf_integer(int, client_id, lttng_get_clid(task))
85 ctf_integer(int, status, status)
86 )
87 )
88@@ -139,8 +162,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
89
90 TP_FIELDS(
91 ctf_integer(unsigned int, task_id, task->tk_pid)
92- ctf_integer(int, client_id, task->tk_client ?
93- task->tk_client->cl_clid : -1)
94+ ctf_integer(int, client_id, lttng_get_clid(task))
95 ctf_integer_hex(const void *, action, action)
96 ctf_integer(unsigned long, runstate, task->tk_runstate)
97 ctf_integer(int, status, task->tk_status)
98@@ -177,8 +199,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
99
100 TP_FIELDS(
101 ctf_integer(unsigned int, task_id, task->tk_pid)
102- ctf_integer(int, client_id, task->tk_client ?
103- task->tk_client->cl_clid : -1)
104+ ctf_integer(int, client_id, lttng_get_clid(task))
105 ctf_integer(unsigned long, timeout, task->tk_timeout)
106 ctf_integer(unsigned long, runstate, task->tk_runstate)
107 ctf_integer(int, status, task->tk_status)
108@@ -210,8 +231,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
109
110 TP_FIELDS(
111 ctf_integer(unsigned int, task_id, task->tk_pid)
112- ctf_integer(int, client_id, task->tk_client ?
113- task->tk_client->cl_clid : -1)
114+ ctf_integer(int, client_id, lttng_get_clid(task))
115 ctf_integer_hex(const void *, action, action)
116 ctf_integer(unsigned long, runstate, task->tk_runstate)
117 ctf_integer(int, status, task->tk_status)
118@@ -248,8 +268,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
119
120 TP_FIELDS(
121 ctf_integer(unsigned int, task_id, task->tk_pid)
122- ctf_integer(int, client_id, task->tk_client ?
123- task->tk_client->cl_clid : -1)
124+ ctf_integer(int, client_id, lttng_get_clid(task))
125 ctf_integer(unsigned long, timeout, task->tk_timeout)
126 ctf_integer(unsigned long, runstate, task->tk_runstate)
127 ctf_integer(int, status, task->tk_status)
128--
1292.17.1
130