public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [for-next][PATCH 09/18] tracing: Make sure variable string fields are NULL-terminated
Date: Fri, 06 Apr 2018 09:00:44 -0400	[thread overview]
Message-ID: <20180406130113.056305093@goodmis.org> (raw)
In-Reply-To: 20180406130035.400292196@goodmis.org

[-- Attachment #1: 0009-tracing-Make-sure-variable-string-fields-are-NULL-te.patch --]
[-- Type: text/plain, Size: 1583 bytes --]

From: Tom Zanussi <tom.zanussi@linux.intel.com>

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>
---
 kernel/trace/trace_events_hist.c | 4 ++--
 1 file 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);
-- 
2.15.1

  parent reply	other threads:[~2018-04-06 13:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 13:00 [for-next][PATCH 00/18] tracing: Last minute updates before pushing to Linus Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 01/18] tracing: Fix a potential NULL dereference Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 02/18] init: Fix initcall0 name as it is "pure" not "early" Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 03/18] tracing: Default to using trace_global_clock if sched_clock is unstable Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 04/18] tracing: Mention trace_clock=global when warning about unstable clocks Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 05/18] ftrace: Drop a VLA in module_exists() Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 06/18] tracing: Fix display of hist trigger expressions containing timestamps Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 07/18] tracing: Dont add flag strings when displaying variable references Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 08/18] tracing: Add action comparisons when testing matching hist triggers Steven Rostedt
2018-04-06 13:00 ` Steven Rostedt [this message]
2018-04-06 13:00 ` [for-next][PATCH 10/18] tracing: Uninitialized variable in create_tracing_map_fields() Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 11/18] vsprintf: Do not preprocess non-dereferenced pointers for bprintf (%px and %pK) Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 12/18] lockdep: Add print_irqtrace_events() to __warn Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 13/18] ring-buffer: Check if memory is available before allocation Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 14/18] ring-buffer: Add set/clear_current_oom_origin() during allocations Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 15/18] tracing: Hide global trace clock from lockdep Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 16/18] tracing: Fixup logic inversion on setting trace_global_clock defaults Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 17/18] tracing: Add rcu dereference annotation for filter->prog Steven Rostedt
2018-04-06 13:00 ` [for-next][PATCH 18/18] tracing: Add rcu dereference annotation for test func that touches filter->prog Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180406130113.056305093@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tom.zanussi@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox