summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2018-03-28 23:10:56 +0300
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2018-04-06 15:56:50 +0300
commitad452870c66e05819a99b491b500a13989a1c502 (patch)
treed38131cc0ac81f73a0daeb9625d384e7821133be
parent48f794731e4ca7b83b8b22a48bfc8641fa77dd09 (diff)
downloadlinux-ad452870c66e05819a99b491b500a13989a1c502.tar.xz
tracing: Make sure variable string fields are NULL-terminated
The strncpy() currently being used for variable string fields can result in a lack of termination if the string length is equal to the field size. Use the safer strscpy() instead, which will guarantee termination. Link: http://lkml.kernel.org/r/fb97c1e518fb358c12a4057d7445ba2c46956cd7.1522256721.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace_events_hist.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 6114939f065a..15ea11c29a51 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -669,7 +669,7 @@ static notrace void trace_event_raw_event_synth(void *__data,
char *str_val = (char *)(long)var_ref_vals[var_ref_idx + i];
char *str_field = (char *)&entry->fields[n_u64];
- strncpy(str_field, str_val, STR_VAR_LEN_MAX);
+ strscpy(str_field, str_val, STR_VAR_LEN_MAX);
n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
} else {
entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
@@ -3091,7 +3091,7 @@ static inline void __update_field_vars(struct tracing_map_elt *elt,
char *str = elt_data->field_var_str[j++];
char *val_str = (char *)(uintptr_t)var_val;
- strncpy(str, val_str, STR_VAR_LEN_MAX);
+ strscpy(str, val_str, STR_VAR_LEN_MAX);
var_val = (u64)(uintptr_t)str;
}
tracing_map_set_var(elt, var_idx, var_val);