tracing: Prevent further users of zero size static arrays in trace events
authorSteven Rostedt (VMware) <[email protected]>
Thu, 10 May 2018 16:40:21 +0000 (12:40 -0400)
committerSteven Rostedt (VMware) <[email protected]>
Tue, 29 May 2018 12:29:13 +0000 (08:29 -0400)
A zero size static array has special meaning in the ftrace infrastructure.
Trace events are for recording data in the trace buffers that is normally
difficult to obtain via probes or function tracing. There is no reason for
any trace event to declare a zero size static array.

If one does, BUILD_BUG_ON() will trigger and prevent the kernel from
compiling.

Reviewed-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
include/trace/trace_events.h

index bfda803b0a09319f02156958c40973a978ceba2f..4ecdfe2e3580077630326a41b34702374c8ebe82 100644 (file)
@@ -422,6 +422,7 @@ static struct trace_event_functions trace_event_type_funcs_##call = {       \
        do {                                                            \
                char *type_str = #type"["__stringify(len)"]";           \
                BUILD_BUG_ON(len > MAX_FILTER_STR_VAL);                 \
+               BUILD_BUG_ON(len <= 0);                                 \
                ret = trace_define_field(event_call, type_str, #item,   \
                                 offsetof(typeof(field), item),         \
                                 sizeof(field.item),                    \