Received: by 10.213.65.68 with SMTP id h4csp595021imn; Wed, 28 Mar 2018 09:09:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48x6VwParErqW1jXYh7GbvrCDr7+lfl2vZXW0tKK9NfJ9FFZ12BoFPYIQIBjcKHAqFp11mv X-Received: by 2002:a17:902:9692:: with SMTP id n18-v6mr4426259plp.67.1522253391836; Wed, 28 Mar 2018 09:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522253391; cv=none; d=google.com; s=arc-20160816; b=EHlZEXHRFBQzhwsZeEpfzp9CqhOi9DmLxiGeiJ3islTR6G6xlkRgKhOnO/MyWuGoDv dmlbyQRiAABnzd3pwej6eMNH+zzC4IW1C5CyHjxhuSdVNXlLSmqLWjKCDpnXQbZWLpOx McCZ7Z4CY3SKPQgtZVtk7FUrPveH9FcpKxZwoWjEsGI++7xUZfKkKuqySQVlK18ECTod cvLiRSF6GTXFtxiC/aerdnihovLRLusVPkzoAREGQCecmasdfmwKdpKfHlRvys4p/V7Y h17jpIePyMyNyrtNUUR51qQ8ntweYDVcaefQVGFguo6lYe9FN/T/KqSUo2bRwfpJMYF+ Exhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=Bz3NwjknMfWxmq9gufllRXWJrpknzOzZcWznqECH0hU=; b=qoT6lZli7NO+aHM9XrDe7qsxZKKDqlUdDVssUPkEb/cvkFyXlS2frDyu/QPQxUr2Xv 0WYVC+vivUzdk2K1HVZLWz7n3HyA+OAKmUgQLlbVSHMpTDM6mis9VdDwLvop+hCIAvS7 6SUGmyuYmXZmQmGtk60HbpEakLNJavvM2wCuLC2OMh0/CjLBVyKc8Sx7SylzriTSJKN6 NIzzUf/hHNAheo961M2CyifYxb+cZAi1SkVrUMawIsrA5YLA1V419ZBaU8p2YEHi5KCW HdX2ABec7RfNUuJvww/lCtABQCxS9A/weaNUwFAeohoNH4l5H0vYG56dM62N9B+TeD6N Ra/Q== 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 l5si3065358pfa.368.2018.03.28.09.09.37; Wed, 28 Mar 2018 09:09:51 -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 S1753856AbeC1OcW (ORCPT + 99 others); Wed, 28 Mar 2018 10:32:22 -0400 Received: from mga17.intel.com ([192.55.52.151]:52188 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753609AbeC1OcU (ORCPT ); Wed, 28 Mar 2018 10:32:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 07:32:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,371,1517904000"; d="scan'208";a="41445922" Received: from tzanussi-mobl.amr.corp.intel.com (HELO [10.252.193.206]) ([10.252.193.206]) by fmsmga004.fm.intel.com with ESMTP; 28 Mar 2018 07:32:19 -0700 Message-ID: <1522247538.10197.3.camel@tzanussi-mobl.amr.corp.intel.com> Subject: Re: [PATCH] tracing: avoid string overflow From: Tom Zanussi To: Arnd Bergmann Cc: Steven Rostedt , Ingo Molnar , Rajvi Jingar , linux-kernel@vger.kernel.org Date: Wed, 28 Mar 2018 09:32:18 -0500 In-Reply-To: <20180328140920.2842153-1-arnd@arndb.de> References: <20180328140920.2842153-1-arnd@arndb.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On Wed, 2018-03-28 at 16:09 +0200, Arnd Bergmann wrote: > 'err' is used as a NUL-terminated string, but using strncpy() with the length > equal to the buffer size may result in lack of the termination: > > kernel/trace/trace_events_hist.c: In function 'hist_err_event': > kernel/trace/trace_events_hist.c:396:3: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] > strncpy(err, var, MAX_FILTER_STR_VAL); > > This changes it to use the safer strscpy() instead. > > Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers") > Signed-off-by: Arnd Bergmann > --- > kernel/trace/trace_events_hist.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > index 4f027642ceef..8357f36d7a1e 100644 > --- a/kernel/trace/trace_events_hist.c > +++ b/kernel/trace/trace_events_hist.c > @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var) > else if (system) > snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event); > else > - strncpy(err, var, MAX_FILTER_STR_VAL); > + strscpy(err, var, MAX_FILTER_STR_VAL); > > hist_err(str, err); > } Yes, thanks for finding this, and for the patch! Acked-by: Tom Zanussi