Skip to content

Commit d0a3022

Browse files
beaubelgraverostedt
authored andcommitted
tracing/user_events: Fix struct arg size match check
When users register an event the name of the event and it's argument are checked to ensure they match if the event already exists. Normally all arguments are in the form of "type name", except for when the type starts with "struct ". In those cases, the size of the struct is passed in addition to the name, IE: "struct my_struct a 20" for an argument that is of type "struct my_struct" with a field name of "a" and has the size of 20 bytes. The current code does not honor the above case properly when comparing a match. This causes the event register to fail even when the same string was used for events that contain a struct argument within them. The example above "struct my_struct a 20" generates a match string of "struct my_struct a" omitting the size field. Add the struct size of the existing field when generating a comparison string for a struct field to ensure proper match checking. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: e6f89a1 ("tracing/user_events: Ensure user provided strings are safely formatted") Signed-off-by: Beau Belgrave <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent b599b06 commit d0a3022

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/trace/trace_events_user.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,9 @@ static int user_field_set_string(struct ftrace_event_field *field,
13171317
pos += snprintf(buf + pos, LEN_OR_ZERO, " ");
13181318
pos += snprintf(buf + pos, LEN_OR_ZERO, "%s", field->name);
13191319

1320+
if (str_has_prefix(field->type, "struct "))
1321+
pos += snprintf(buf + pos, LEN_OR_ZERO, " %d", field->size);
1322+
13201323
if (colon)
13211324
pos += snprintf(buf + pos, LEN_OR_ZERO, ";");
13221325

0 commit comments

Comments
 (0)