tracing: Fix null pointer deref with SEND_SIG_FORCED
[safe/jmp/linux-2.6] / include / trace / events / signal.h
index a6d71de..17df434 100644 (file)
@@ -10,7 +10,8 @@
 
 #define TP_STORE_SIGINFO(__entry, info)                                \
        do {                                                    \
-               if (info == SEND_SIG_NOINFO) {                  \
+               if (info == SEND_SIG_NOINFO ||                  \
+                   info == SEND_SIG_FORCED) {                  \
                        __entry->errno  = 0;                    \
                        __entry->code   = SI_USER;              \
                } else if (info == SEND_SIG_PRIV) {             \
@@ -99,6 +100,66 @@ TRACE_EVENT(signal_deliver,
                  __entry->sig, __entry->errno, __entry->code,
                  __entry->sa_handler, __entry->sa_flags)
 );
+
+DECLARE_EVENT_CLASS(signal_queue_overflow,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig     )
+               __field(        int,    group   )
+               __field(        int,    errno   )
+               __field(        int,    code    )
+       ),
+
+       TP_fast_assign(
+               __entry->sig    = sig;
+               __entry->group  = group;
+               TP_STORE_SIGINFO(__entry, info);
+       ),
+
+       TP_printk("sig=%d group=%d errno=%d code=%d",
+                 __entry->sig, __entry->group, __entry->errno, __entry->code)
+);
+
+/**
+ * signal_overflow_fail - called when signal queue is overflow
+ * @sig: signal number
+ * @group: signal to process group or not (bool)
+ * @info: pointer to struct siginfo
+ *
+ * Kernel fails to generate 'sig' signal with 'info' siginfo, because
+ * siginfo queue is overflow, and the signal is dropped.
+ * 'group' is not 0 if the signal will be sent to a process group.
+ * 'sig' is always one of RT signals.
+ */
+DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info)
+);
+
+/**
+ * signal_lose_info - called when siginfo is lost
+ * @sig: signal number
+ * @group: signal to process group or not (bool)
+ * @info: pointer to struct siginfo
+ *
+ * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
+ * queue is overflow.
+ * 'group' is not 0 if the signal will be sent to a process group.
+ * 'sig' is always one of non-RT signals.
+ */
+DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info)
+);
+
 #endif /* _TRACE_SIGNAL_H */
 
 /* This part must be outside protection */