blob: 351184dabb6c2c3e2de45dbe82f81f58dde1390e [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 0a0d736ec89dffdbc83e7181166a99d5563acfe8 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Mon, 5 Nov 2018 11:35:52 -0500
4Subject: [PATCH 1/9] Fix: signal: Distinguish between kernel_siginfo and
5 siginfo (v4.20)
6
7See upstream commit :
8
9 commit ae7795bc6187a15ec51cf258abae656a625f9980
10 Author: Eric W. Biederman <ebiederm@xmission.com>
11 Date: Tue Sep 25 11:27:20 2018 +0200
12
13 signal: Distinguish between kernel_siginfo and siginfo
14
15 Linus recently observed that if we did not worry about the padding
16 member in struct siginfo it is only about 48 bytes, and 48 bytes is
17 much nicer than 128 bytes for allocating on the stack and copying
18 around in the kernel.
19
20 The obvious thing of only adding the padding when userspace is
21 including siginfo.h won't work as there are sigframe definitions in
22 the kernel that embed struct siginfo.
23
24 So split siginfo in two; kernel_siginfo and siginfo. Keeping the
25 traditional name for the userspace definition. While the version that
26 is used internally to the kernel and ultimately will not be padded to
27 128 bytes is called kernel_siginfo.
28
29 The definition of struct kernel_siginfo I have put in include/signal_types.h
30
31 A set of buildtime checks has been added to verify the two structures have
32 the same field offsets.
33
34 To make it easy to verify the change kernel_siginfo retains the same
35 size as siginfo. The reduction in size comes in a following change.
36
37Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
38Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
39
40Upstream-Status: backport https://github.com/lttng/lttng-modules/commit/0a0d736ec89dffdbc83e7181166a99d5563acfe8
41
42Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
43---
44 instrumentation/events/lttng-module/signal.h | 41 ++++++++++++++++++--
45 1 file changed, 37 insertions(+), 4 deletions(-)
46
47diff --git a/instrumentation/events/lttng-module/signal.h b/instrumentation/events/lttng-module/signal.h
48index b3c9126..8783b52 100644
49--- a/instrumentation/events/lttng-module/signal.h
50+++ b/instrumentation/events/lttng-module/signal.h
51@@ -35,21 +35,24 @@
52 * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
53 * means that si_code is SI_KERNEL.
54 */
55-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
56+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
57 LTTNG_TRACEPOINT_EVENT(signal_generate,
58
59- TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
60+ TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
61+ int group, int result),
62
63- TP_ARGS(sig, info, task),
64+ TP_ARGS(sig, info, task, group, result),
65
66 TP_FIELDS(
67 ctf_integer(int, sig, sig)
68 LTTNG_FIELDS_SIGINFO(info)
69 ctf_array_text(char, comm, task->comm, TASK_COMM_LEN)
70 ctf_integer(pid_t, pid, task->pid)
71+ ctf_integer(int, group, group)
72+ ctf_integer(int, result, result)
73 )
74 )
75-#else
76+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
77 LTTNG_TRACEPOINT_EVENT(signal_generate,
78
79 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
80@@ -66,6 +69,20 @@ LTTNG_TRACEPOINT_EVENT(signal_generate,
81 ctf_integer(int, result, result)
82 )
83 )
84+#else
85+LTTNG_TRACEPOINT_EVENT(signal_generate,
86+
87+ TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
88+
89+ TP_ARGS(sig, info, task),
90+
91+ TP_FIELDS(
92+ ctf_integer(int, sig, sig)
93+ LTTNG_FIELDS_SIGINFO(info)
94+ ctf_array_text(char, comm, task->comm, TASK_COMM_LEN)
95+ ctf_integer(pid_t, pid, task->pid)
96+ )
97+)
98 #endif
99
100 /**
101@@ -82,6 +99,21 @@ LTTNG_TRACEPOINT_EVENT(signal_generate,
102 * This means, this can show which signals are actually delivered, but
103 * matching generated signals and delivered signals may not be correct.
104 */
105+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
106+LTTNG_TRACEPOINT_EVENT(signal_deliver,
107+
108+ TP_PROTO(int sig, struct kernel_siginfo *info, struct k_sigaction *ka),
109+
110+ TP_ARGS(sig, info, ka),
111+
112+ TP_FIELDS(
113+ ctf_integer(int, sig, sig)
114+ LTTNG_FIELDS_SIGINFO(info)
115+ ctf_integer(unsigned long, sa_handler, (unsigned long) ka->sa.sa_handler)
116+ ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags)
117+ )
118+)
119+#else
120 LTTNG_TRACEPOINT_EVENT(signal_deliver,
121
122 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
123@@ -95,6 +127,7 @@ LTTNG_TRACEPOINT_EVENT(signal_deliver,
124 ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags)
125 )
126 )
127+#endif
128
129 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
130 LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow,
131--
1322.19.1
133