Skip to content

Commit 00d9593

Browse files
committed
Merge tag 'trace-v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull more tracing updates from Steven Rostedt: "These are three simple changes. The first one is just a switch from using strcpy() to strlcpy(). Someone thought that it may cause an overflow bug, but since it only copies comms into a pre-allocated array of TASK_COMM_LEN, and no comm should ever be bigger than that, nor not end with a nul character, this change is more of a safety precaution than fixing anything that is actually broken. The other two changes are simply cleaning and optimizing some code" * tag 'trace-v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ftrace: Simplify ftrace_match_record() even more ftrace: Remove an unneeded condition tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline()
2 parents 3341713 + 77c0edd commit 00d9593

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

kernel/trace/ftrace.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,22 +3631,20 @@ ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g,
36313631
/* blank module name to match all modules */
36323632
if (!mod_g->len) {
36333633
/* blank module globbing: modname xor exclude_mod */
3634-
if ((!exclude_mod) != (!modname))
3634+
if (!exclude_mod != !modname)
36353635
goto func_match;
36363636
return 0;
36373637
}
36383638

3639-
/* not matching the module */
3640-
if (!modname || !mod_matches) {
3641-
if (exclude_mod)
3642-
goto func_match;
3643-
else
3644-
return 0;
3645-
}
3646-
3647-
if (mod_matches && exclude_mod)
3639+
/*
3640+
* exclude_mod is set to trace everything but the given
3641+
* module. If it is set and the module matches, then
3642+
* return 0. If it is not set, and the module doesn't match
3643+
* also return 0. Otherwise, check the function to see if
3644+
* that matches.
3645+
*/
3646+
if (!mod_matches == !exclude_mod)
36483647
return 0;
3649-
36503648
func_match:
36513649
/* blank search means to match all funcs in the mod */
36523650
if (!func_g->len)

kernel/trace/trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ static void __trace_find_cmdline(int pid, char comm[])
19761976

19771977
map = savedcmd->map_pid_to_cmdline[pid];
19781978
if (map != NO_CMDLINE_MAP)
1979-
strcpy(comm, get_saved_cmdlines(map));
1979+
strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
19801980
else
19811981
strcpy(comm, "<...>");
19821982
}

0 commit comments

Comments
 (0)