Received: by 10.213.65.68 with SMTP id h4csp809829imn; Wed, 28 Mar 2018 13:13:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx48DGOoUANBBnwSe9gBli6e6oRzrGg7ghjkcqnkqZuyiYhatZO7uZOVIgIpu55lkrphzn8Ih X-Received: by 10.101.90.68 with SMTP id z4mr3528802pgs.184.1522267991792; Wed, 28 Mar 2018 13:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522267991; cv=none; d=google.com; s=arc-20160816; b=KK+OORzoFPlG2mt2rIG/hR42Ar7iyxThHcXWKEB92N55gFQzsaYkDUBB+zpydm8md9 4W2r2jaBGTk36xVc0COYsII7AbY5kbRlAqfusi9/8sDrt2sdE62Zpk1lt3dYW40n5AXC yzHatQDJmwLcWGXbYN/5a5ERLEikZ9xeLicKTG9cbuv6n6xj5oHZ0KvbjA1IzF0P6nkg sbnyPIkQ0EbE6PeQnSTaj7pDVa6uUVCjeybLIAl4LsLSyBNP09bvQyP1O0fox7ADdJyR 82lylc5G9jY+uQmuc4NuH4tdxc9Du0oqmXvMse6G+doF+UXxjav3wsgJqe0Q0h+UWIXW ZBcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BqL8nx6ygW4dAzTMDeCp29HgTnGRsyA05pYTbZZKxsU=; b=0H7XRY2jWWz/KRsMOyCa2iE5oUUK1ktNYrIIP07fksgWTfTzCsRlrP3ZvE8GxxX6xh mMflsUT7yif1AgC74TQl/tTY03iJdmw0fo8Hwx1bSLPVU9WViwa/ekA5GpqFAPKjTGtC +ZDpK+uxXQCl1X9F/3VsA1K0ldA+kxb+4wHGxK0UriLaPaI5FmMHZA0t5/X0HUeVAfpe l7nWf2XI7Uq2Qjc+nzbhchjFZ2ILVS+eg+0DSKHC0Rm7mjQbX99dXeIHRAGnF8rTsp7n VZOACnF4F14pYDWQ5Vja+/UdOuYaOWmIp99RHcZLagPNhVVB8s+yDq35yvZnXVJ+eTzt lTOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si3344055pfb.204.2018.03.28.13.12.57; Wed, 28 Mar 2018 13:13:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753637AbeC1UL0 (ORCPT + 99 others); Wed, 28 Mar 2018 16:11:26 -0400 Received: from mga18.intel.com ([134.134.136.126]:51848 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbeC1ULO (ORCPT ); Wed, 28 Mar 2018 16:11:14 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 13:11:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,373,1517904000"; d="scan'208";a="46106760" Received: from tzanussi-mobl.amr.corp.intel.com (HELO localhost) ([10.252.193.206]) by orsmga002.jf.intel.com with ESMTP; 28 Mar 2018 13:11:12 -0700 From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, rajvi.jingar@intel.com, julia@ni.com, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH 4/4] tracing: Make sure variable string fields are NULL-terminated Date: Wed, 28 Mar 2018 15:10:56 -0500 Message-Id: X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Tom Zanussi --- 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 ae84470..2751a0f 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]; @@ -3090,7 +3090,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); -- 1.9.3